Skip to content

Commit 60cbdf5

Browse files
jpoimboeacmel
authored andcommitted
tools build: Fix objtool build with ARCH=x86_64
The objtool build fails in a cross-compiled environment on a non-x86 host with "ARCH=x86_64": tools/objtool/objtool-in.o: In function `decode_instructions': tools/objtool/builtin-check.c:276: undefined reference to `arch_decode_instruction' We could override the ARCH environment variable and change it back to x86, similar to what the objtool Makefile was doing before; but it's tricky to override environment variables consistently. Instead, take a similar approach used by the Linux top-level Makefile and introduce a SRCARCH Makefile variable which evaluates to "x86" when ARCH is either "x86_64" or "x86". Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20160722191920.ej62fnspnqurbaa7@treble Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0cf6eb6 commit 60cbdf5

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

‎tools/objtool/Build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
objtool-y += arch/$(ARCH)/
1+
objtool-y += arch/$(SRCARCH)/
22
objtool-y += builtin-check.o
33
objtool-y += elf.o
44
objtool-y += special.o

‎tools/objtool/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | gre
3333
CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
3434

3535
AWK = awk
36-
export srctree OUTPUT CFLAGS ARCH AWK
36+
export srctree OUTPUT CFLAGS SRCARCH AWK
3737
include $(srctree)/tools/build/Makefile.include
3838

3939
$(OBJTOOL_IN): fixdep FORCE

‎tools/scripts/Makefile.arch‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,42 @@ HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
55
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
66
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
77
-e s/tile.*/tile/ )
8+
89
ifndef ARCH
910
ARCH := $(HOSTARCH)
1011
endif
1112

13+
SRCARCH := $(ARCH)
14+
15+
# Additional ARCH settings for x86
16+
ifeq ($(ARCH),i386)
17+
SRCARCH := x86
18+
endif
19+
ifeq ($(ARCH),x86_64)
20+
SRCARCH := x86
21+
endif
22+
23+
# Additional ARCH settings for sparc
24+
ifeq ($(ARCH),sparc32)
25+
SRCARCH := sparc
26+
endif
27+
ifeq ($(ARCH),sparc64)
28+
SRCARCH := sparc
29+
endif
30+
31+
# Additional ARCH settings for sh
32+
ifeq ($(ARCH),sh64)
33+
SRCARCH := sh
34+
endif
35+
36+
# Additional ARCH settings for tile
37+
ifeq ($(ARCH),tilepro)
38+
SRCARCH := tile
39+
endif
40+
ifeq ($(ARCH),tilegx)
41+
SRCARCH := tile
42+
endif
43+
1244
LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
1345
ifeq ($(LP64), 1)
1446
IS_64_BIT := 1

0 commit comments

Comments
 (0)