From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Horman Subject: [PATCH 0/X v5 01/14] makefiles: Fixed -share command line option error Date: Mon, 21 Apr 2014 10:59:26 -0400 Message-ID: <1398092379-7679-2-git-send-email-nhorman@tuxdriver.com> References: <1397585169-14537-1-git-send-email-nhorman@tuxdriver.com> <1398092379-7679-1-git-send-email-nhorman@tuxdriver.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1398092379-7679-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" The shared libraries built with the current makefile set produce static libraries rather than actual shared objects. This is due to several missing options that are required to correctly build shared objects using ld, as well as a mis-specified -share option (which should be -shared). Switching to the use of CC rather than LD and fixing the -shared option corrects these problems and builds the DSOs correctly. Signed-off-by: Neil Horman --- Change notes: v2) Added test for LINK_USING_CC to convert to link with gcc --- mk/rte.lib.mk | 14 ++++++++++++-- mk/rte.sharelib.mk | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk index f75ca92..fc8fd01 100644 --- a/mk/rte.lib.mk +++ b/mk/rte.lib.mk @@ -59,6 +59,18 @@ build: _postbuild exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1)))) +ifeq ($(LINK_USING_CC),1) +comma := , +CPU_LDFLAGS := $(addprefix -Wl$(comma),$(CPU_LDFLAGS)) +O_TO_S = $(CC) $(CPU_LDFLAGS) -Wl$(comma)-z$(comma)muldefs -shared $(OBJS-y) -o $(LIB) + +ifeq ($(RTE_BUILD_SHARED_LIB),y) +O_TO_C = $(CC) -z muldefs -shared $(OBJS-y) -o $(LIB_ONE) +endif +else +O_TO_S = $(LD) $(CPU_LDFLAGS) -z muldefs -shared $(OBJS-y) -o $(LIB) +endif + O_TO_A = $(AR) crus $(LIB) $(OBJS-y) O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #'# fix syntax highlight O_TO_A_DISP = $(if $(V),"$(O_TO_A_STR)"," AR $(@)") @@ -68,7 +80,6 @@ O_TO_A_DO = @set -e; \ $(O_TO_A) && \ echo $(O_TO_A_CMD) > $(call exe2cmd,$(@)) -O_TO_S = $(LD) $(CPU_LDFLAGS) -z muldefs -share $(OBJS-y) -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_DO = @set -e; \ @@ -84,7 +95,6 @@ O_TO_C_DO = @set -e; \ $(lib_dir) \ $(copy_obj) else -O_TO_C = $(LD) -z muldefs -share $(OBJS-y) -o $(LIB_ONE) O_TO_C_STR = $(subst ','\'',$(O_TO_C)) #'# fix syntax highlight O_TO_C_DISP = $(if $(V),"$(O_TO_C_STR)"," LD_C $(@)") O_TO_C_DO = @set -e; \ diff --git a/mk/rte.sharelib.mk b/mk/rte.sharelib.mk index 3967b51..429309f 100644 --- a/mk/rte.sharelib.mk +++ b/mk/rte.sharelib.mk @@ -45,7 +45,7 @@ sharelib: $(LIB_ONE) FORCE OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o) -O_TO_S = $(LD) $(CPU_LDFLAGS) -share $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE) +O_TO_S = $(LD) $(CPU_LDFLAGS) -shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE) 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)" -- 1.8.3.1