diff options
author | Josh Poimboeuf <jpoimboe@redhat.com> | 2016-03-02 19:39:37 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-03-03 10:13:00 -0500 |
commit | c1d45c3abd49b5bf9447e435099c1b000dcde752 (patch) | |
tree | 8b486173e97100a56753997b6e209450e8c7e3de /tools | |
parent | 19072f23d1d785c093b7f81cb1fb161e7a13ecc0 (diff) |
objtool: Support CROSS_COMPILE
When building with CONFIG_STACK_VALIDATION on a ppc64le host with an x86
cross-compiler, Stephen Rothwell saw the following objtool build errors:
DESCEND objtool
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/builtin-check.o
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/special.o
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/elf.o
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/objtool.o
MKDIR /home/sfr/next/x86_64_allmodconfig/tools/objtool/arch/x86/insn/
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/libstring.o
elf.c:22:23: fatal error: sys/types.h: No such file or directory
compilation terminated.
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/exec-cmd.o
CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/help.o
builtin-check.c:28:20: fatal error: string.h: No such file or directory
compilation terminated.
objtool.c:28:19: fatal error: stdio.h: No such file or directory
compilation terminated.
It fails to build because it tries to compile objtool with the
cross-compiler instead of the host compiler.
Ensure that it always uses the host compiler by ignoring CROSS_COMPILE.
In order to do that properly, the libsubcmd.a library needs to be built
in tools/objtool/ rather than tools/lib/subcmd/. The latter directory
contains the cross-compiled version which is needed for perf and
possibly other tools.
Note that cross-compiling for x86 on a _big_ endian system would result
in a bunch of false positive objtool warnings during the kernel build
because it isn't endian-aware. But that's generally a rare edge case
and there haven't been any reports of anybody needing that.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/55b63eefc347f1bb28573f972d8d1adbf1f1c31d.1456962210.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/subcmd/Makefile | 6 | ||||
-rw-r--r-- | tools/objtool/Makefile | 17 |
2 files changed, 14 insertions, 9 deletions
diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile index 629cf8c14e68..1faecb82ad42 100644 --- a/tools/lib/subcmd/Makefile +++ b/tools/lib/subcmd/Makefile | |||
@@ -8,8 +8,10 @@ srctree := $(patsubst %/,%,$(dir $(srctree))) | |||
8 | #$(info Determined 'srctree' to be $(srctree)) | 8 | #$(info Determined 'srctree' to be $(srctree)) |
9 | endif | 9 | endif |
10 | 10 | ||
11 | CC = $(CROSS_COMPILE)gcc | 11 | CC ?= $(CROSS_COMPILE)gcc |
12 | AR = $(CROSS_COMPILE)ar | 12 | LD ?= $(CROSS_COMPILE)ld |
13 | AR ?= $(CROSS_COMPILE)ar | ||
14 | |||
13 | RM = rm -f | 15 | RM = rm -f |
14 | 16 | ||
15 | MAKEFLAGS += --no-print-directory | 17 | MAKEFLAGS += --no-print-directory |
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index c4f0713a1eb7..e4a6bd528bf0 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile | |||
@@ -7,13 +7,19 @@ ARCH := x86 | |||
7 | endif | 7 | endif |
8 | endif | 8 | endif |
9 | 9 | ||
10 | # always use the host compiler | ||
11 | CC = gcc | ||
12 | LD = ld | ||
13 | AR = ar | ||
14 | |||
10 | ifeq ($(srctree),) | 15 | ifeq ($(srctree),) |
11 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) | 16 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) |
12 | srctree := $(patsubst %/,%,$(dir $(srctree))) | 17 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
13 | endif | 18 | endif |
14 | 19 | ||
15 | SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ | 20 | SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ |
16 | LIBSUBCMD = $(if $(OUTPUT),$(OUTPUT),$(SUBCMD_SRCDIR))libsubcmd.a | 21 | LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(PWD)/) |
22 | LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a | ||
17 | 23 | ||
18 | OBJTOOL := $(OUTPUT)objtool | 24 | OBJTOOL := $(OUTPUT)objtool |
19 | OBJTOOL_IN := $(OBJTOOL)-in.o | 25 | OBJTOOL_IN := $(OBJTOOL)-in.o |
@@ -45,12 +51,9 @@ $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) | |||
45 | 51 | ||
46 | 52 | ||
47 | $(LIBSUBCMD): fixdep FORCE | 53 | $(LIBSUBCMD): fixdep FORCE |
48 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) | 54 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) |
49 | |||
50 | $(LIBSUBCMD)-clean: | ||
51 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) clean > /dev/null | ||
52 | 55 | ||
53 | clean: $(LIBSUBCMD)-clean | 56 | clean: |
54 | $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) | 57 | $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) |
55 | $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete | 58 | $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete |
56 | $(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c $(OUTPUT)fixdep | 59 | $(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c $(OUTPUT)fixdep |