DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mk: fix objects/library order when linking
@ 2015-12-04 14:38 David Marchand
  2015-12-04 17:11 ` [dpdk-dev] [PATCH v2] " David Marchand
  0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2015-12-04 14:38 UTC (permalink / raw)
  To: dev

It is safer to specify libraries we depend on after the objects we are linking
into a shared library, especially when the linker is invoked with options like
--as-needed.

Fixes: bef06a8a0655 ("mk: set library dependencies in shared object file")

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 mk/rte.lib.mk |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
index 06a1519..1f1b6e1 100644
--- a/mk/rte.lib.mk
+++ b/mk/rte.lib.mk
@@ -82,7 +82,7 @@ O_TO_A_DO = @set -e; \
 	$(O_TO_A) && \
 	echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
 
-O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS) -shared $(OBJS-y) \
+O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) -shared $(OBJS-y) $(LDLIBS) \
 	 -Wl,-soname,$(LIB) -o $(LIB)
 O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] mk: fix objects/library order when linking
  2015-12-04 14:38 [dpdk-dev] [PATCH] mk: fix objects/library order when linking David Marchand
@ 2015-12-04 17:11 ` David Marchand
  2015-12-04 17:31   ` Adrien Mazarguil
  0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2015-12-04 17:11 UTC (permalink / raw)
  To: dev

The initial problem has been seen while building mlx4 pmd as a shared library
on Ubuntu 14.04 (gcc 4.8.4-2ubuntu1~14.04).

Resulting .so will lack the DT_NEEDED entry for libibverbs:

marchand@ubuntu1404:~/dpdk$ ldd ./build/lib/librte_pmd_mlx4.so
	linux-vdso.so.1 =>  (0x00007fff87ebb000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2ced21a000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2ced821000)

And trying to load it in testpmd triggers this error:

[...]
EAL: librte_pmd_mlx4.so: undefined symbol: ibv_query_port
[...]

After some strace, the problem comes from the --as-needed option passed to the
linker.

It is safer to specify libraries we depend on after the objects we are linking
into a shared library, especially when the linker is invoked with options like
--as-needed.

Fixes: bef06a8a0655 ("mk: set library dependencies in shared object file")

Signed-off-by: David Marchand <david.marchand@6wind.com>
---

Changes since v1:
- added some details in commitlog since Thomas does not like "safer"
  argument :-)

---

 mk/rte.lib.mk |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
index 06a1519..1f1b6e1 100644
--- a/mk/rte.lib.mk
+++ b/mk/rte.lib.mk
@@ -82,7 +82,7 @@ O_TO_A_DO = @set -e; \
 	$(O_TO_A) && \
 	echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
 
-O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS) -shared $(OBJS-y) \
+O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) -shared $(OBJS-y) $(LDLIBS) \
 	 -Wl,-soname,$(LIB) -o $(LIB)
 O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] mk: fix objects/library order when linking
  2015-12-04 17:11 ` [dpdk-dev] [PATCH v2] " David Marchand
@ 2015-12-04 17:31   ` Adrien Mazarguil
  2015-12-04 18:43     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Adrien Mazarguil @ 2015-12-04 17:31 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

On Fri, Dec 04, 2015 at 06:11:03PM +0100, David Marchand wrote:
> The initial problem has been seen while building mlx4 pmd as a shared library
> on Ubuntu 14.04 (gcc 4.8.4-2ubuntu1~14.04).
> 
> Resulting .so will lack the DT_NEEDED entry for libibverbs:
> 
> marchand@ubuntu1404:~/dpdk$ ldd ./build/lib/librte_pmd_mlx4.so
> 	linux-vdso.so.1 =>  (0x00007fff87ebb000)
> 	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2ced21a000)
> 	/lib64/ld-linux-x86-64.so.2 (0x00007f2ced821000)
> 
> And trying to load it in testpmd triggers this error:
> 
> [...]
> EAL: librte_pmd_mlx4.so: undefined symbol: ibv_query_port
> [...]
> 
> After some strace, the problem comes from the --as-needed option passed to the
> linker.
> 
> It is safer to specify libraries we depend on after the objects we are linking
> into a shared library, especially when the linker is invoked with options like
> --as-needed.
> 
> Fixes: bef06a8a0655 ("mk: set library dependencies in shared object file")
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>
> ---
> 
> Changes since v1:
> - added some details in commitlog since Thomas does not like "safer"
>   argument :-)

Obvious issue that did not show up in our tests under Debian.

Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] mk: fix objects/library order when linking
  2015-12-04 17:31   ` Adrien Mazarguil
@ 2015-12-04 18:43     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2015-12-04 18:43 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

2015-12-04 18:31, Adrien Mazarguil:
> On Fri, Dec 04, 2015 at 06:11:03PM +0100, David Marchand wrote:
> > The initial problem has been seen while building mlx4 pmd as a shared library
> > on Ubuntu 14.04 (gcc 4.8.4-2ubuntu1~14.04).
> > 
> > Resulting .so will lack the DT_NEEDED entry for libibverbs:
> > 
> > marchand@ubuntu1404:~/dpdk$ ldd ./build/lib/librte_pmd_mlx4.so
> > 	linux-vdso.so.1 =>  (0x00007fff87ebb000)
> > 	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2ced21a000)
> > 	/lib64/ld-linux-x86-64.so.2 (0x00007f2ced821000)
> > 
> > And trying to load it in testpmd triggers this error:
> > 
> > [...]
> > EAL: librte_pmd_mlx4.so: undefined symbol: ibv_query_port
> > [...]
> > 
> > After some strace, the problem comes from the --as-needed option passed to the
> > linker.
> > 
> > It is safer to specify libraries we depend on after the objects we are linking
> > into a shared library, especially when the linker is invoked with options like
> > --as-needed.
> > 
> > Fixes: bef06a8a0655 ("mk: set library dependencies in shared object file")
> > 
> > Signed-off-by: David Marchand <david.marchand@6wind.com>
> > ---
> > 
> > Changes since v1:
> > - added some details in commitlog since Thomas does not like "safer"
> >   argument :-)

Yes, that's better justified with these details :)

> Obvious issue that did not show up in our tests under Debian.
> 
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-04 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 14:38 [dpdk-dev] [PATCH] mk: fix objects/library order when linking David Marchand
2015-12-04 17:11 ` [dpdk-dev] [PATCH v2] " David Marchand
2015-12-04 17:31   ` Adrien Mazarguil
2015-12-04 18:43     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).