mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] objtool: Fix Makefile to properly see if libelf is supported
@ 2016-04-20 15:32 Steven Rostedt
  2016-04-21  4:27 ` Josh Poimboeuf
  2016-04-22  9:45 ` [tip:core/urgent] " tip-bot for Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-04-20 15:32 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel,
	live-patching, Michal Marek, Peter Zijlstra, Andy Lutomirski,
	Borislav Petkov, Linus Torvalds, Andi Kleen, Pedro Alves,
	Namhyung Kim, Bernd Petrovitsch, Chris J Arges, Andrew Morton,
	Jiri Slaby, Arnaldo Carvalho de Melo

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.
In file included from special.h:22:0,
                 from special.c:26:
elf.h:22:18: fatal error: gelf.h: No such file or directory
compilation terminated.
In file included from elf.c:30:0:
elf.h:22:18: fatal error: gelf.h: No such file or directory
compilation terminated.
mv: cannot stat 'tools/objtool/.elf.o.tmp': No such file or directory
tools/build/Makefile.build:77: recipe for target 'tools/objtool/elf.o' failed
make[4]: *** [tools/objtool/elf.o] Error 1
make[4]: *** Waiting for unfinished jobs....

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.

Fixes: 442f04c34a1a4 ("objtool: Add tool to perform compile-time stack metadata validation")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---

diff --git a/Makefile b/Makefile
index 873411873c03..012b7dd3ed24 100644
--- a/Makefile
+++ b/Makefile
@@ -1008,7 +1008,8 @@ prepare0: archprepare FORCE
 prepare: prepare0 prepare-objtool
 
 ifdef CONFIG_STACK_VALIDATION
-  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
   else

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-22  9:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-20 15:32 [PATCH] objtool: Fix Makefile to properly see if libelf is supported Steven Rostedt
2016-04-21  4:27 ` Josh Poimboeuf
2016-04-22  9:45 ` [tip:core/urgent] " tip-bot for Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome