[tip:perf/core] perf tools: Fix static build with newer toolchains
From: tip-bot for Jiri Olsa
Date: Tue Aug 29 2017 - 17:20:47 EST
Commit-ID: 6bd76b8fabe157233e498931c3f9298ee7128a28
Gitweb: http://git.kernel.org/tip/6bd76b8fabe157233e498931c3f9298ee7128a28
Author: Jiri Olsa <jolsa@xxxxxxxxxx>
AuthorDate: Fri, 25 Aug 2017 15:45:10 -0300
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Mon, 28 Aug 2017 11:05:09 -0300
perf tools: Fix static build with newer toolchains
We can't pass --dynamic-list list into static build anymore, because
compilers starts to scream about that. Fedora 26 started to fail build
with following error:
$ make LDFLAGS=-static
...
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/libc.a(strcmp.o
+)' can not be used when making an executable; recompile with -fPIE and relink with -pie
There's no sense for --dynamic-list in static build, because there's no
.dynsym table in static binary. Consequently the traceevent plugins have
never worked with static build, but it was quietly passed by.
To fix this in future I think we should add support to compile plugins
within the perf binary directly for static build.
Reported-and-Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-jeg6a7ff9j9hlqn8k4gllzvv@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/Makefile.perf | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 70ddc65..a700a07 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -279,7 +279,13 @@ LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
export LIBTRACEEVENT
LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-list
-LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
+
+#
+# The static build has no dynsym table, so this does not work for
+# static build. Looks like linker starts to scream about that now
+# (in Fedora 26) so we need to switch it off for static build.
+DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
+LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
LIBAPI = $(API_PATH)libapi.a
export LIBAPI