Skip to contentSkip to conversation

perf tools, x86: fix 32-bit compile on 64-bit system

PATCH In review David Ahern 4 participants 9 messages Jul 11, 2011 – Jul 21, 2011 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools, x86: fix 32-bit compile on 64-bit system

Builds for 32-bit binaries on a 64-bit host currently fail with the error:

gcc -o /tmp/perf-ppc/bench/mem-memcpy-x86-64-asm.o -c -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement -m32 -fstack-protector-all -Wstack-protector -Wvolatile-register-var -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/x86/include -I/tmp/perf-ppc/ -DLIBELF_NO_MMAP -DDWARF_SUPPORT -DNO_NEWT_SUPPORT -DNO_LIBPERL -DNO_LIBPYTHON -DHAVE_CPLUS_DEMANGLE -DNO_STRLCPY -DARCH_X86_64 bench/mem-memcpy-x86-64-asm.
S
bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad register name `%rdi'
bench/../../../arch/x86/lib/memcpy_64.S:34: Error: invalid instruction suffix for `movs'
bench/../../../arch/x86/lib/memcpy_64.S:50: Error: bad register name `%rdi'
bench/../../../arch/x86/lib/memcpy_64.S:61: Error: bad register name `%rdi'
...

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

and 64-bit builds still reference the memcpy_64.S.

---
 tools/perf/Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/Makefile +4 -1
index 940257b..c168366 100644
@@ -52,7 +52,10 @@ ifeq ($(ARCH),i386)
 endif
 ifeq ($(ARCH),x86_64)
 	ARCH := x86
-	IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	IS_X86_64 := 0
+	ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
+		IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	endif
 	ifeq (${IS_X86_64}, 1)
 		RAW_ARCH := x86_64
 		ARCH_CFLAGS := -DARCH_X86_64
Signature · 1 line
1.7.6
#1 lore raw
Quoted 3 lines · David Ahern

Builds for 32-bit binaries on a 64-bit host currently fail with the error:

gcc -o /tmp/perf-ppc/bench/mem-memcpy-x86-64-asm.o -c -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement -m32 -fstack-protector-all -Wstack-protector -Wvolatile-register-var -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/x86/include -I/tmp/perf-ppc/ -DLIBELF_NO_MMAP -DDWARF_SUPPORT -DNO_NEWT_SUPPORT -DNO_LIBPERL -DNO_LIBPYTHON -DHAVE_CPLUS_DEMANGLE -DNO_STRLCPY -DARCH_X86_64 bench/mem-memcpy-x86-64-as

m.S

Quoted 7 lines

bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:34: Error: invalid instruction suffix for movs' bench/../../../arch/x86/lib/memcpy_64.S:50: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:61: Error: bad register name %rdi'
...

Quoted 7 lines

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

and 64-bit builds still reference the memcpy_64.S.

Fairly trivial change to the Makefile. Any objections? I believe Arnaldo is out for a few more days and realistically another week to get through a month's backlog.

David

Quoted 21 lines
---
 tools/perf/Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/Makefile +4 -1
index 940257b..c168366 100644
@@ -52,7 +52,10 @@ ifeq ($(ARCH),i386)
 endif
 ifeq ($(ARCH),x86_64)
 	ARCH := x86
-	IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	IS_X86_64 := 0
+	ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
+		IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	endif
 	ifeq (${IS_X86_64}, 1)
 		RAW_ARCH := x86_64
 		ARCH_CFLAGS := -DARCH_X86_64
#2 lore raw
Quoted 4 lines · David Ahern
Quoted 3 lines · David Ahern

Builds for 32-bit binaries on a 64-bit host currently fail with the error:

gcc -o /tmp/perf-ppc/bench/mem-memcpy-x86-64-asm.o -c -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement -m32 -fstack-protector-all -Wstack-protector -Wvolatile-register-var -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/x86/include -I/tmp/perf-ppc/ -DLIBELF_NO_MMAP -DDWARF_SUPPORT -DNO_NEWT_SUPPORT -DNO_LIBPERL -DNO_LIBPYTHON -DHAVE_CPLUS_DEMANGLE -DNO_STRLCPY -DARCH_X86_64 bench/mem-memcpy-x86-64-

asm.S

Quoted 12 lines
Quoted 12 lines

bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:34: Error: invalid instruction suffix for movs' bench/../../../arch/x86/lib/memcpy_64.S:50: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:61: Error: bad register name %rdi'
...

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

Quoted 8 lines
Quoted 2 lines

and 64-bit builds still reference the memcpy_64.S.

Fairly trivial change to the Makefile. Any objections? I believe Arnaldo is out for a few more days and realistically another week to get through a month's backlog.

David

Yeah, looks good.

Thanks.

maintainer
#3 lore raw
In reply to David Ahern
Quoted 4 lines · David Ahern

Fairly trivial change to the Makefile. Any objections? I believe Arnaldo is out for a few more days and realistically another week to get through a month's backlog.

I took both patches, lets hope Ingo resurfaces soon, otherwise I'll have to push stuff to Linus directly.

#4 lore raw
In reply to David Ahern
Quoted 3 lines · David Ahern

Builds for 32-bit binaries on a 64-bit host currently fail with the error:

gcc -o /tmp/perf-ppc/bench/mem-memcpy-x86-64-asm.o -c -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement -m32 -fstack-protector-all -Wstack-protector -Wvolatile-register-var -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/x86/include -I/tmp/perf-ppc/ -DLIBELF_NO_MMAP -DDWARF_SUPPORT -DNO_NEWT_SUPPORT -DNO_LIBPERL -DNO_LIBPYTHON -DHAVE_CPLUS_DEMANGLE -DNO_STRLCPY -DARCH_X86_64 bench/mem-memcpy-x86-64-as

m.S

Quoted 7 lines

bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:34: Error: invalid instruction suffix for movs' bench/../../../arch/x86/lib/memcpy_64.S:50: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:61: Error: bad register name %rdi'
...

Quoted 8 lines

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

and 64-bit builds still reference the memcpy_64.S.

This one was missed in the recent commits. It has been acked by Frederic and Peter made a comment about picking it up. Perhaps coming through his tree?

Thanks,
David

Quoted 20 lines
---
 tools/perf/Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/Makefile +4 -1
index 940257b..c168366 100644
@@ -52,7 +52,10 @@ ifeq ($(ARCH),i386)
 endif
 ifeq ($(ARCH),x86_64)
 	ARCH := x86
-	IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	IS_X86_64 := 0
+	ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
+		IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	endif
 	ifeq (${IS_X86_64}, 1)
 		RAW_ARCH := x86_64
 		ARCH_CFLAGS := -DARCH_X86_64
#5 lore raw

[tip:perf/urgent] perf tools, x86: Fix 32-bit compile on 64-bit system

In reply to David Ahern
Commit-ID:  08a4a43fc407d780bdde36d98f89c0dbb2a6be6b
Gitweb:     http://git.kernel.org/tip/08a4a43fc407d780bdde36d98f89c0dbb2a6be6b
Author:     David Ahern <[email protected]>
AuthorDate: Mon, 11 Jul 2011 15:38:24 -0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 21 Jul 2011 13:42:30 +0200

perf tools, x86: Fix 32-bit compile on 64-bit system

Builds for 32-bit perf binaries on a 64-bit host currently fail with this error:

[...]
bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:34: Error: invalid instruction suffix for movs' bench/../../../arch/x86/lib/memcpy_64.S:50: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:61: Error: bad register name %rdi'
...

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

and 64-bit builds still reference the memcpy_64.S.

---
 tools/perf/Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/Makefile +4 -1
index 940257b..c168366 100644
@@ -52,7 +52,10 @@ ifeq ($(ARCH),i386)
 endif
 ifeq ($(ARCH),x86_64)
 	ARCH := x86
-	IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	IS_X86_64 := 0
+	ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
+		IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
+	endif
 	ifeq (${IS_X86_64}, 1)
 		RAW_ARCH := x86_64
 		ARCH_CFLAGS := -DARCH_X86_64
#6 lore raw

Re: [tip:perf/urgent] perf tools, x86: Fix 32-bit compile on 64-bit system

Quoted 20 lines · tip-bot for David Ahern
Commit-ID:  08a4a43fc407d780bdde36d98f89c0dbb2a6be6b
Gitweb:     http://git.kernel.org/tip/08a4a43fc407d780bdde36d98f89c0dbb2a6be6b
Author:     David Ahern <[email protected]>
AuthorDate: Mon, 11 Jul 2011 15:38:24 -0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 21 Jul 2011 13:42:30 +0200

perf tools, x86: Fix 32-bit compile on 64-bit system

Builds for 32-bit perf binaries on a 64-bit host currently fail with this error:

[...]
bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:34: Error: invalid instruction suffix for movs' bench/../../../arch/x86/lib/memcpy_64.S:50: Error: bad register name %rdi' bench/../../../arch/x86/lib/memcpy_64.S:61: Error: bad register name %rdi'
...

Quoted 7 lines

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

and 64-bit builds still reference the memcpy_64.S.

But this is the wrong way to build 32-bit code on 64-bit platforms. make ARCH=i386 is the supported way.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#7 lore raw

Re: [tip:perf/urgent] perf tools, x86: Fix 32-bit compile on 64-bit system

Quoted 5 lines · H. Peter Anvin
Quoted 5 lines

The problem is the detection of the host arch without considering passed in flags. This change fixes 32-bit builds via:

make EXTRA_CFLAGS=-m32

Quoted 8 lines
Quoted 2 lines

and 64-bit builds still reference the memcpy_64.S.

But this is the wrong way to build 32-bit code on 64-bit platforms. make ARCH=i386 is the supported way.

-hpa

Indeed that works fine. If that is the preferred route then the patch needs to update the following comment in the Makefile:

# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.

to specify ARCH on the command line.

David

#8 lore raw

Re: [tip:perf/urgent] perf tools, x86: Fix 32-bit compile on 64-bit system

Quoted 9 lines · David Ahern

Indeed that works fine. If that is the preferred route then the patch needs to update the following comment in the Makefile:

# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.

to specify ARCH on the command line.

And that it should.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.