Commit c6e5e9fbc3ea1c1a5648a3498d085fc3978df2d4

Authored by Namhyung Kim
Committed by Arnaldo Carvalho de Melo
1 parent 7949ba1fa2

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.)

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1421029255-23039-1-git-send-email-wangnan0@huawei.com
[ Namhyung provided his S-o-B on a followup to this patch thread on lkml ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 3 changed files with 17 additions and 15 deletions Side-by-side Diff

tools/perf/Makefile.perf
... ... @@ -462,9 +462,11 @@
462 462 # Benchmark modules
463 463 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
464 464 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
465   -ifeq ($(RAW_ARCH),x86_64)
  465 +ifeq ($(ARCH), x86)
  466 +ifeq ($(IS_64_BIT), 1)
466 467 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
467 468 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
  469 +endif
468 470 endif
469 471 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
470 472 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
tools/perf/config/Makefile
... ... @@ -20,7 +20,7 @@
20 20  
21 21 # Additional ARCH settings for x86
22 22 ifeq ($(ARCH),x86)
23   - ifeq (${IS_X86_64}, 1)
  23 + ifeq (${IS_64_BIT}, 1)
24 24 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
25 25 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
26 26 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
tools/perf/config/Makefile.arch
1 1  
2 2 uname_M := $(shell uname -m 2>/dev/null || echo not)
3 3  
4   -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
  4 +RAW_ARCH := $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
5 5 -e s/arm.*/arm/ -e s/sa110/arm/ \
6 6 -e s/s390x/s390/ -e s/parisc64/parisc/ \
7 7 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
8 8  
9 9  
10 10  
11 11  
... ... @@ -9,24 +9,24 @@
9 9 -e s/tile.*/tile/ )
10 10  
11 11 # Additional ARCH settings for x86
12   -ifeq ($(ARCH),i386)
13   - override ARCH := x86
  12 +ifeq ($(RAW_ARCH),i386)
  13 + ARCH ?= x86
14 14 endif
15 15  
16   -ifeq ($(ARCH),x86_64)
17   - override ARCH := x86
18   - IS_X86_64 := 0
19   - ifeq (, $(findstring m32,$(CFLAGS)))
20   - IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
21   - RAW_ARCH := x86_64
  16 +ifeq ($(RAW_ARCH),x86_64)
  17 + ARCH ?= x86
  18 +
  19 + ifneq (, $(findstring m32,$(CFLAGS)))
  20 + RAW_ARCH := x86_32
22 21 endif
23 22 endif
24 23  
25   -ifeq (${IS_X86_64}, 1)
  24 +ARCH ?= $(RAW_ARCH)
  25 +
  26 +LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
  27 +ifeq ($(LP64), 1)
26 28 IS_64_BIT := 1
27   -else ifeq ($(ARCH),x86)
28   - IS_64_BIT := 0
29 29 else
30   - IS_64_BIT := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
  30 + IS_64_BIT := 0
31 31 endif