Skip to contentSkip to conversation

perf: fix building error in x86_64 when dwarf unwind is on

PATCH In review Wang Nan 5 participants 16 messages Dec 27, 2014 – Feb 3, 2015 perf events

lore
Share & tools
lore

Wang Nan

author
#0 lore raw

PATCH 1/1 perf: fix building error in x86_64 when dwarf unwind is on

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

This patch fixes it by checking __x86_64__ in both case of 'ARCH=x86_64' and 'ARCH=x86'.

---
 tools/perf/config/Makefile.arch | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/config/Makefile.arch +2 -0
index 851cd01..303a096 100644
@@ -15,6 +15,8 @@ endif
 
 ifeq ($(ARCH),x86_64)
   override ARCH := x86
+endif
+ifeq ($(ARCH),x86)
   IS_X86_64 := 0
   ifeq (, $(findstring m32,$(CFLAGS)))
     IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
Signature · 1 line
1.8.4
maintainer
#1 lore raw

Hi Wang,

(Adding Arnaldo and Jiri to CC)

Quoted 13 lines · Wang Nan

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Quoted 4 lines

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

Hmm.. how did you compile this? I guess ARCH=x86 requires -m32 flag to the gcc, did you pass it (like via EXTRA_CFLAGS=-m32)?

I'm confused by 'underlying compile may also be x86_64' part..

Thanks,
Namhyung

Quoted 30 lines

This patch fixes it by checking __x86_64__ in both case of 'ARCH=x86_64' and 'ARCH=x86'.

---
 tools/perf/config/Makefile.arch | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/config/Makefile.arch +2 -0
index 851cd01..303a096 100644
@@ -15,6 +15,8 @@ endif
 
 ifeq ($(ARCH),x86_64)
   override ARCH := x86
+endif
+ifeq ($(ARCH),x86)
   IS_X86_64 := 0
   ifeq (, $(findstring m32,$(CFLAGS)))
     IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
Signature · 7 lines
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author
#2 lore raw
Quoted 23 lines · Namhyung Kim

Hi Wang,

(Adding Arnaldo and Jiri to CC)

Quoted 13 lines · Wang Nan

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Quoted 4 lines

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

Quoted 5 lines

Hmm.. how did you compile this? I guess ARCH=x86 requires -m32 flag to the gcc, did you pass it (like via EXTRA_CFLAGS=-m32)?

I'm confused by 'underlying compile may also be x86_64' part..

I hit this problem when building perf with Yocto (https://www.yoctoproject.org/), which is a famous building system for embeded system.

When building kernel, we can simply use 'make ARCH=x86' and select 'CONFIG_64BIT' in menuconfig to get a x86_64 kernel. As a result, there building framework like Yocto doesn't ever consider 'x86_64' as a valid ARCH option. See:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/kernel-arch.bbclass
Therefore, when building with such framework, it uses a x86_64 compiler and ARCH=x86.

Quoted 34 lines

Thanks,
Namhyung

Quoted 30 lines

This patch fixes it by checking __x86_64__ in both case of 'ARCH=x86_64' and 'ARCH=x86'.

---
 tools/perf/config/Makefile.arch | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/config/Makefile.arch +2 -0
index 851cd01..303a096 100644
@@ -15,6 +15,8 @@ endif
 
 ifeq ($(ARCH),x86_64)
   override ARCH := x86
+endif
+ifeq ($(ARCH),x86)
   IS_X86_64 := 0
   ifeq (, $(findstring m32,$(CFLAGS)))
     IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
Signature · 7 lines
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author
#3 lore raw

Ping...

Quoted 81 lines · Wang Nan
Quoted 23 lines · Namhyung Kim

Hi Wang,

(Adding Arnaldo and Jiri to CC)

Quoted 13 lines · Wang Nan

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Quoted 4 lines

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

Quoted 5 lines

Hmm.. how did you compile this? I guess ARCH=x86 requires -m32 flag to the gcc, did you pass it (like via EXTRA_CFLAGS=-m32)?

I'm confused by 'underlying compile may also be x86_64' part..

I hit this problem when building perf with Yocto (https://www.yoctoproject.org/), which is a famous building system for embeded system.

When building kernel, we can simply use 'make ARCH=x86' and select 'CONFIG_64BIT' in menuconfig to get a x86_64 kernel. As a result, there building framework like Yocto doesn't ever consider 'x86_64' as a valid ARCH option. See:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/kernel-arch.bbclass
Therefore, when building with such framework, it uses a x86_64 compiler and ARCH=x86.

Quoted 29 lines

Thanks,
Namhyung

Quoted 25 lines

This patch fixes it by checking __x86_64__ in both case of 'ARCH=x86_64' and 'ARCH=x86'.

---
 tools/perf/config/Makefile.arch | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/config/Makefile.arch +2 -0
index 851cd01..303a096 100644
@@ -15,6 +15,8 @@ endif
 
 ifeq ($(ARCH),x86_64)
   override ARCH := x86
+endif
+ifeq ($(ARCH),x86)
   IS_X86_64 := 0
   ifeq (, $(findstring m32,$(CFLAGS)))
     IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
Signature · 1 line
1.8.4
Quoted 5 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

maintainer
#4 lore raw

Hi,

Quoted 1 line · Wang Nan

Ping...

Sorry for long delay.

Quoted 32 lines · Wang Nan
Quoted 30 lines · Namhyung Kim
Quoted 28 lines

Hi Wang,

(Adding Arnaldo and Jiri to CC)

Quoted 13 lines · Wang Nan

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Quoted 4 lines

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

Hmm.. how did you compile this? I guess ARCH=x86 requires -m32 flag to the gcc, did you pass it (like via EXTRA_CFLAGS=-m32)?

I'm confused by 'underlying compile may also be x86_64' part..

Quoted 8 lines
Quoted 8 lines

I hit this problem when building perf with Yocto (https://www.yoctoproject.org/), which is a famous building system for embeded system.

When building kernel, we can simply use 'make ARCH=x86' and select 'CONFIG_64BIT' in menuconfig to get a x86_64 kernel. As a result, there building framework like Yocto doesn't ever consider 'x86_64' as a valid ARCH option. See:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/kernel-arch.bbclass
Therefore, when building with such framework, it uses a x86_64 compiler and ARCH=x86.

Hmm.. okay. I think that it should also be checked with the new build system for perf, Jiri? ;)

Anyway, I cleaned up the code like below.. As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

Thanks,
Namhyung

tools/perf/Makefile.perf +2 -0
index 67a03a825b3c..eb3e2f3e14b4 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(ARCH),x86)
 ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o
tools/perf/config/Makefile +1 -1
index 5d4b039fe1ed..648e31ff4021 100644
@@ -20,7 +20,7 @@ NO_PERF_REGS := 1
 
 # Additional ARCH settings for x86
 ifeq ($(ARCH),x86)
-  ifeq (${IS_X86_64}, 1)
+  ifeq (${IS_64_BIT}, 1)
     CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
     ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
     LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
tools/perf/config/Makefile.arch +13 -13
index 851cd0172a76..ff95a68741d1 100644
@@ -1,7 +1,7 @@
 
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+RAW_ARCH := $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/arm.*/arm/ -e s/sa110/arm/ \
                                   -e s/s390x/s390/ -e s/parisc64/parisc/ \
                                   -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
@@ -9,23 +9,23 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/tile.*/tile/ )
 
 # Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
-  override ARCH := x86
+ifeq ($(RAW_ARCH),i386)
+  ARCH ?= x86
 endif
 
-ifeq ($(ARCH),x86_64)
-  override ARCH := x86
-  IS_X86_64 := 0
-  ifeq (, $(findstring m32,$(CFLAGS)))
-    IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
-    RAW_ARCH := x86_64
+ifeq ($(RAW_ARCH),x86_64)
+  ARCH ?= x86
+
+  ifneq (, $(findstring m32,$(CFLAGS)))
+    RAW_ARCH := x86_32
   endif
 endif
 
-ifeq (${IS_X86_64}, 1)
+ARCH ?= $(RAW_ARCH)
+
+LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+ifeq ($(LP64), 1)
   IS_64_BIT := 1
-else ifeq ($(ARCH),x86)
-  IS_64_BIT := 0
 else
-  IS_64_BIT := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+  IS_64_BIT := 0
 endif
#5 lore raw
Quoted 42 lines · Namhyung Kim

Hi,

Quoted 1 line · Wang Nan

Ping...

Sorry for long delay.

Quoted 35 lines · Wang Nan
Quoted 33 lines · Namhyung Kim
Quoted 23 lines

Hi Wang,

(Adding Arnaldo and Jiri to CC)

Quoted 13 lines · Wang Nan

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Quoted 4 lines

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

Quoted 5 lines

Hmm.. how did you compile this? I guess ARCH=x86 requires -m32 flag to the gcc, did you pass it (like via EXTRA_CFLAGS=-m32)?

I'm confused by 'underlying compile may also be x86_64' part..

I hit this problem when building perf with Yocto (https://www.yoctoproject.org/), which is a famous building system for embeded system.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

When building kernel, we can simply use 'make ARCH=x86' and select 'CONFIG_64BIT' in menuconfig to get a x86_64 kernel. As a result, there building framework like Yocto doesn't ever consider 'x86_64' as a valid ARCH option. See:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/kernel-arch.bbclass
Therefore, when building with such framework, it uses a x86_64 compiler and ARCH=x86.

Hmm.. okay. I think that it should also be checked with the new build system for perf, Jiri? ;)

yea.. however the config/Makefile still stays as it was

but whatever change you'll make for Makefile.perf I need to transform.. but this one does not seem too massive ;-)

Quoted 14 lines

Anyway, I cleaned up the code like below.. As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

Thanks,
Namhyung

tools/perf/Makefile.perf +0 -0
index 67a03a825b3c..eb3e2f3e14b4 100644

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 470

Quoted 9 lines
tools/perf/Makefile.perf +2 -0
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(ARCH),x86)
 ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif

isn't the check for x86 superfluous here? the x86_64 check is stronger

otherwise it looks ok to me.. Wang Nan, could you please check if it fixes the issue for you?

thanks,
jirka

author
#6 lore raw
Quoted 83 lines · Jiri Olsa
Quoted 42 lines · Namhyung Kim

Hi,

Quoted 1 line · Wang Nan

Ping...

Sorry for long delay.

Quoted 35 lines · Wang Nan
Quoted 33 lines · Namhyung Kim
Quoted 23 lines

Hi Wang,

(Adding Arnaldo and Jiri to CC)

Quoted 13 lines · Wang Nan

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Quoted 4 lines

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, with 'ARCH=x86', the underlying compile may also be x86_64, which causes mismatching.

Quoted 5 lines

Hmm.. how did you compile this? I guess ARCH=x86 requires -m32 flag to the gcc, did you pass it (like via EXTRA_CFLAGS=-m32)?

I'm confused by 'underlying compile may also be x86_64' part..

I hit this problem when building perf with Yocto (https://www.yoctoproject.org/), which is a famous building system for embeded system.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

When building kernel, we can simply use 'make ARCH=x86' and select 'CONFIG_64BIT' in menuconfig to get a x86_64 kernel. As a result, there building framework like Yocto doesn't ever consider 'x86_64' as a valid ARCH option. See:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/kernel-arch.bbclass
Therefore, when building with such framework, it uses a x86_64 compiler and ARCH=x86.

Hmm.. okay. I think that it should also be checked with the new build system for perf, Jiri? ;)

yea.. however the config/Makefile still stays as it was

but whatever change you'll make for Makefile.perf I need to transform.. but this one does not seem too massive ;-)

Quoted 14 lines

Anyway, I cleaned up the code like below.. As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

Thanks,
Namhyung

tools/perf/Makefile.perf +0 -0
index 67a03a825b3c..eb3e2f3e14b4 100644

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 470

Quoted 9 lines
tools/perf/Makefile.perf +2 -0
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(ARCH),x86)
 ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif

isn't the check for x86 superfluous here? the x86_64 check is stronger

Quoted 3 lines

otherwise it looks ok to me.. Wang Nan, could you please check if it fixes the issue for you?

Sorry, although Namhyung Kim's patch solves my ARCH=x86 problem, it breaks ARM building:

...

| bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
| bench/../../../arch/x86/lib/memcpy_64.S:27: Error: junk at end of line, first unrecognized character is `,'
| bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad instruction `movq %rdi,%rax'
| bench/../../../arch/x86/lib/memcpy_64.S:30: Error: bad instruction `movq %rdx,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:31: Error: bad instruction `shrq $3,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:32: Error: bad instruction `andl $7,%edx'

...

It builds x86_64 bench when I corss compiling perf for arm (use ARCH=arm). This is caused by Makefile.perf:

...
BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o ifeq ($(RAW_ARCH),x86_64)
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o endif
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
...

Which rely on RAW_ARCH, but RAW_ARCH is not a cross-compiling-friendly variable now.

Quoted 3 lines

thanks,
jirka

maintainer
#7 lore raw
Quoted 25 lines · Wang Nan
Quoted 18 lines · Jiri Olsa
Quoted 5 lines · Namhyung Kim
tools/perf/Makefile.perf +0 -0
index 67a03a825b3c..eb3e2f3e14b4 100644

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 470

Quoted 9 lines
tools/perf/Makefile.perf +2 -0
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(ARCH),x86)
 ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif

isn't the check for x86 superfluous here? the x86_64 check is stronger

Quoted 3 lines

otherwise it looks ok to me.. Wang Nan, could you please check if it fixes the issue for you?

Sorry, although Namhyung Kim's patch solves my ARCH=x86 problem, it breaks ARM building:

Quoted 8 lines

...

| bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
| bench/../../../arch/x86/lib/memcpy_64.S:27: Error: junk at end of line, first unrecognized character is `,'
| bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad instruction `movq %rdi,%rax'
| bench/../../../arch/x86/lib/memcpy_64.S:30: Error: bad instruction `movq %rdx,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:31: Error: bad instruction `shrq $3,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:32: Error: bad instruction `andl $7,%edx'

...

Strange.. this code is included only if ARCH=x86 in config/Makefile:

# Additional ARCH settings for x86
ifeq ($(ARCH),x86)
ifeq (${IS_64_BIT}, 1)

    CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
    ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
    LIBUNWIND_LIBS = -lunwind -lunwind-x86_64

else
LIBUNWIND_LIBS = -lunwind -lunwind-x86
endif
NO_PERF_REGS := 0
endif

Did your original patch build it without a problem?

Quoted 12 lines

It builds x86_64 bench when I corss compiling perf for arm (use ARCH=arm). This is caused by Makefile.perf:

...
BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o ifeq ($(RAW_ARCH),x86_64)
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o endif
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
...

Quoted 1 line

Which rely on RAW_ARCH, but RAW_ARCH is not a cross-compiling-friendly variable now.

That's why I added the extra ARCH check.

Thanks,
Namhyung

author
#8 lore raw
Quoted 43 lines · Namhyung Kim
Quoted 25 lines · Wang Nan
Quoted 18 lines · Jiri Olsa
Quoted 5 lines · Namhyung Kim
tools/perf/Makefile.perf +0 -0
index 67a03a825b3c..eb3e2f3e14b4 100644

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 470

Quoted 9 lines
tools/perf/Makefile.perf +2 -0
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(ARCH),x86)
 ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif

isn't the check for x86 superfluous here? the x86_64 check is stronger

Quoted 3 lines

otherwise it looks ok to me.. Wang Nan, could you please check if it fixes the issue for you?

Sorry, although Namhyung Kim's patch solves my ARCH=x86 problem, it breaks ARM building:

Quoted 8 lines

...

| bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
| bench/../../../arch/x86/lib/memcpy_64.S:27: Error: junk at end of line, first unrecognized character is `,'
| bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad instruction `movq %rdi,%rax'
| bench/../../../arch/x86/lib/memcpy_64.S:30: Error: bad instruction `movq %rdx,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:31: Error: bad instruction `shrq $3,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:32: Error: bad instruction `andl $7,%edx'

...

Strange.. this code is included only if ARCH=x86 in config/Makefile:

# Additional ARCH settings for x86
ifeq ($(ARCH),x86)
ifeq (${IS_64_BIT}, 1)

    CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
    ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
    LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
Quoted 8 lines

else
LIBUNWIND_LIBS = -lunwind -lunwind-x86
endif
NO_PERF_REGS := 0
endif

Did your original patch build it without a problem?

My original patch is free from this problem.

bench/mem-memset-x86-64-asm.S doesn't use ARCH_INCLUDE, it direct include "../../../arch/x86/lib/memset_64.S".

Quoted 13 lines
Quoted 13 lines

It builds x86_64 bench when I corss compiling perf for arm (use ARCH=arm). This is caused by Makefile.perf:

...
BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o ifeq ($(RAW_ARCH),x86_64)
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o endif
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
...

Quoted 4 lines
Quoted 1 line

Which rely on RAW_ARCH, but RAW_ARCH is not a cross-compiling-friendly variable now.

That's why I added the extra ARCH check.

With your additional ARCH check, ARM compiling is passed. However I suggest you not to use $(RAW_ARCH) directly, because it is get from "uname -m", which reflects the arch of build machine, not the arch of host machine (the machine perf will run on).

What about this:

---

tools/perf/Makefile.perf +3 -1
index 67a03a82..1f71a32 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
-ifeq ($(RAW_ARCH),x86_64)
+ifeq ($(ARCH), x86)
+ifeq ($(IS_64_BIT), 1)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o
Quoted 3 lines

Thanks,
Namhyung

maintainer
#9 lore raw
Quoted 50 lines · Wang Nan
Quoted 49 lines · Namhyung Kim
Quoted 25 lines · Wang Nan
Quoted 18 lines · Jiri Olsa
Quoted 5 lines · Namhyung Kim
tools/perf/Makefile.perf +0 -0
index 67a03a825b3c..eb3e2f3e14b4 100644

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 470

Quoted 9 lines
tools/perf/Makefile.perf +2 -0
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(ARCH),x86)
 ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif

isn't the check for x86 superfluous here? the x86_64 check is stronger

Quoted 3 lines

otherwise it looks ok to me.. Wang Nan, could you please check if it fixes the issue for you?

Sorry, although Namhyung Kim's patch solves my ARCH=x86 problem, it breaks ARM building:

Quoted 8 lines

...

| bench/../../../arch/x86/lib/memcpy_64.S: Assembler messages:
| bench/../../../arch/x86/lib/memcpy_64.S:27: Error: junk at end of line, first unrecognized character is `,'
| bench/../../../arch/x86/lib/memcpy_64.S:29: Error: bad instruction `movq %rdi,%rax'
| bench/../../../arch/x86/lib/memcpy_64.S:30: Error: bad instruction `movq %rdx,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:31: Error: bad instruction `shrq $3,%rcx'
| bench/../../../arch/x86/lib/memcpy_64.S:32: Error: bad instruction `andl $7,%edx'

...

Strange.. this code is included only if ARCH=x86 in config/Makefile:

# Additional ARCH settings for x86
ifeq ($(ARCH),x86)
ifeq (${IS_64_BIT}, 1)

    CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
    ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
    LIBUNWIND_LIBS = -lunwind -lunwind-x86_64

else
LIBUNWIND_LIBS = -lunwind -lunwind-x86
endif
NO_PERF_REGS := 0
endif

Quoted 6 lines
Quoted 2 lines

Did your original patch build it without a problem?

My original patch is free from this problem.

bench/mem-memset-x86-64-asm.S doesn't use ARCH_INCLUDE, it direct include "../../../arch/x86/lib/memset_64.S".

Ah, got it.

Quoted 34 lines
Quoted 14 lines
Quoted 14 lines

It builds x86_64 bench when I corss compiling perf for arm (use ARCH=arm). This is caused by Makefile.perf:

...
BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o ifeq ($(RAW_ARCH),x86_64)
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o endif
BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
...

Quoted 4 lines
Quoted 1 line

Which rely on RAW_ARCH, but RAW_ARCH is not a cross-compiling-friendly variable now.

That's why I added the extra ARCH check.

With your additional ARCH check, ARM compiling is passed. However I suggest you not to use $(RAW_ARCH) directly, because it is get from "uname -m", which reflects the arch of build machine, not the arch of host machine (the machine perf will run on).

What about this:

---

tools/perf/Makefile.perf +0 -0
index 67a03a82..1f71a32 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 473

Quoted 10 lines
tools/perf/Makefile.perf +3 -1
-ifeq ($(RAW_ARCH),x86_64)
+ifeq ($(ARCH), x86)
+ifeq ($(IS_64_BIT), 1)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o

Looks good to me!

Thanks,
Namhyung

#10 lore raw

On Thu, Jan 08, 2015 at 02:09:20PM +0900, Namhyung Kim wrote:

SNIP

Quoted 13 lines
Quoted 13 lines

---

tools/perf/Makefile.perf +2 -1
index 67a03a82..1f71a32 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
-ifeq ($(RAW_ARCH),x86_64)
+ifeq ($(ARCH), x86)
+ifeq ($(IS_64_BIT), 1)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
Quoted 8 lines

tools/perf/Makefile.perf BUILTIN_OBJS += $(OUTPUT)builtin-bench.o · line 473

Quoted 6 lines
tools/perf/Makefile.perf +1 -0
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o

Looks good to me!

I'm little confused now.. is this on top of your earlier patch or this change stands by itself..?

could any of you please resend v2 ? ;-)

thanks,
jirka

author
#11 lore raw

PATCH 1/1 perf: fix building error in x86_64 when dwarf unwind is on.

From: Namhyung Kim <[email protected]>

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, when building x86_64 kernel, ARCH=x86 is valid and commonly used. Building systems, such as yocto, uses x86_64 compiler with 'ARCH=x86' to build x86_64 perf, which causes mismatching.

As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

(This patch is made by Namhyung Kim when replying my v1 patch:

https://lkml.org/lkml/2015/1/7/17

I modified the code to remove dependency on RAW_ARCH:

https://lkml.org/lkml/2015/1/7/865

Namhyung Kim didn't provide his SOB in his original email. I add mine only for my modification.)

---
 tools/perf/Makefile.perf        |  4 +++-
 tools/perf/config/Makefile      |  2 +-
 tools/perf/config/Makefile.arch | 26 +++++++++++++-------------
 3 files changed, 17 insertions(+), 15 deletions(-)
tools/perf/Makefile.perf +3 -1
index 67a03a82..1f71a32 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
-ifeq ($(RAW_ARCH),x86_64)
+ifeq ($(ARCH), x86)
+ifeq ($(IS_64_BIT), 1)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o
tools/perf/config/Makefile +1 -1
index 5d4b039..648e31f 100644
@@ -20,7 +20,7 @@ NO_PERF_REGS := 1
 
 # Additional ARCH settings for x86
 ifeq ($(ARCH),x86)
-  ifeq (${IS_X86_64}, 1)
+  ifeq (${IS_64_BIT}, 1)
     CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
     ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
     LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
tools/perf/config/Makefile.arch +13 -13
index 851cd01..ff95a68 100644
@@ -1,7 +1,7 @@
 
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+RAW_ARCH := $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/arm.*/arm/ -e s/sa110/arm/ \
                                   -e s/s390x/s390/ -e s/parisc64/parisc/ \
                                   -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
@@ -9,23 +9,23 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/tile.*/tile/ )
 
 # Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
-  override ARCH := x86
+ifeq ($(RAW_ARCH),i386)
+  ARCH ?= x86
 endif
 
-ifeq ($(ARCH),x86_64)
-  override ARCH := x86
-  IS_X86_64 := 0
-  ifeq (, $(findstring m32,$(CFLAGS)))
-    IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
-    RAW_ARCH := x86_64
+ifeq ($(RAW_ARCH),x86_64)
+  ARCH ?= x86
+
+  ifneq (, $(findstring m32,$(CFLAGS)))
+    RAW_ARCH := x86_32
   endif
 endif
 
-ifeq (${IS_X86_64}, 1)
+ARCH ?= $(RAW_ARCH)
+
+LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+ifeq ($(LP64), 1)
   IS_64_BIT := 1
-else ifeq ($(ARCH),x86)
-  IS_64_BIT := 0
 else
-  IS_64_BIT := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+  IS_64_BIT := 0
 endif
Signature · 1 line
1.8.4
maintainer
#12 lore raw

Re: [PATCH] perf: fix building error in x86_64 when dwarf unwind is on.

Quoted 27 lines · Wang Nan

From: Namhyung Kim <[email protected]>

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, when building x86_64 kernel, ARCH=x86 is valid and commonly used. Building systems, such as yocto, uses x86_64 compiler with 'ARCH=x86' to build x86_64 perf, which causes mismatching.

As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

(This patch is made by Namhyung Kim when replying my v1 patch:

Quoted 8 lines

https://lkml.org/lkml/2015/1/7/17

I modified the code to remove dependency on RAW_ARCH:

https://lkml.org/lkml/2015/1/7/865

Namhyung Kim didn't provide his SOB in his original email. I add mine only for my modification.)

Please feel free to add my SOB to this patch.

Thanks,
Namhyung

Quoted 96 lines
---
 tools/perf/Makefile.perf        |  4 +++-
 tools/perf/config/Makefile      |  2 +-
 tools/perf/config/Makefile.arch | 26 +++++++++++++-------------
 3 files changed, 17 insertions(+), 15 deletions(-)
tools/perf/Makefile.perf +3 -1
index 67a03a82..1f71a32 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
-ifeq ($(RAW_ARCH),x86_64)
+ifeq ($(ARCH), x86)
+ifeq ($(IS_64_BIT), 1)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o
tools/perf/config/Makefile +1 -1
index 5d4b039..648e31f 100644
@@ -20,7 +20,7 @@ NO_PERF_REGS := 1
 
 # Additional ARCH settings for x86
 ifeq ($(ARCH),x86)
-  ifeq (${IS_X86_64}, 1)
+  ifeq (${IS_64_BIT}, 1)
     CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
     ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
     LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
tools/perf/config/Makefile.arch +13 -13
index 851cd01..ff95a68 100644
@@ -1,7 +1,7 @@
 
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+RAW_ARCH := $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/arm.*/arm/ -e s/sa110/arm/ \
                                   -e s/s390x/s390/ -e s/parisc64/parisc/ \
                                   -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
@@ -9,23 +9,23 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/tile.*/tile/ )
 
 # Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
-  override ARCH := x86
+ifeq ($(RAW_ARCH),i386)
+  ARCH ?= x86
 endif
 
-ifeq ($(ARCH),x86_64)
-  override ARCH := x86
-  IS_X86_64 := 0
-  ifeq (, $(findstring m32,$(CFLAGS)))
-    IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
-    RAW_ARCH := x86_64
+ifeq ($(RAW_ARCH),x86_64)
+  ARCH ?= x86
+
+  ifneq (, $(findstring m32,$(CFLAGS)))
+    RAW_ARCH := x86_32
   endif
 endif
 
-ifeq (${IS_X86_64}, 1)
+ARCH ?= $(RAW_ARCH)
+
+LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+ifeq ($(LP64), 1)
   IS_64_BIT := 1
-else ifeq ($(ARCH),x86)
-  IS_64_BIT := 0
 else
-  IS_64_BIT := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+  IS_64_BIT := 0
 endif
Signature · 7 lines
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Acked-by
#13 lore raw

Re: [PATCH] perf: fix building error in x86_64 when dwarf unwind is on.

Quoted 32 lines · Namhyung Kim
Quoted 31 lines · Wang Nan

From: Namhyung Kim <[email protected]>

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, when building x86_64 kernel, ARCH=x86 is valid and commonly used. Building systems, such as yocto, uses x86_64 compiler with 'ARCH=x86' to build x86_64 perf, which causes mismatching.

As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

(This patch is made by Namhyung Kim when replying my v1 patch:

https://lkml.org/lkml/2015/1/7/17

I modified the code to remove dependency on RAW_ARCH:

Quoted 8 lines
Quoted 4 lines

https://lkml.org/lkml/2015/1/7/865

Namhyung Kim didn't provide his SOB in his original email. I add mine only for my modification.)

Please feel free to add my SOB to this patch.

also.. I tried 32bit build on x86_64, but I had to disable python support explicitly to succeed:

  $ make EXTRA_CFLAGS=-m32 NO_LIBPYTHON=1

seems like 'python-config --cflags' returns -m64, which beats -m32, and the features code always detects 64bit version, which fails to link at the end with all the rest 32bit stuff

hopefully some python enthusiast will fix it one day, anyway it's great the 32bit build works.. sort of ;-)

thanks,
jirka

#14 lore raw

[tip:perf/urgent] perf tools: Fix building error in x86_64 when dwarf unwind is on

In reply to Wang Nan
perf tools: Fix building error in x86_64 when dwarf unwind is on
Commit-ID:  c6e5e9fbc3ea1c1a5648a3498d085fc3978df2d4
Gitweb:     http://git.kernel.org/tip/c6e5e9fbc3ea1c1a5648a3498d085fc3978df2d4
Author:     Namhyung Kim <[email protected]>
AuthorDate: Mon, 12 Jan 2015 10:20:55 +0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 16 Jan 2015 17:49:28 -0300

perf tools: Fix building error in x86_64 when dwarf unwind is on

When build with 'make ARCH=x86' and dwarf unwind is on, there is a compiling error:

CC /home/wn/perf/arch/x86/util/unwind-libdw.o
CC /home/wn/perf/arch/x86/tests/regs_load.o
arch/x86/tests/regs_load.S: Assembler messages:
arch/x86/tests/regs_load.S:65: Error: operand type mismatch for push' arch/x86/tests/regs_load.S:72: Error: operand type mismatch for pop' make[1]: *** [/home/wn/perf/arch/x86/tests/regs_load.o] Error 1 make[1]: INTERNAL: Exiting with 25 jobserver tokens available; should be 24!
make: *** [all] Error 2
...

Which is caused by incorrectly undefine macro HAVE_ARCH_X86_64_SUPPORT. 'config/Makefile.arch' tests __x86_64__ only when 'ARCH=x86_64'. However, when building x86_64 kernel, ARCH=x86 is valid and commonly used. Build systems, such as yocto, uses x86_64 compiler with 'ARCH=x86' to build x86_64 perf, which causes mismatching.

As __LP64__ is defined for x86_64 as well, we can consolidate the __x86_64__ check to the __LP64__ check and get rid of the IS_X86_64 IMHO.

(This patch is made by Namhyung Kim when replying my v1 patch:

https://lkml.org/lkml/2015/1/7/17

I modified the code to remove dependency on RAW_ARCH:

https://lkml.org/lkml/2015/1/7/865

Namhyung Kim didn't provide his SOB in his original email. I add mine only for my modification.)

Cc Jiri Olsa <[email protected]>
Cc Li Zefan <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
[ Namhyung provided his S-o-B on a followup to this patch thread on lkml ]
---
 tools/perf/Makefile.perf        |  4 +++-
 tools/perf/config/Makefile      |  2 +-
 tools/perf/config/Makefile.arch | 26 +++++++++++++-------------
 3 files changed, 17 insertions(+), 15 deletions(-)
tools/perf/Makefile.perf +3 -1
index 67a03a82..1f71a32 100644
@@ -462,10 +462,12 @@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
 # Benchmark modules
 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
-ifeq ($(RAW_ARCH),x86_64)
+ifeq ($(ARCH), x86)
+ifeq ($(IS_64_BIT), 1)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
 endif
+endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
 BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o
tools/perf/config/Makefile +1 -1
index 5d4b039..648e31f 100644
@@ -20,7 +20,7 @@ NO_PERF_REGS := 1
 
 # Additional ARCH settings for x86
 ifeq ($(ARCH),x86)
-  ifeq (${IS_X86_64}, 1)
+  ifeq (${IS_64_BIT}, 1)
     CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
     ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
     LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
tools/perf/config/Makefile.arch +13 -13
index 851cd01..ff95a68 100644
@@ -1,7 +1,7 @@
 
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+RAW_ARCH := $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/arm.*/arm/ -e s/sa110/arm/ \
                                   -e s/s390x/s390/ -e s/parisc64/parisc/ \
                                   -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
@@ -9,23 +9,23 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
                                   -e s/tile.*/tile/ )
 
 # Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
-  override ARCH := x86
+ifeq ($(RAW_ARCH),i386)
+  ARCH ?= x86
 endif
 
-ifeq ($(ARCH),x86_64)
-  override ARCH := x86
-  IS_X86_64 := 0
-  ifeq (, $(findstring m32,$(CFLAGS)))
-    IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
-    RAW_ARCH := x86_64
+ifeq ($(RAW_ARCH),x86_64)
+  ARCH ?= x86
+
+  ifneq (, $(findstring m32,$(CFLAGS)))
+    RAW_ARCH := x86_32
   endif
 endif
 
-ifeq (${IS_X86_64}, 1)
+ARCH ?= $(RAW_ARCH)
+
+LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+ifeq ($(LP64), 1)
   IS_64_BIT := 1
-else ifeq ($(ARCH),x86)
-  IS_64_BIT := 0
 else
-  IS_64_BIT := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+  IS_64_BIT := 0
 endif
#15 lore raw

Re: [PATCH] perf: fix building error in x86_64 when dwarf unwind is on.

In reply to Wang Nan

Hi,

Commit c6e5e9fbc3ea1c1a5648a3498d085fc3978df2d4 breaks the following make invocation (-j, -C, O=, LDFLAGS=, and build directory prefix stripped to simplify report):

make ARCH=x86_64 CROSS_COMPILE= EXTRA_CFLAGS= config/Makefile:128: The path 'python-config' is not executable. config/Makefile:349: No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev
config/Makefile:401: Disabling post unwind, no support found. config/Makefile:439: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
config/Makefile:453: slang not found, disables TUI support. Please install slang-devel or libslang-dev
config/Makefile:466: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
config/Makefile:494: Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed config/Makefile:525: No python-config tool was found config/Makefile:525: Python support will not be built config/Makefile:597: No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling config/Makefile:627: No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev

Auto-detecting system features:
... dwarf: [ OFF ]
... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ OFF ]
... zlib: [ on ]

[...]

AR x86_64-linux-gnu/perf/libperf.a
LINK x86_64-linux-gnu/perf/perf
x86_64-linux-gnu/perf/tests/builtin-test.o:(.data+0x158): undefined reference to `test__perf_time_to_tsc'
collect2: ld returned 1 exit status

Thanks,
Chris