[dpdk-dev,v2,4/4] Link apps/DSOs against EXECENV_LDLIBS with --as-needed
Commit Message
Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
mk/rte.app.mk | 4 ++--
mk/rte.lib.mk | 8 +++++++-
mk/rte.sharelib.mk | 7 ++++++-
3 files changed, 15 insertions(+), 4 deletions(-)
Comments
Please could you explain why patch is needed?
On Wed, Oct 08, 2014 at 05:38:52PM +0200, Thomas Monjalon wrote:
> Please could you explain why patch is needed?
>
Hi Thomas,
Basically this patch just adds missing dependencies to DPDK DSOs. so the
DL knows about them.
As an example, if we were to build an application against DPDK without
adding the libs defined in EXECENV_LDLIBS:
-- pre-patch:
LD test
test_red.o: In function `ovfl_test1':
test_red.c:(.text+0x1ac6): undefined reference to `log'
test_red.c:(.text+0x1ad3): undefined reference to `ceil'
test_red.o: In function `perf2_test':
test_red.c:(.text+0x2314): undefined reference to `pow'
test_red.o: In function `func_test3':
test_red.c:(.text+0x28d7): undefined reference to `pow'
test_red.o: In function `func_test6':
test_red.c:(.text+0x324c): undefined reference to `pow'
dpdk/x86_64-native-linuxapp-gcc/lib/libintel_dpdk.so: undefined reference to `dlopen'
dpdk/x86_64-native-linuxapp-gcc/lib/libintel_dpdk.so: undefined reference to `log2'
dpdk/x86_64-native-linuxapp-gcc/lib/libintel_dpdk.so: undefined reference to `dlerror'
dpdk/x86_64-native-linuxapp-gcc/lib/libintel_dpdk.so: undefined reference to `round'
-- post-patch:
LD test
/usr/bin/ld: test_red.o: undefined reference to symbol 'log@@GLIBC_2.2.5'
/usr/bin/ld: note: 'log@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
Thanks,
Sergio
> --
> Thomas
@@ -62,9 +62,9 @@ ifeq ($(NO_AUTOLIBS),)
LDLIBS += --whole-archive
LDLIBS += -l$(RTE_LIBNAME)
LDLIBS += --no-whole-archive
-LDLIBS += --start-group
+LDLIBS += --as-needed
LDLIBS += $(EXECENV_LDLIBS)
-LDLIBS += --end-group
+LDLIBS += --no-as-needed
endif # ifeq ($(NO_AUTOLIBS),)
@@ -59,14 +59,20 @@ build: _postbuild
exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
+O_TO_S_LDLIBS := --as-needed
+O_TO_S_LDLIBS += $(EXECENV_LDLIBS)
+O_TO_S_LDLIBS += --no-as-needed
+
ifeq ($(LINK_USING_CC),1)
# Override the definition of LD here, since we're linking with CC
LD := $(CC)
LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+O_TO_S_LDLIBS := $(call linkerprefix,$(O_TO_S_LDLIBS))
endif
-O_TO_S = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -shared $(OBJS-y) -o $(LIB)
+O_TO_S = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -shared $(OBJS-y) \
+ $(O_TO_S_LDLIBS) -o $(LIB)
O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #') # fix syntax highlight
O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)"," LD $(@)")
O_TO_S_CMD = "cmd_$@ = $(O_TO_S_STR)"
@@ -40,11 +40,16 @@ else
LIB_ONE := lib$(RTE_LIBNAME).a
endif
+O_TO_L_LDLIBS := --as-needed
+O_TO_L_LDLIBS += $(EXECENV_LDLIBS)
+O_TO_L_LDLIBS += --no-as-needed
+
ifeq ($(LINK_USING_CC),1)
# Override the definition of LD here, since we're linking with CC
LD := $(CC)
LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+O_TO_L_LDLIBS := $(call linkerprefix,$(O_TO_L_LDLIBS))
endif
.PHONY:sharelib
@@ -54,7 +59,7 @@ OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
ifeq ($(RTE_BUILD_SHARED_LIB),y)
O_TO_L = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -shared $(OBJS)\
- -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
+ $(O_TO_L_LDLIBS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
L_DISP=LD
else
O_TO_L = $(AR) crus $(RTE_OUTPUT)/lib/$(LIB_ONE) $(OBJS)