[1/7] build: always link-whole DPDK static libraries
Checks
Commit Message
To ensure all constructors are included in static build, we need to pass
the --whole-archive flag when linking, which is used with the
"link_whole" meson option. Since we use link_whole for all libs, we no
longer need to track the lib as part of the static dependency, just the
path to the headers for compiling.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test/meson.build | 2 +-
drivers/meson.build | 2 +-
examples/meson.build | 6 +++---
lib/meson.build | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
Comments
29/04/2020 12:08, Bruce Richardson:
> To ensure all constructors are included in static build, we need to pass
> the --whole-archive flag when linking, which is used with the
> "link_whole" meson option. Since we use link_whole for all libs, we no
> longer need to track the lib as part of the static dependency, just the
> path to the headers for compiling.
Please could you add the generated command line before/after?
I would like to make sure that the external dependencies are out of
the whole-archive option.
Thanks
On Wed, Apr 29, 2020 at 12:18:19PM +0200, Thomas Monjalon wrote:
> 29/04/2020 12:08, Bruce Richardson:
> > To ensure all constructors are included in static build, we need to pass
> > the --whole-archive flag when linking, which is used with the
> > "link_whole" meson option. Since we use link_whole for all libs, we no
> > longer need to track the lib as part of the static dependency, just the
> > path to the headers for compiling.
>
> Please could you add the generated command line before/after?
>
> I would like to make sure that the external dependencies are out of
> the whole-archive option.
>
> Thanks
>
Sure,
the link args for the helloworld example from build.ninja are now (snipping
out some .a's from the middle for brevity):
LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
-Wl,--start-group lib/librte_telemetry.a lib/librte_bpf.a
lib/librte_flow_classify.a lib/librte_pipeline.a lib/librte_table.a
lib/librte_port.a lib/librte_fib.a lib/librte_ipsec.a lib/librte_vhost.a
lib/librte_stack.a lib/librte_security.a lib/librte_sched.a
lib/librte_reorder.a lib/librte_rib.a lib/librte_rawdev.a
lib/librte_pdump.a lib/librte_power.a lib/librte_member.a lib/librte_lpm.a
lib/librte_latencystats.a lib/librte_kni.a lib/librte_jobstats.a
lib/librte_ip_frag.a lib/librte_gso.a lib/librte_gro.a
<snip>
drivers/librte_pmd_mlx5_vdpa.a drivers/librte_pmd_bbdev_null.a
drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
-Wl,--no-as-needed -pthread -lm -ldl -lnuma -lpcap
/usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libjansson.so
/usr/lib/x86_64-linux-gnu/libelf.so -lpcap -lpcap -lpcap -lpcap
/usr/lib/x86_64-linux-gnu/libmlx5.so
/usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
/usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -Wl,--end-group
The before case is below (again snipping some drivers):
LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
-Wl,--start-group drivers/librte_common_cpt.a drivers/librte_common_dpaax.a
drivers/librte_common_iavf.a drivers/librte_common_mlx5.a
drivers/librte_common_octeontx.a drivers/librte_common_octeontx2.a
drivers/librte_bus_dpaa.a drivers/librte_bus_fslmc.a
drivers/librte_bus_ifpga.a drivers/librte_bus_pci.a
<snip>
drivers/librte_pmd_octeontx_event.a drivers/librte_pmd_bbdev_null.a
drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
-Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_eal.a
lib/librte_kvargs.a lib/librte_mempool.a lib/librte_ring.a lib/librte_net.a
lib/librte_mbuf.a lib/librte_ethdev.a lib/librte_meter.a
lib/librte_cmdline.a lib/librte_pci.a lib/librte_cryptodev.a
lib/librte_hash.a lib/librte_eventdev.a lib/librte_timer.a
lib/librte_rawdev.a lib/librte_stack.a lib/librte_sched.a
lib/librte_ip_frag.a lib/librte_security.a lib/librte_kni.a
lib/librte_pipeline.a lib/librte_port.a lib/librte_table.a lib/librte_lpm.a
lib/librte_acl.a lib/librte_gso.a lib/librte_vhost.a lib/librte_reorder.a
lib/librte_compressdev.a lib/librte_bbdev.a -lpcap
/usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libmlx5.so
/usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
/usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -lpcap -lpcap -lpcap
-lIPSec_MB -lIPSec_MB /usr/lib/x86_64-linux-gnu/libcrypto.so
/usr/lib/x86_64-linux-gnu/libisal.so -Wl,--end-group
'-Wl,-rpath,$$ORIGIN/../lib' -Wl,-rpath-link,/home/bruce/dpdk.org/build/lib
These both come from builds with meson 0.54. I can also check that things
look the same for 0.47 too.
/Bruce
29/04/2020 12:42, Bruce Richardson:
> On Wed, Apr 29, 2020 at 12:18:19PM +0200, Thomas Monjalon wrote:
> > 29/04/2020 12:08, Bruce Richardson:
> > > To ensure all constructors are included in static build, we need to pass
> > > the --whole-archive flag when linking, which is used with the
> > > "link_whole" meson option. Since we use link_whole for all libs, we no
> > > longer need to track the lib as part of the static dependency, just the
> > > path to the headers for compiling.
> >
> > Please could you add the generated command line before/after?
> >
> > I would like to make sure that the external dependencies are out of
> > the whole-archive option.
> >
> > Thanks
> >
> Sure,
>
> the link args for the helloworld example from build.ninja are now (snipping
> out some .a's from the middle for brevity):
>
> LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
> -Wl,--start-group lib/librte_telemetry.a lib/librte_bpf.a
> lib/librte_flow_classify.a lib/librte_pipeline.a lib/librte_table.a
> lib/librte_port.a lib/librte_fib.a lib/librte_ipsec.a lib/librte_vhost.a
> lib/librte_stack.a lib/librte_security.a lib/librte_sched.a
> lib/librte_reorder.a lib/librte_rib.a lib/librte_rawdev.a
> lib/librte_pdump.a lib/librte_power.a lib/librte_member.a lib/librte_lpm.a
> lib/librte_latencystats.a lib/librte_kni.a lib/librte_jobstats.a
> lib/librte_ip_frag.a lib/librte_gso.a lib/librte_gro.a
> <snip>
> drivers/librte_pmd_mlx5_vdpa.a drivers/librte_pmd_bbdev_null.a
> drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
> drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
> -Wl,--no-as-needed -pthread -lm -ldl -lnuma -lpcap
> /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libjansson.so
> /usr/lib/x86_64-linux-gnu/libelf.so -lpcap -lpcap -lpcap -lpcap
> /usr/lib/x86_64-linux-gnu/libmlx5.so
> /usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
> /usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -Wl,--end-group
>
> The before case is below (again snipping some drivers):
>
> LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
> -Wl,--start-group drivers/librte_common_cpt.a drivers/librte_common_dpaax.a
> drivers/librte_common_iavf.a drivers/librte_common_mlx5.a
> drivers/librte_common_octeontx.a drivers/librte_common_octeontx2.a
> drivers/librte_bus_dpaa.a drivers/librte_bus_fslmc.a
> drivers/librte_bus_ifpga.a drivers/librte_bus_pci.a
> <snip>
> drivers/librte_pmd_octeontx_event.a drivers/librte_pmd_bbdev_null.a
> drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
> drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
> -Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_eal.a
> lib/librte_kvargs.a lib/librte_mempool.a lib/librte_ring.a lib/librte_net.a
> lib/librte_mbuf.a lib/librte_ethdev.a lib/librte_meter.a
> lib/librte_cmdline.a lib/librte_pci.a lib/librte_cryptodev.a
> lib/librte_hash.a lib/librte_eventdev.a lib/librte_timer.a
> lib/librte_rawdev.a lib/librte_stack.a lib/librte_sched.a
> lib/librte_ip_frag.a lib/librte_security.a lib/librte_kni.a
> lib/librte_pipeline.a lib/librte_port.a lib/librte_table.a lib/librte_lpm.a
> lib/librte_acl.a lib/librte_gso.a lib/librte_vhost.a lib/librte_reorder.a
> lib/librte_compressdev.a lib/librte_bbdev.a -lpcap
> /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libmlx5.so
> /usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
> /usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -lpcap -lpcap -lpcap
> -lIPSec_MB -lIPSec_MB /usr/lib/x86_64-linux-gnu/libcrypto.so
> /usr/lib/x86_64-linux-gnu/libisal.so -Wl,--end-group
> '-Wl,-rpath,$$ORIGIN/../lib' -Wl,-rpath-link,/home/bruce/dpdk.org/build/lib
>
> These both come from builds with meson 0.54. I can also check that things
> look the same for 0.47 too.
That's fine, it looks good.
Please mention that you move DPDK libs inside but external dependencies
are still outside of whole-archive block.
Thanks
On 29/04/2020 12:08, Bruce Richardson wrote:
> To ensure all constructors are included in static build, we need to pass
> the --whole-archive flag when linking, which is used with the
> "link_whole" meson option. Since we use link_whole for all libs, we no
> longer need to track the lib as part of the static dependency, just the
> path to the headers for compiling.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
Thank you Bruce!
I was just searching for the same. My problem was that IF Proxy builds
were crashing on static builds with meson. It turned out that the
culprit is that at the end of rte_eth_iterator_init() there is a call:
iter->cls = rte_class_find_by_name("eth");
which was failing (because constructor registering eth class was not
being called).
This patch solves this issue.
Tested-by: Andrzej Ostruszka <aostruszka@marvell.com>
With regards
Andrzej Ostruszka
@@ -400,7 +400,7 @@ test_dep_objs += cc.find_library('execinfo', required: false)
link_libs = []
if get_option('default_library') == 'static'
- link_libs = dpdk_drivers
+ link_libs = dpdk_static_libraries + dpdk_drivers
endif
dpdk_test = executable('dpdk-test',
@@ -196,7 +196,7 @@ foreach class:dpdk_driver_classes
shared_dep = declare_dependency(link_with: shared_lib,
include_directories: includes,
dependencies: shared_deps)
- static_dep = declare_dependency(link_with: static_lib,
+ static_dep = declare_dependency(
include_directories: includes,
dependencies: static_deps)
@@ -1,9 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2019 Intel Corporation
-driver_libs = []
+link_whole_libs = []
if get_option('default_library') == 'static'
- driver_libs = dpdk_drivers
+ link_whole_libs = dpdk_static_libraries + dpdk_drivers
endif
execinfo = cc.find_library('execinfo', required: false)
@@ -99,7 +99,7 @@ foreach example: examples
endif
executable('dpdk-' + name, sources,
include_directories: includes,
- link_whole: driver_libs,
+ link_whole: link_whole_libs,
link_args: dpdk_extra_ldflags,
c_args: cflags,
dependencies: dep_objs)
@@ -128,7 +128,7 @@ foreach l:libraries
dependencies: static_deps,
include_directories: includes,
install: true)
- static_dep = declare_dependency(link_with: static_lib,
+ static_dep = declare_dependency(
include_directories: includes,
dependencies: static_deps)