On Sun, 2010-08-22 at 01:43 -0500, Tom Zanussi wrote:
Looking into it a bit further, both ExtUtils::Embed -e ldopts and
python-config --ldflags put the libs at the end, so we should be able to
parse the output of those and take only the parts we need for each
component. How about something like this instead?
Tom
---
[PATCH] Refresh of Ozan Çağlayan's patch: perf tools: Fix linking errors
with --as-needed flag:
External shared libraries should never be appended to the LDFLAGS as
this messes the linking order. As EXTLIBS collects those libraries,
it seems that perl and python libraries should also be appended
to EXTLIBS.
Also fix the broken linking order.
v2: add commands to separate out LDFLAGS and libs from both Perl and
Python LDOPTS (Tom Zanussi)
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
---
tools/perf/Makefile | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 26a3f2e..59f5b10 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -589,13 +589,16 @@ ifdef NO_LIBPERL
BASIC_CFLAGS += -DNO_LIBPERL
else
PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
+ PERL_EMBED_LDFLAGS = $(shell echo $(PERL_EMBED_LDOPTS) | sed 's/-l.*//' )
+ PERL_EMBED_LIBADD = $(shell echo $(PERL_EMBED_LDOPTS) | grep -o '\-l.*' )
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
BASIC_CFLAGS += -DNO_LIBPERL
else
- ALL_LDFLAGS += $(PERL_EMBED_LDOPTS)
+ ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
+ EXTLIBS += $(PERL_EMBED_LIBADD)
LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
endif
@@ -605,12 +608,15 @@ ifdef NO_LIBPYTHON
BASIC_CFLAGS += -DNO_LIBPYTHON
else
PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null`
+ PYTHON_EMBED_LDFLAGS = $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/-l.*//' )
+ PYTHON_EMBED_LIBADD = $(shell echo $(PYTHON_EMBED_LDOPTS) | grep -o '\-l.*' )
PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
BASIC_CFLAGS += -DNO_LIBPYTHON
else
- ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS)
+ ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
+ EXTLIBS += $(PYTHON_EMBED_LIBADD)
LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
endif
@@ -919,8 +925,8 @@ $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
$(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
$(OUTPUT)perf$X: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
- $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(OUTPUT)perf.o \
- $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
+ $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
+ $(BUILTIN_OBJS) $(LIBS) -o $@
$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
--
1.6.4.GIT
--