diff mbox

[dpdk-dev,v3,6/6] mk: prevent overlinking in applications

Message ID 1465583550-21020-7-git-send-email-ferruh.yigit@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers show

Commit Message

Ferruh Yigit June 10, 2016, 6:32 p.m. UTC
Replace --no-as-needed linker flag with --as-needed flag, which will
only link libraries directly called by application.
It can be achieved now that the libraries dependencies are handled
properly.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 mk/exec-env/linuxapp/rte.vars.mk | 3 ---
 mk/rte.app.mk                    | 8 ++++++++
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Thomas Monjalon June 11, 2016, 6:34 a.m. UTC | #1
Hi Ferruh,

2016-06-10 19:32, Ferruh Yigit:
> --- a/mk/rte.app.mk
> +++ b/mk/rte.app.mk
> @@ -50,6 +50,14 @@ ifeq ($(NO_LDSCRIPT),)
>  LDSCRIPT = $(RTE_LDSCRIPT)
>  endif
>  
> +ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
> +# Workaround to eal <-> mempool cyclic dependency
> +_LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
> +endif
> +
> +# Link only the libraries used in the application
> +_LDLIBS-y += --as-needed

I think we do not need this workaround.
The dependency of EAL logs on mempool is now removed.
We only have the dependency of EAL ivshmem on librte_ivshmem header
(which needs mempool and rings headers).
Ferruh Yigit June 13, 2016, 9:05 a.m. UTC | #2
On 6/11/2016 7:34 AM, Thomas Monjalon wrote:
> Hi Ferruh,
> 
> 2016-06-10 19:32, Ferruh Yigit:
>> --- a/mk/rte.app.mk
>> +++ b/mk/rte.app.mk
>> @@ -50,6 +50,14 @@ ifeq ($(NO_LDSCRIPT),)
>>  LDSCRIPT = $(RTE_LDSCRIPT)
>>  endif
>>  
>> +ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
>> +# Workaround to eal <-> mempool cyclic dependency
>> +_LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
>> +endif
>> +
>> +# Link only the libraries used in the application
>> +_LDLIBS-y += --as-needed
> 
> I think we do not need this workaround.
> The dependency of EAL logs on mempool is now removed.
> We only have the dependency of EAL ivshmem on librte_ivshmem header
> (which needs mempool and rings headers).
> 

I missed that dependency removed, this is good, I will send a new
version of the patch.

Thanks,
ferruh
Christian Ehrhardt June 13, 2016, 9:24 a.m. UTC | #3
Hi,
great work on cleaning that up already.
I applied v3 of the series and see already much better results.

But I found some more that should be part of this.
I don't know how generally available a similar solution is, but usually in
our build dpkg-shlibdeps checks for under/overlinking issues.
I let that run on a dir built from git plus v3 of the series in discussion
here.

There are two way of open dependency issues left:
1. some libraries use symbols of other libraries they are not linked with
correctly yet
2. the appliactions are still overlinking

We need to finalize #1 first before being able to tackle #2 without
breaking something.

I'll send a patch for the following so it can be part of your v4

$ for binfile in $(find debian/build/shared-root/lib -executable -type f;
find debian/build/shared-root/app -executable -type f;); do printf
"\n\n\nTesting %s\n" $binfile; dpkg-shlibdeps -e $binfile
-ldebian/build/shared-root/lib/ | grep -v "installed in their package's
directory"; done

Testing debian/build/shared-root/lib/librte_port.so.3
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_sched_port_dequeue used by
debian/build/shared-root/lib/librte_port.so.3 found in none of the libraries
dpkg-shlibdeps: warning: symbol rte_sched_port_enqueue used by
debian/build/shared-root/lib/librte_port.so.3 found in none of the libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_pmd_bond.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_mempool_create used by
debian/build/shared-root/lib/librte_pmd_bond.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_ring_create used by
debian/build/shared-root/lib/librte_pmd_bond.so.1 found in none of the
libraries

Testing debian/build/shared-root/lib/librte_pipeline.so.3
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol per_lcore__lcore_id used by
debian/build/shared-root/lib/librte_pipeline.so.3 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_pipeline.so.3 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_pipeline.so.3 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_free used by
debian/build/shared-root/lib/librte_pipeline.so.3 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_pipeline.so.3 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_zmalloc_socket used by
debian/build/shared-root/lib/librte_pipeline.so.3 found in none of the
libraries

Testing debian/build/shared-root/lib/librte_pmd_null_crypto.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_ring_create used by
debian/build/shared-root/lib/librte_pmd_null_crypto.so.1 found in none of
the libraries
dpkg-shlibdeps: warning: symbol rte_kvargs_parse used by
debian/build/shared-root/lib/librte_pmd_null_crypto.so.1 found in none of
the libraries
dpkg-shlibdeps: warning: symbol rte_kvargs_free used by
debian/build/shared-root/lib/librte_pmd_null_crypto.so.1 found in none of
the libraries
dpkg-shlibdeps: warning: symbol rte_kvargs_process used by
debian/build/shared-root/lib/librte_pmd_null_crypto.so.1 found in none of
the libraries
dpkg-shlibdeps: warning: symbol rte_ring_lookup used by
debian/build/shared-root/lib/librte_pmd_null_crypto.so.1 found in none of
the libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_pmd_vhost.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_eal_driver_register used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol pthread_join used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol pthread_cancel used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_zmalloc_socket used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol pthread_create used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol per_lcore__lcore_id used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_socket_id used by
debian/build/shared-root/lib/librte_pmd_vhost.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: 2 other similar warnings have been skipped (use -v
to see them all)
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_pmd_fm10k.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_kvargs_count used by
debian/build/shared-root/lib/librte_pmd_fm10k.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_kvargs_free used by
debian/build/shared-root/lib/librte_pmd_fm10k.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_kvargs_parse used by
debian/build/shared-root/lib/librte_pmd_fm10k.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_kvargs_process used by
debian/build/shared-root/lib/librte_pmd_fm10k.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_pmd_pcap.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_eal_driver_register used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_cycles_vmware_tsc_map used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_zmalloc_socket used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_get_tsc_hz used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_free used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_socket_id used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol eal_timer_source used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_pmd_pcap.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: 2 other similar warnings have been skipped (use -v
to see them all)
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_sched.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_zmalloc used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol __rte_panic used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol per_lcore__lcore_id used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_free used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_get_tsc_hz used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_cycles_vmware_tsc_map used by
debian/build/shared-root/lib/librte_sched.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_pmd_af_packet.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_zmalloc_socket used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_free used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_socket_id used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_driver_register used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol per_lcore__lcore_id used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_pmd_af_packet.so.1 found in none of the
libraries

Testing debian/build/shared-root/lib/librte_port.so.2
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_sched_port_enqueue used by
debian/build/shared-root/lib/librte_port.so.2 found in none of the libraries
dpkg-shlibdeps: warning: symbol rte_sched_port_dequeue used by
debian/build/shared-root/lib/librte_port.so.2 found in none of the libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_pmd_null.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_zmalloc_socket used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_socket_id used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_cpu_get_flag_enabled used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_free used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol per_lcore__lcore_id used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_eal_driver_register used by
debian/build/shared-root/lib/librte_pmd_null.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory

Testing debian/build/shared-root/lib/librte_ip_frag.so.1
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory
dpkg-shlibdeps: warning: symbol rte_eal_has_hugepages used by
debian/build/shared-root/lib/librte_ip_frag.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_log used by
debian/build/shared-root/lib/librte_ip_frag.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol per_lcore__lcore_id used by
debian/build/shared-root/lib/librte_ip_frag.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_zmalloc_socket used by
debian/build/shared-root/lib/librte_ip_frag.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_cpu_get_flag_enabled used by
debian/build/shared-root/lib/librte_ip_frag.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: symbol rte_mem_virt2phy used by
debian/build/shared-root/lib/librte_ip_frag.so.1 found in none of the
libraries
dpkg-shlibdeps: warning: binaries to analyze should already be installed in
their package's directory


Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd

On Mon, Jun 13, 2016 at 11:05 AM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 6/11/2016 7:34 AM, Thomas Monjalon wrote:
> > Hi Ferruh,
> >
> > 2016-06-10 19:32, Ferruh Yigit:
> >> --- a/mk/rte.app.mk
> >> +++ b/mk/rte.app.mk
> >> @@ -50,6 +50,14 @@ ifeq ($(NO_LDSCRIPT),)
> >>  LDSCRIPT = $(RTE_LDSCRIPT)
> >>  endif
> >>
> >> +ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
> >> +# Workaround to eal <-> mempool cyclic dependency
> >> +_LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
> >> +endif
> >> +
> >> +# Link only the libraries used in the application
> >> +_LDLIBS-y += --as-needed
> >
> > I think we do not need this workaround.
> > The dependency of EAL logs on mempool is now removed.
> > We only have the dependency of EAL ivshmem on librte_ivshmem header
> > (which needs mempool and rings headers).
> >
>
> I missed that dependency removed, this is good, I will send a new
> version of the patch.
>
> Thanks,
> ferruh
>
diff mbox

Patch

diff --git a/mk/exec-env/linuxapp/rte.vars.mk b/mk/exec-env/linuxapp/rte.vars.mk
index d51bd17..a8a1ee4 100644
--- a/mk/exec-env/linuxapp/rte.vars.mk
+++ b/mk/exec-env/linuxapp/rte.vars.mk
@@ -45,9 +45,6 @@  else
 EXECENV_CFLAGS  = -pthread
 endif
 
-# Workaround lack of DT_NEEDED entry
-EXECENV_LDFLAGS = --no-as-needed
-
 EXECENV_LDLIBS  =
 EXECENV_ASFLAGS =
 
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index f60e5bf..aa794bc 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -50,6 +50,14 @@  ifeq ($(NO_LDSCRIPT),)
 LDSCRIPT = $(RTE_LDSCRIPT)
 endif
 
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+# Workaround to eal <-> mempool cyclic dependency
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
+endif
+
+# Link only the libraries used in the application
+_LDLIBS-y += --as-needed
+
 # default path for libs
 _LDLIBS-y += -L$(RTE_SDK_BIN)/lib