Skip to contentSkip to conversation

mk: link combined lib using CC

PATCH Superseded Sergio Gonzalez Monroy 3 participants 17 messages Oct 23, 2014 – Dec 17, 2014 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mk: link combined lib using CC

Building combined shared libs fails if we set EXTRA_CFLAGS=-O0.

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO /usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
mk/rte.lib.mk +0 -1
index d83e808..a6abd6d 100644
@@ -63,7 +63,6 @@ ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
 LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
-CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
 endif
 
 O_TO_A = $(AR) crus $(LIB) $(OBJS-y)
mk/rte.sharelib.mk +11 -1
index c0a811a..1fac0ad 100644
@@ -29,6 +29,8 @@
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+include $(RTE_SDK)/mk/internal/rte.build-pre.mk
+
 # VPATH contains at least SRCDIR
 VPATH += $(SRCDIR)
 
@@ -45,7 +47,15 @@ sharelib: $(LIB_ONE) FORCE
 
 OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) -shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
+ifeq ($(LINK_USING_CC),1)
+# Override the definition of LD here, since we're linking with CC
+LD := $(CC) $(CPU_CFLAGS)
+LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
+CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+endif
+
+O_TO_S = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -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)"
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1414078550-692-1-git-send-email-sergio.gonzalez.monroy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 30 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Sergio Gonzalez Monroy
Sent: Thursday, October 23, 2014 4:36 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH] mk: link combined lib using CC

Building combined shared libs fails if we set EXTRA_CFLAGS=-O0.

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO /usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

Signed-off-by: Sergio Gonzalez Monroy <[email protected]>

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
mk/rte.lib.mk +0 -0
index d83e808..a6abd6d 100644

mk/rte.lib.mk ifeq ($(LINK_USING_CC),1) · line 66

Quoted 5 lines
mk/rte.lib.mk +0 -1
@@ -63,7 +63,6 @@ ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
 LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
-CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
 endif

Patch does not apply cleanly, due to context mismatch. Could you send a V2, based on the current branch status?

Plus, should we include compilation errors in commits?
They are quite useful to identify the problem that
the patch is solving, but not sure if this should be shown in the git log.

Thanks,
Pablo

A message that is not in the archive (sent off-list or not yet received): E115CCD9D858EF4F90C690B0DCB4D89722637456-kPTMFJFq+rEMvF1YICWikbfspsVTdybXVpNB7YpNyf8@public.gmane.org

#4 lore raw
Quoted 16 lines · Pablo
Quoted 16 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Sergio Gonzalez Monroy
Sent: Thursday, October 23, 2014 4:36 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH] mk: link combined lib using CC

Building combined shared libs fails if we set EXTRA_CFLAGS=-O0.

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO /usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Quoted 9 lines
Quoted 4 lines

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

Signed-off-by: Sergio Gonzalez Monroy <[email protected]>

Plus, should we include compilation errors in commits?
They are quite useful to identify the problem that
the patch is solving, but not sure if this should be shown in the git log.

I was wondering about it myself. I think it is useful info but maybe t is more appropiate to have it as a comment or cover letter just on the mailing list. I don't have a strong preference for including it, maybe someone else has an opinion about this?

Thanks,
Sergio

Quoted 3 lines

Thanks,
Pablo

A message that is not in the archive (sent off-list or not yet received): 20141028145123.GA24266-IWE99D/oH1/[email protected]

#6 lore raw

2014-10-28 14:51, Sergio Gonzalez Monroy:

Quoted 12 lines · Pablo
Quoted 11 lines
Quoted 10 lines

Building combined shared libs fails if we set EXTRA_CFLAGS=-O0.

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO /usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

Quoted 8 lines
Quoted 4 lines

Plus, should we include compilation errors in commits?
They are quite useful to identify the problem that
the patch is solving, but not sure if this should be shown in the git log.

I was wondering about it myself. I think it is useful info but maybe t is more appropiate to have it as a comment or cover letter just on the mailing list. I don't have a strong preference for including it, maybe someone else has an opinion about this?

We are not limited in characters in the commit log. So every useful information (like error output) is more than welcome.
The only thing which needs to be shorter than a twitter post, is the title. Because short and clear titles help to scroll commits.

That said, don't put things which have no interest at all. Here I'd put only this:
ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Signature · 1 line
Thomas
#7 lore raw
Quoted 22 lines · Thomas Monjalon

2014-10-28 14:51, Sergio Gonzalez Monroy:

Quoted 12 lines · Pablo
Quoted 11 lines
Quoted 10 lines

Building combined shared libs fails if we set EXTRA_CFLAGS=-O0.

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO /usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

Quoted 8 lines
Quoted 4 lines

Plus, should we include compilation errors in commits?
They are quite useful to identify the problem that
the patch is solving, but not sure if this should be shown in the git log.

I was wondering about it myself. I think it is useful info but maybe t is more appropiate to have it as a comment or cover letter just on the mailing list. I don't have a strong preference for including it, maybe someone else has an opinion about this?

Quoted 8 lines

We are not limited in characters in the commit log. So every useful information (like error output) is more than welcome.
The only thing which needs to be shorter than a twitter post, is the title. Because short and clear titles help to scroll commits.

That said, don't put things which have no interest at all. Here I'd put only this:
ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Thanks for the tips!

I'll send a v2 with changes.

Sergio

Quoted 2 lines
Signature · 1 line
Thomas
#8 lore raw

PATCH v2 1/1 mk: link combined shared lib using CC

In reply to a message not in the archive

If we set EXTRA_CFLAGS=-O0, build fails with following error:

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
mk/rte.lib.mk +0 -1
index d83e808..a6abd6d 100644
@@ -63,7 +63,6 @@ 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))
 endif
 
 O_TO_A = $(AR) crus $(LIB) $(OBJS-y)
mk/rte.sharelib.mk +11 -1
index c0a811a..1fac0ad 100644
@@ -29,6 +29,8 @@
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+include $(RTE_SDK)/mk/internal/rte.build-pre.mk
+
 # VPATH contains at least SRCDIR
 VPATH += $(SRCDIR)
 
@@ -45,7 +47,15 @@ sharelib: $(LIB_ONE) FORCE
 
 OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) -shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
+ifeq ($(LINK_USING_CC),1)
+# Override the definition of LD here, since we're linking with CC
+LD := $(CC) $(CPU_CFLAGS)
+LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
+CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+endif
+
+O_TO_S = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -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)"
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1414511329-3948-1-git-send-email-sergio.gonzalez.monroy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#10 lore raw

Re: [PATCH v2] mk: link combined shared lib using CC

Quoted 11 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, October 28, 2014 3:49 PM
To: [email protected]
Cc: [email protected]; De Lara Guarch, Pablo
Subject: [PATCH v2] mk: link combined shared lib using CC

If we set EXTRA_CFLAGS=-O0, build fails with following error:

Quoted 7 lines

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

Signed-off-by: Sergio Gonzalez Monroy <[email protected]>

#11 lore raw

Re: [PATCH v2] mk: link combined shared lib using CC

In reply to a message not in the archive

2014-10-28 15:48, Sergio Gonzalez Monroy:

Quoted 10 lines

If we set EXTRA_CFLAGS=-O0, build fails with following error:

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-

[...]

mk/rte.lib.mk ifeq ($(LINK_USING_CC),1) · line 66

Quoted 8 lines
mk/rte.lib.mk +0 -1
@@ -63,7 +63,6 @@ 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))
 endif

Why are you removing this line?

Quoted 2 lines
mk/rte.sharelib.mk +0 -0

[...]

#12 lore raw

Re: [PATCH v2] mk: link combined shared lib using CC

2014-12-16 19:48, Thomas Monjalon:

Quoted 12 lines

2014-10-28 15:48, Sergio Gonzalez Monroy:

Quoted 10 lines

If we set EXTRA_CFLAGS=-O0, build fails with following error:

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-

[...]

Quoted 10 lines

mk/rte.lib.mk ifeq ($(LINK_USING_CC),1) · line 66

Quoted 8 lines
mk/rte.lib.mk +0 -1
@@ -63,7 +63,6 @@ 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))
 endif

Why are you removing this line?

If it's really needed, it could be another patch.

Quoted 3 lines
Quoted 2 lines
mk/rte.sharelib.mk +0 -0

[...]

Applied without the change to rte.lib.mk.

Thanks

Signature · 1 line
Thomas
#13 lore raw

Re: [PATCH v2] mk: link combined shared lib using CC

Quoted 27 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, December 16, 2014 11:43 PM

2014-12-16 19:48, Thomas Monjalon:

Quoted 22 lines

2014-10-28 15:48, Sergio Gonzalez Monroy:

Quoted 12 lines

If we set EXTRA_CFLAGS=-O0, build fails with following error:

/usr/bin/ld: test: hidden symbol `mknod' in /usr/lib64/libc_nonshared.a(mknod.oS) is referenced by DSO

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

Signed-off-by: Sergio Gonzalez Monroy <[email protected]>

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-

[...]

Quoted 6 lines
mk/rte.lib.mk +0 -0
@@ -63,7 +63,6 @@ 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)) endif

Why are you removing this line?

Hi Thomas,

Basically the problem is when CPU_LDFLAGS has a value, which in the currently only happens if we set CPU_LDFLAGS in the command line or build i686 (setting CPU_LDFLAGS=-melf_i386). In those cases, given the way the makefiles are being included, CPU_LDFLAGS is being 'linkerprefixed' twice, resulting in build error.
Removing that line avoided the second linker prefix of the CPU_LDFLAGS (note that we reset the original var instead of using a different var name).

There probably is a better way but I could not see an straightforward fix for it.
I planned to improve the current build system (already sent an RFC) and was waiting until 1.8 release to resume the work on it.

Thanks,
Sergio

Quoted 13 lines

If it's really needed, it could be another patch.

Quoted 3 lines
Quoted 2 lines
mk/rte.sharelib.mk +0 -0

[...]

Applied without the change to rte.lib.mk.

Thanks
--
Thomas

A message that is not in the archive (sent off-list or not yet received): 91383E96CE459D47BCE92EFBF5CE73B004F0B593-kPTMFJFq+rFwl47ZQwxUxrfspsVTdybXVpNB7YpNyf8@public.gmane.org

#15 lore raw

Re: [PATCH v2] mk: link combined shared lib using CC

2014-12-17 10:41, Gonzalez Monroy, Sergio:

Quoted 21 lines
Quoted 21 lines

From: Thomas Monjalon [mailto:[email protected]] 2014-12-16 19:48, Thomas Monjalon:

Quoted 18 lines

2014-10-28 15:48, Sergio Gonzalez Monroy:

Quoted 6 lines

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-

[...]

mk/rte.lib.mk ifeq ($(LINK_USING_CC),1) · line 66

Quoted 8 lines
mk/rte.lib.mk +0 -1
@@ -63,7 +63,6 @@ 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))
 endif

Why are you removing this line?

Quoted 6 lines

Hi Thomas,

Basically the problem is when CPU_LDFLAGS has a value, which in the currently only happens if we set CPU_LDFLAGS in the command line or build i686 (setting CPU_LDFLAGS=-melf_i386).
In those cases, given the way the makefiles are being included,

These 2 files don't include each other. rte.sharelib.mk is included only in lib/Makefile and rte.lib.mk is included in each lib Makefile.

I think the problem is not about how the files are included but how this variable is exported.
CPU_LDFLAGS is modified in lib/Makefile via rte.sharelib.mk, then exported (see mk/arch/*/rte.vars.mk) then modified again in libs via rte.lib.mk.

Quoted 5 lines

CPU_LDFLAGS is being 'linkerprefixed' twice, resulting in build error. Removing that line avoided the second linker prefix of the CPU_LDFLAGS (note that we reset the original var instead of using a different var name).

There probably is a better way but I could not see an straightforward fix for it.

I suggest 2 possible fixes:
- do not export this variable (why is it exported?)
- or do not override the variable, i.e. use a different variable for prefixing

Quoted 2 lines

I planned to improve the current build system (already sent an RFC) and was waiting until 1.8 release to resume the work on it.

I agree we should work on improvements after 1.8.

Quoted 1 line
Quoted 1 line

If it's really needed, it could be another patch.

[...]

Quoted 2 lines
Quoted 2 lines

Applied without the change to rte.lib.mk.

It definitely deserves another patch with a proper fix.

Signature · 1 line
Thomas
#16 lore raw

Re: [PATCH v2] mk: link combined shared lib using CC

2014-12-17 15:01, Thomas Monjalon:

Quoted 43 lines

2014-12-17 10:41, Gonzalez Monroy, Sergio:

Quoted 21 lines
Quoted 21 lines

From: Thomas Monjalon [mailto:[email protected]] 2014-12-16 19:48, Thomas Monjalon:

Quoted 18 lines

2014-10-28 15:48, Sergio Gonzalez Monroy:

Quoted 6 lines

Fix: link combined shared lib using CC if LINK_USING_CC is enabled.

---
 mk/rte.lib.mk      |  1 -
 mk/rte.sharelib.mk | 12 +++++++++++-

[...]

mk/rte.lib.mk ifeq ($(LINK_USING_CC),1) · line 66

Quoted 8 lines
mk/rte.lib.mk +0 -1
@@ -63,7 +63,6 @@ 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))
 endif

Why are you removing this line?

Quoted 6 lines

Hi Thomas,

Basically the problem is when CPU_LDFLAGS has a value, which in the currently only happens if we set CPU_LDFLAGS in the command line or build i686 (setting CPU_LDFLAGS=-melf_i386).
In those cases, given the way the makefiles are being included,

These 2 files don't include each other. rte.sharelib.mk is included only in lib/Makefile and rte.lib.mk is included in each lib Makefile.

I think the problem is not about how the files are included but how this variable is exported.
CPU_LDFLAGS is modified in lib/Makefile via rte.sharelib.mk, then exported (see mk/arch/*/rte.vars.mk) then modified again in libs via rte.lib.mk.

Quoted 4 lines

CPU_LDFLAGS is being 'linkerprefixed' twice, resulting in build error. Removing that line avoided the second linker prefix of the CPU_LDFLAGS (note that we reset the original var instead of using a different var name).

Quoted 5 lines
Quoted 1 line

There probably is a better way but I could not see an straightforward fix for it.

I suggest 2 possible fixes:
- do not export this variable (why is it exported?)
- or do not override the variable, i.e. use a different variable for prefixing

I'm preparing a patch with the second approach.
It raised other problems like error when linking examples with combined library. Patchset to come.

Quoted 11 lines
Quoted 2 lines

I planned to improve the current build system (already sent an RFC) and was waiting until 1.8 release to resume the work on it.

I agree we should work on improvements after 1.8.

Quoted 1 line
Quoted 1 line

If it's really needed, it could be another patch.

[...]

Quoted 2 lines
Quoted 2 lines

Applied without the change to rte.lib.mk.

It definitely deserves another patch with a proper fix.

Signature · 1 line
Thomas
#17 lore raw

cover mk: fix link options

When trying to fix the use of combined library, some bugs have been raised. This patchset fix and clean some link options.

Thomas Monjalon (3):
mk: fix link examples to combined library
mk: forbid multiple definitions
mk: fix link with CC

 mk/rte.app.mk      | 5 ++---
 mk/rte.lib.mk      | 9 +++++----
 mk/rte.shared.mk   | 6 ++----
 mk/rte.sharelib.mk | 9 +++++----
 mk/rte.vars.mk     | 9 +++++----
 5 files changed, 19 insertions(+), 19 deletions(-)
Signature · 1 line
2.1.3

A message that is not in the archive (sent off-list or not yet received): 1418853558-2445-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org

#19 lore raw

PATCH 1/3 mk: fix link examples to combined library

RTE_LIBNAME was defined only if BUILDING_RTE_SDK.
So external applications like examples were trying to link with -l without any library name.

This bug appeared after fixing link to combined library (removing link to separate libraries).

---
 mk/rte.vars.mk | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
mk/rte.vars.mk +5 -4
index 1e874ee..d5b36be 100644
@@ -71,10 +71,11 @@ ifneq ($(BUILDING_RTE_SDK),)
   ifeq ($(RTE_BUILD_COMBINE_LIBS),)
     RTE_BUILD_COMBINE_LIBS := n
   endif
-  RTE_LIBNAME := $(CONFIG_RTE_LIBNAME:"%"=%)
-  ifeq ($(RTE_LIBNAME),)
-    RTE_LIBNAME := intel_dpdk
-  endif
+endif
+
+RTE_LIBNAME := $(CONFIG_RTE_LIBNAME:"%"=%)
+ifeq ($(RTE_LIBNAME),)
+RTE_LIBNAME := intel_dpdk
 endif
 
 # RTE_TARGET is deducted from config when we are building the SDK.
Signature · 1 line
2.1.3
#20 lore raw

PATCH 2/3 mk: forbid multiple definitions

In reply to a message not in the archive

The option "-z muldefs" was set only if not using ld directly. By the way, this option seems to be a useless hack introduced with shared and combined libraries support (e25e4d7ef16b8aa84de). The clean approach is to remove it.

---
 mk/rte.lib.mk      | 5 ++---
 mk/rte.sharelib.mk | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
mk/rte.lib.mk +2 -3
index d83e808..a67c129 100644
@@ -62,7 +62,6 @@ exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
 ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
-LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
 CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
 endif
 
@@ -75,7 +74,7 @@ O_TO_A_DO = @set -e; \
 	$(O_TO_A) && \
 	echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -shared $(OBJS-y) -o $(LIB)
+O_TO_S = $(LD) $(CPU_LDFLAGS) -shared $(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; \
@@ -91,7 +90,7 @@ O_TO_C_DO = @set -e; \
 	$(lib_dir) \
 	$(copy_obj)
 else
-O_TO_C = $(LD) $(LD_MULDEFS) -shared $(OBJS-y) -o $(LIB_ONE)
+O_TO_C = $(LD) -shared $(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; \
mk/rte.sharelib.mk +1 -2
index d0ec12a..d0cc7e3 100644
@@ -50,11 +50,10 @@ OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
 ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
-LD_MULDEFS := $(call linkerprefix,-z$(comma)muldefs)
 CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
 endif
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) $(LD_MULDEFS) -shared $(OBJS) \
+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 $(@)")
Signature · 1 line
2.1.3
#21 lore raw

PATCH 3/3 mk: fix link with CC

In reply to a message not in the archive

It appeared in commit 21cdc2e77a4ca999 ("fix 32-bit link with gcc") that linker options must be prefixed by -Wl, when using CC.
So CPU_LDFLAGS is prefixed in rte.lib.mk.
Then commit 815cfb7925bb6de ("fix link of combined shared library using CC") introduced another prefixing of CPU_LDFLAGS in rte.sharelib.mk, included in lib/Makefile.
Because CPU_LDFLAGS is an exported variable, the prefixing is done twice. Initial patch of commit 815cfb7925bb6de had a workaround but it hasn't been applied in favor of this proper fix.

Now variables are not overriden when prefixing.

---
 mk/rte.app.mk      | 5 ++---
 mk/rte.lib.mk      | 6 ++++--
 mk/rte.shared.mk   | 6 ++----
 mk/rte.sharelib.mk | 8 +++++---
 4 files changed, 13 insertions(+), 12 deletions(-)
mk/rte.app.mk +2 -3
index 3c35985..e1a0dbf 100644
@@ -256,11 +256,10 @@ LDLIBS += -l$(RTE_LIBNAME)
 endif
 
 ifeq ($(LINK_USING_CC),1)
-LDLIBS := $(call linkerprefix,$(LDLIBS))
-LDFLAGS := $(call linkerprefix,$(LDFLAGS))
 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
-	-Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
+	-Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(call linkerprefix,$(LDFLAGS)) \
+	$(EXTRA_LDFLAGS) $(call linkerprefix,$(LDLIBS))
 else
 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
 	-Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
mk/rte.lib.mk +4 -2
index a67c129..81bf8e1 100644
@@ -62,7 +62,9 @@ exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
 ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
-CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+_CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+else
+_CPU_LDFLAGS := $(CPU_LDFLAGS)
 endif
 
 O_TO_A = $(AR) crus $(LIB) $(OBJS-y)
@@ -74,7 +76,7 @@ O_TO_A_DO = @set -e; \
 	$(O_TO_A) && \
 	echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) -shared $(OBJS-y) -o $(LIB)
+O_TO_S = $(LD) $(_CPU_LDFLAGS) -shared $(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; \
mk/rte.shared.mk +2 -4
index 42feee7..fc6b0b4 100644
@@ -58,11 +58,9 @@ build: _postbuild
 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
 
 ifeq ($(LINK_USING_CC),1)
-LDLIBS := $(call linkerprefix,$(LDLIBS))
-LDFLAGS := $(call linkerprefix,$(LDFLAGS))
 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
-O_TO_SO = $(CC) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
-	-shared -o $@ $(OBJS-y) $(LDLIBS)
+O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
+	-shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))
 else
 O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
 	-shared -o $@ $(OBJS-y) $(LDLIBS)
mk/rte.sharelib.mk +5 -3
index d0cc7e3..de53558 100644
@@ -50,11 +50,13 @@ OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
 ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
-CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+O_TO_S = $(LD) $(call linkerprefix,$(CPU_LDFLAGS)) \
+	-shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
+else
+O_TO_S = $(LD) $(CPU_LDFLAGS) \
+	-shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
 endif
 
-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)"
Signature · 1 line
2.1.3
#22 lore raw

Re: [PATCH 0/3] mk: fix link options

In reply to a message not in the archive

2014-12-17 22:59, Thomas Monjalon:

Quoted 7 lines

When trying to fix the use of combined library, some bugs have been raised. This patchset fix and clean some link options.

Thomas Monjalon (3):
mk: fix link examples to combined library
mk: forbid multiple definitions
mk: fix link with CC

Applied quickly to validate building before the release.

Signature · 1 line
Thomas