Skip to content

Commit 9f0c18a

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool: Fix CONFIG_STACK_VALIDATION=y warning for out-of-tree modules
When building a CONFIG_STACK_VALIDATION enabled kernel without the libelf devel package installed, the Makefile prints a warning: "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel" But when building an out-of-tree module, the warning doesn't show. Instead it tries to use objtool, and the build fails with: /bin/sh: ./tools/objtool/objtool: No such file or directory Make sure the warning and the disabling of objtool occur in all cases, by moving the CONFIG_STACK_VALIDATION checks outside the 'ifeq ($(KBUILD_EXTMOD),)' block in the Makefile. Tested-By: Marc MERLIN <marc@merlins.org> Suggested-by: Jessica Yu <jeyu@redhat.com> Reported-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Reviewed-by: Jessica Yu <jeyu@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michal Marek <mmarek@suse.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: 3b27a0c ("objtool: Detect and warn if libelf is missing and don't break the build") Link: http://lkml.kernel.org/r/b3088ae4a8698143d4851965793c61fec2135b1f.1487182864.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent c470abd commit 9f0c18a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,18 @@ mod_sign_cmd = true
908908
endif
909909
export mod_sign_cmd
910910

911+
ifdef CONFIG_STACK_VALIDATION
912+
has_libelf := $(call try-run,\
913+
echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
914+
ifeq ($(has_libelf),1)
915+
objtool_target := tools/objtool FORCE
916+
else
917+
$(warning "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel")
918+
SKIP_STACK_VALIDATION := 1
919+
export SKIP_STACK_VALIDATION
920+
endif
921+
endif
922+
911923

912924
ifeq ($(KBUILD_EXTMOD),)
913925
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -1035,18 +1047,6 @@ prepare0: archprepare gcc-plugins
10351047
# All the preparing..
10361048
prepare: prepare0 prepare-objtool
10371049

1038-
ifdef CONFIG_STACK_VALIDATION
1039-
has_libelf := $(call try-run,\
1040-
echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
1041-
ifeq ($(has_libelf),1)
1042-
objtool_target := tools/objtool FORCE
1043-
else
1044-
$(warning "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel")
1045-
SKIP_STACK_VALIDATION := 1
1046-
export SKIP_STACK_VALIDATION
1047-
endif
1048-
endif
1049-
10501050
PHONY += prepare-objtool
10511051
prepare-objtool: $(objtool_target)
10521052

0 commit comments

Comments
 (0)