perf tool: Allow mixed static/dynamic linking
PATCH 1/1 perf tool: Allow mixed static/dynamic linking
Listen to a STATIC_LDFLAGS environment variable which will be appended to a -Wl,-Bstatic in each link step. Remove its contents from the regular link flags to avoid linking conflicts. Like that some of the libraries can be statically linked while others are linked dynamically.
Signed-off-by Ulf Hermann <[email protected]>
tools/perf/Makefile.perf +9 -4
@@ -29,7 +29,10 @@ include config/utilities.mak # # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. # -# Define LDFLAGS=-static to build a static binary. +# Define LDFLAGS=-static to build a completely static binary. +# +# Define STATIC_LDFLAGS to specify link flags that should follow a -Wl,-Bstatic. +# Those flags will be removed from the automatically determined, dynamic flags. # # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. #
@@ -558,7 +561,9 @@ ifdef ASCIIDOC8 export ASCIIDOC8 endif -LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group +LDFLAGS := $(filter-out $(STATIC_LDFLAGS), $(LDFLAGS)) +LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive\ + -Wl,--start-group $(filter-out $(STATIC_LDFLAGS) $(LDFLAGS), $(EXTLIBS)) -Wl,--end-group export INSTALL SHELL_PATH
@@ -582,8 +587,8 @@ $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS $(CFLAGS) -c $(filter %.c,$^) -o $@ $(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) - $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \ - $(BUILTIN_OBJS) $(LIBS) -o $@ + $(QUIET_LINK)$(CC) $(CFLAGS) $(OUTPUT)perf.o $(BUILTIN_OBJS) \ + $(LIBS) -Wl,-Bstatic $(STATIC_LDFLAGS) -Wl,-Bdynamic $(LDFLAGS) -o $@ $(GTK_OBJS): $(OUTPUT)%.o: %.c $(LIB_H) $(QUIET_CC)$(CC) -o $@ -c -fPIC $(CFLAGS) $(GTK_CFLAGS) $<
tools/perf/config/feature-checks/Makefile +41 -29
142 lines not on this page · raw message