diff options
authorSteven Rostedt <>2016-04-20 11:32:35 -0400
committerIngo Molnar <>2016-04-22 09:00:57 +0200
commitc2bb9e32e2315971a8535fee77335c04a739d71d (patch)
parentb1547d3101e74e809b9790174b27f1080747b009 (diff)
objtool: Fix Makefile to properly see if libelf is supported
When doing a make allmodconfig, I hit the following compile error: In file included from builtin-check.c:32:0: elf.h:22:18: fatal error: gelf.h: No such file or directory compilation terminated. ... Digging into it, it appears that the $(shell ..) command in the Makefile does not give the proper result when it fails to find -lelf, and continues to compile objtool. Instead, use the "try-run" makefile macro to perform the test. This gives a proper result for both cases. Signed-off-by: Steven Rostedt <> Acked-by: Josh Poimboeuf <> Cc: Andrew Morton <> Cc: Andy Lutomirski <> Cc: Arnaldo Carvalho de Melo <> Cc: Bernd Petrovitsch <> Cc: Borislav Petkov <> Cc: Chris J Arges <> Cc: Jiri Slaby <> Cc: Linus Torvalds <> Cc: Michal Marek <> Cc: Namhyung Kim <> Cc: Pedro Alves <> Cc: Peter Zijlstra <> Cc: Thomas Gleixner <> Cc: Fixes: 442f04c34a1a4 ("objtool: Add tool to perform compile-time stack metadata validation") Link: Signed-off-by: Ingo Molnar <>
1 files changed, 2 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 1d0aef03eae7..70ca38ef9f4b 100644
--- a/Makefile
+++ b/Makefile
@@ -1008,7 +1008,8 @@ prepare0: archprepare FORCE
prepare: prepare0 prepare-objtool
- has_libelf := $(shell echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf - &> /dev/null && echo 1 || echo 0)
+ has_libelf := $(call try-run,\
+ echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
ifeq ($(has_libelf),1)
objtool_target := tools/objtool FORCE