improve DPDK static builds with meson
Subsystems (2)
cover improve DPDK static builds with meson
This set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole-archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK rather than just one.
Bruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variable devtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinking
app/meson.build | 2 +- app/test/meson.build | 2 +- buildtools/pkg-config/meson.build | 43 +++++++++++++++++++ .../pkg-config/set-static-linker-flags.py | 38 ++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/prog_guide/build-sdk-meson.rst | 2 +- drivers/meson.build | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/meson.build | 6 +-- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- lib/librte_telemetry/meson.build | 1 - lib/meson.build | 2 +- meson.build | 26 +---------- 53 files changed, 134 insertions(+), 76 deletions(-) create mode 100644 buildtools/pkg-config/meson.build create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
Signature · 1 line
2.20.1
PATCH 1/7 build: always link-whole DPDK static libraries
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.
--- app/test/meson.build | 2 +- drivers/meson.build | 2 +- examples/meson.build | 6 +++--- lib/meson.build | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
app/test/meson.build +1 -1
@@ -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',
drivers/meson.build +1 -1
@@ -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)
examples/meson.build +3 -3
@@ -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)
lib/meson.build +1 -1
@@ -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)
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
29/04/2020 12:08, Bruce Richardson:
Quoted 5 lines
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 uselink_wholefor 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
Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
Quoted 7 lines · Thomas Monjalon
29/04/2020 12:08, Bruce Richardson:
Quoted 5 lines
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 uselink_wholefor all libs, we no longer need to track the lib as part of the static dependency, just the path to the headers for compiling.
Quoted 7 lines
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
Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
29/04/2020 12:42, Bruce Richardson:
Quoted 69 lines · Thomas Monjalon
Quoted 7 lines
29/04/2020 12:08, Bruce Richardson:
Quoted 5 lines
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 uselink_wholefor all libs, we no longer need to track the lib as part of the static dependency, just the path to the headers for compiling.Quoted 7 lines
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-grouplib/librte_telemetry.alib/librte_bpf.alib/librte_flow_classify.alib/librte_pipeline.alib/librte_table.alib/librte_port.alib/librte_fib.alib/librte_ipsec.alib/librte_vhost.alib/librte_stack.alib/librte_security.alib/librte_sched.alib/librte_reorder.alib/librte_rib.alib/librte_rawdev.alib/librte_pdump.alib/librte_power.alib/librte_member.alib/librte_lpm.alib/librte_latencystats.alib/librte_kni.alib/librte_jobstats.alib/librte_ip_frag.alib/librte_gso.alib/librte_gro.a
<snip>drivers/librte_pmd_mlx5_vdpa.adrivers/librte_pmd_bbdev_null.adrivers/librte_pmd_bbdev_turbo_sw.adrivers/librte_pmd_bbdev_fpga_lte_fec.adrivers/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-groupThe before case is below (again snipping some drivers):
LINK_ARGS= -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
-Wl,--start-groupdrivers/librte_common_cpt.adrivers/librte_common_dpaax.adrivers/librte_common_iavf.adrivers/librte_common_mlx5.adrivers/librte_common_octeontx.adrivers/librte_common_octeontx2.adrivers/librte_bus_dpaa.adrivers/librte_bus_fslmc.adrivers/librte_bus_ifpga.adrivers/librte_bus_pci.a
<snip>drivers/librte_pmd_octeontx_event.adrivers/librte_pmd_bbdev_null.adrivers/librte_pmd_bbdev_turbo_sw.adrivers/librte_pmd_bbdev_fpga_lte_fec.adrivers/librte_pmd_bbdev_fpga_5gnr_fec.a-Wl,--no-whole-archive -Wl,--no-as-needed -pthread -lm -ldl -lnumalib/librte_eal.alib/librte_kvargs.alib/librte_mempool.alib/librte_ring.alib/librte_net.alib/librte_mbuf.alib/librte_ethdev.alib/librte_meter.alib/librte_cmdline.alib/librte_pci.alib/librte_cryptodev.alib/librte_hash.alib/librte_eventdev.alib/librte_timer.alib/librte_rawdev.alib/librte_stack.alib/librte_sched.alib/librte_ip_frag.alib/librte_security.alib/librte_kni.alib/librte_pipeline.alib/librte_port.alib/librte_table.alib/librte_lpm.alib/librte_acl.alib/librte_gso.alib/librte_vhost.alib/librte_reorder.alib/librte_compressdev.alib/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
Quoted 2 lines
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
Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
In reply to Bruce RichardsonQuoted 8 lines · 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 uselink_wholefor 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 <[email protected]>---
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.
With regards
Andrzej Ostruszka
PATCH 2/7 build: remove unnecessary variable
In reply to Bruce RichardsonSince all libraries are explicitly linked as part of a build, we no longer need to track ones that should be always included for linking against apps.
--- app/meson.build | 2 +- lib/librte_telemetry/meson.build | 1 - meson.build | 1 - 3 files changed, 1 insertion(+), 3 deletions(-)
app/meson.build +1 -1
@@ -36,7 +36,7 @@ foreach app:apps # use "deps" for internal DPDK dependencies, and "ext_deps" for # external package/library requirements ext_deps = [] - deps = dpdk_app_link_libraries + deps = [] subdir(name)
lib/librte_telemetry/meson.build +0 -1
@@ -8,7 +8,6 @@ deps += ['metrics', 'ethdev'] jansson = dependency('jansson', required: false) if jansson.found() ext_deps += jansson - dpdk_app_link_libraries += ['telemetry'] else build = false reason = 'missing dependency "jansson"'
meson.build +0 -1
@@ -19,7 +19,6 @@ dpdk_static_libraries = [] dpdk_driver_classes = [] dpdk_drivers = [] dpdk_extra_ldflags = [] -dpdk_app_link_libraries = [] dpdk_libs_disabled = [] dpdk_drvs_disabled = [] abi_version_file = files('ABI_VERSION')
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable
29/04/2020 12:08, Bruce Richardson:
Quoted 2 lines
Since all libraries are explicitly linked as part of a build, we no longer need to track ones that should be always included for linking against apps.
I don't understand why telemetry was managed differently.
Re: [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable
Quoted 6 lines · Thomas Monjalon
29/04/2020 12:08, Bruce Richardson:
Quoted 2 lines
Since all libraries are explicitly linked as part of a build, we no longer need to track ones that should be always included for linking against apps.
I don't understand why telemetry was managed differently.
Because it was never directly called by applications - and so unneeded from the linkers viewpoint - but still needed to be linked in to allow apps to support emitting telemetry data. Therefore it was needed to add it explicitly because it was never in the required dependency list for each app.
This wasn't needed for make, since all libs were always linked into make builds. The previous patch in this set changes meson to behave that way too.
/Bruce
PATCH 3/7 devtools/test-meson-builds.sh: add pkg-config static builds
In reply to Bruce RichardsonThe pkg-config file was tested by building some of the examples using make, pulling the cflags and ldflags from the pkg-config file for DPDK. However, this only tested the shared library linkage, and not the static, so this patch updates it to test both.
--- devtools/test-meson-builds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
devtools/test-meson-builds.sh +1 -1
@@ -219,6 +219,6 @@ if pkg-config --define-prefix libdpdk >/dev/null 2>&1; then export PKGCONF="pkg-config --define-prefix" for example in cmdline helloworld l2fwd l3fwd skeleton timer; do echo "## Building $example" - $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all + $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean shared static done fi
Signature · 1 line
2.20.1
PATCH 4/7 build: move pkg-config creation to separate file
In reply to Bruce RichardsonAhead of changes to rework the file, move the pkg-config file generation to a new directory under buildtools. This allows the meson code to be separated out from the main meson.build for simplicity, and also allows any additional scripts for working with the pkg-config files to be placed there too.
--- buildtools/pkg-config/meson.build | 26 ++++++++++++++++++++++++++ meson.build | 25 ++----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 buildtools/pkg-config/meson.build
buildtools/pkg-config/meson.build new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +# for static builds, include the drivers as libs and we need to "whole-archive" +# them. +dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] + +pkg = import('pkgconfig') +pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args +if is_freebsd + pkg_extra_cflags += ['-D__BSD_VISIBLE'] +endif +pkg.generate(name: meson.project_name(), + filebase: 'lib' + meson.project_name().to_lower(), + version: meson.project_version(), + libraries: dpdk_libraries, + libraries_private: dpdk_drivers + dpdk_static_libraries + + ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, + requires: libbsd, # apps using rte_string_fns.h may need this if enabled + # if libbsd is not enabled, then this is blank + description: '''The Data Plane Development Kit (DPDK). +Note that CFLAGS might contain an -march flag higher than typical baseline. +This is required for a number of static inline functions in the public headers.''', + subdirs: [get_option('include_subdir_arch'), '.'], + extra_cflags: pkg_extra_cflags +)
meson.build +2 -23
@@ -60,29 +60,8 @@ configure_file(output: build_cfg, install_dir: join_paths(get_option('includedir'), get_option('include_subdir_arch'))) -# for static builds, include the drivers as libs and we need to "whole-archive" -# them. -dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] - -pkg = import('pkgconfig') -pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args -if is_freebsd - pkg_extra_cflags += ['-D__BSD_VISIBLE'] -endif -pkg.generate(name: meson.project_name(), - filebase: 'lib' + meson.project_name().to_lower(), - version: meson.project_version(), - libraries: dpdk_libraries, - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, - requires: libbsd, # apps using rte_string_fns.h may need this if enabled - # if libbsd is not enabled, then this is blank - description: '''The Data Plane Development Kit (DPDK). -Note that CFLAGS might contain an -march flag higher than typical baseline. -This is required for a number of static inline functions in the public headers.''', - subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: pkg_extra_cflags -) +# build pkg-config files for dpdk +subdir('buildtools/pkg-config') # final output, list all the libs and drivers to be built # this does not affect any part of the build, for information only.
Signature · 1 line
2.20.1
PATCH 5/7 build/pkg-config: output driver libs first for static build
In reply to Bruce RichardsonWhen calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
--- buildtools/pkg-config/meson.build | 32 +++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
buildtools/pkg-config/meson.build +24 -8
@@ -10,17 +10,33 @@ pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args if is_freebsd pkg_extra_cflags += ['-D__BSD_VISIBLE'] endif -pkg.generate(name: meson.project_name(), - filebase: 'lib' + meson.project_name().to_lower(), + +# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before. +pkg.generate(name: 'dpdk-libs', + filebase: 'libdpdk-libs', + description: 'The Data Plane Development Kit (DPDK), libraries only.', version: meson.project_version(), + subdirs: [get_option('include_subdir_arch'), '.'], + extra_cflags: pkg_extra_cflags, libraries: dpdk_libraries, - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, - requires: libbsd, # apps using rte_string_fns.h may need this if enabled - # if libbsd is not enabled, then this is blank + libraries_private: dpdk_extra_ldflags) + +pkg.generate(name: 'DPDK', # main DPDK pkgconfig file + filebase: 'libdpdk', + version: meson.project_version(), description: '''The Data Plane Development Kit (DPDK). Note that CFLAGS might contain an -march flag higher than typical baseline. This is required for a number of static inline functions in the public headers.''', - subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: pkg_extra_cflags + requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs + # if libbsd is not enabled, then this is blank + libraries_private: dpdk_drivers + dpdk_static_libraries + + ['-Wl,-Bdynamic'] )
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
29/04/2020 12:08, Bruce Richardson:
Quoted 7 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries.
Please could you add the error here?
Quoted 3 lines
To get this result, we
need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first.
I feel we are doing something wrong.
We should not have two .pc files.
I also know that static linkage is generally badly supported in pkg-config...
Please could you insert the output of pkg-config to help understanding?
Thanks
Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
Quoted 11 lines · Thomas Monjalon
29/04/2020 12:08, Bruce Richardson:
Quoted 7 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries.
Please could you add the error here?
There is no error, because we work around it. What we do now is that we list the DPDK libraries in both the Libs and Libs.private sections. Without that, we'd have the libs first and then the drivers. This doesn't cause any issues because linking against a .so unnecessarily isn't a problem. However, it does mean that we require that we put in flags to switch between dynamic and static linking in the output.
Quoted 8 lines
Quoted 3 lines
To get this result, we
need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first.I feel we are doing something wrong.
We should not have two .pc files.
I also know that static linkage is generally badly supported in pkg-config...
Yes, it's working around a pkgconfig limitation, though also a limitation in that we don't link against the drivers when we do a shared build.
Quoted 2 lines
Please could you insert the output of pkg-config to help understanding?
Here is the libdpdk.pc contents right now:
Requires: libbsd
Requires.private: libmlx5, libibverbs, zlib, libmlx4, libcrypto, libisal, jansson, libelf
Libs: -L${libdir} -lrte_telemetry -lrte_bpf -lrte_flow_classify
-lrte_pipeline -lrte_table -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost
-lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_rawdev
-lrte_pdump -lrte_power -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni
-lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd
-lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile
-lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash
-lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net
-lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_kvargs
Libs.private: -Wl,--whole-archive -L${libdir} -lrte_common_cpt
-lrte_common_dpaax -lrte_common_iavf -lrte_common_mlx5
-lrte_common_octeontx -lrte_common_octeontx2 -lrte_bus_dpaa -lrte_bus_fslmc
-lrte_bus_ifpga -lrte_bus_pci -lrte_bus_vdev -lrte_bus_vmbus
<snip>
-lrte_pmd_mlx5_vdpa -lrte_pmd_dpaa_event -lrte_pmd_dpaa2_event
-lrte_pmd_octeontx2_event -lrte_pmd_opdl_event -lrte_pmd_skeleton_event
-lrte_pmd_sw_event -lrte_pmd_dsw_event -lrte_pmd_octeontx_event
-lrte_pmd_bbdev_null -lrte_pmd_bbdev_turbo_sw -lrte_pmd_bbdev_fpga_lte_fec
-lrte_pmd_bbdev_fpga_5gnr_fec -Wl,--no-whole-archive -lrte_telemetry
-lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_port
-lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched
-lrte_reorder -lrte_rib -lrte_rawdev -lrte_pdump -lrte_power -lrte_member
-lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag
-lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor
-lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats
-lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline
-lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool
-lrte_rcu -lrte_ring -lrte_eal -lrte_kvargs -Wl,-Bdynamic -pthread -lm -ldl
-lnuma -lpcap -lIPSec_MB Cflags:-I${includedir} -include rte_config.h
-march=nativeThe output from pkg-config for this is below, with libs first, then drivers and libs a second time:
$ PKG_CONFIG_PATH=`pwd`/meson-private pkg-config --static --libs libdpdk -L/usr/local/lib/x86_64-linux-gnu -lrte_telemetry -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_kvargs -Wl,--whole-archive -L/usr/local/lib/x86_64-linux-gnu -lrte_common_cpt -lrte_common_dpaax -lrte_common_iavf -lrte_common_mlx5 -lrte_common_octeontx -lrte_common_octeontx2 -lrte_bus_dpaa -lrte_bus_fslmc -lrte_bus_ifpga -lrte_bus_pci -lrte_bus_vdev -lrte_bus_vmbus -lrte_mempool_bucket -lrte_mempool_dpaa -lrte_mempool_dpaa2 -lrte_mempool_octeontx -lrte_mempool_octeontx2 -lrte_mempool_ring -lrte_mempool_stack -lrte_pmd_af_packet -lrte_pmd_ark -lrte_pmd_atlantic -lrte_pmd_avp -lrte_pmd_axgbe -lrte_pmd_bond -lrte_pmd_bnx2x -lrte_pmd_bnxt -lrte_pmd_cxgbe -lrte_pmd_dpaa -lrte_pmd_dpaa2 -lrte_pmd_e1000 -lrte_pmd_ena -lrte_pmd_enetc -lrte_pmd_enic -lrte_pmd_failsafe -lrte_pmd_fm10k -lrte_pmd_i40e -lrte_pmd_hinic -lrte_pmd_hns3 -lrte_pmd_iavf -lrte_pmd_ice -lrte_pmd_igc -lrte_pmd_ixgbe -lrte_pmd_kni -lrte_pmd_liquidio -lrte_pmd_memif -lrte_pmd_mlx4 -lrte_pmd_mlx5 -lrte_pmd_netvsc -lrte_pmd_nfp -lrte_pmd_null -lrte_pmd_octeontx -lrte_pmd_octeontx2 -lrte_pmd_pcap -lrte_pmd_pfe -lrte_pmd_qede -lrte_pmd_ring -lrte_pmd_sfc -lrte_pmd_softnic -lrte_pmd_tap -lrte_pmd_thunderx -lrte_pmd_vdev_netvsc -lrte_pmd_vhost -lrte_pmd_virtio -lrte_pmd_vmxnet3 -lrte_rawdev_dpaa2_cmdif -lrte_rawdev_dpaa2_qdma -lrte_rawdev_ioat -lrte_rawdev_ntb -lrte_rawdev_octeontx2_dma -lrte_rawdev_octeontx2_ep -lrte_rawdev_skeleton -lrte_pmd_aesni_gcm -lrte_pmd_aesni_mb -lrte_pmd_caam_jr -lrte_pmd_ccp -lrte_pmd_dpaa_sec -lrte_pmd_dpaa2_sec -lrte_pmd_nitrox -lrte_pmd_null_crypto -lrte_pmd_octeontx_crypto -lrte_pmd_octeontx2_crypto -lrte_pmd_openssl -lrte_pmd_crypto_scheduler -lrte_pmd_virtio_crypto -lrte_pmd_isal -lrte_pmd_octeontx_compress -lrte_pmd_qat -lrte_pmd_zlib -lrte_pmd_ifc -lrte_pmd_mlx5_vdpa -lrte_pmd_dpaa_event -lrte_pmd_dpaa2_event -lrte_pmd_octeontx2_event -lrte_pmd_opdl_event -lrte_pmd_skeleton_event -lrte_pmd_sw_event -lrte_pmd_dsw_event -lrte_pmd_octeontx_event -lrte_pmd_bbdev_null -lrte_pmd_bbdev_turbo_sw -lrte_pmd_bbdev_fpga_lte_fec -lrte_pmd_bbdev_fpga_5gnr_fec -Wl,--no-whole-archive -lrte_telemetry -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_kvargs -Wl,-Bdynamic -pthread -lm -ldl -lnuma -lpcap -lIPSec_MB -L/usr/lib/x86_64-linux-gnu -lbsd -L/usr/lib/x86_64-linux-gnu -lmlx5 -lpthread -L/usr/lib/x86_64-linux-gnu -libverbs -lbnxt_re-rdmav22 -lcxgb3-rdmav22 -lcxgb4-rdmav22 -lefa -lhns-rdmav22 -li40iw-rdmav22 -lmlx4 -lmlx5 -lmthca-rdmav22 -lnes-rdmav22 -locrdma-rdmav22 -lqedr-rdmav22 -lvmw_pvrdma-rdmav22 -lhfi1verbs-rdmav22 -lipathverbs-rdmav22 -lrxe-rdmav22 -lpthread -L/usr/lib/x86_64-linux-gnu -lnl-3 -libverbs -lbnxt_re-rdmav22 -lcxgb3-rdmav22 -lcxgb4-rdmav22 -lefa -lhns-rdmav22 -li40iw-rdmav22 -lmlx5 -lmthca-rdmav22 -lnes-rdmav22 -locrdma-rdmav22 -lqedr-rdmav22 -lvmw_pvrdma-rdmav22 -lhfi1verbs-rdmav22 -lipathverbs-rdmav22 -lrxe-rdmav22 -libverbs -lpthread -L/usr/lib/x86_64-linux-gnu -lnl-3 -lz -lmlx4 -lpthread -L/usr/lib/x86_64-linux-gnu -libverbs -lbnxt_re-rdmav22 -lcxgb3-rdmav22 -lcxgb4-rdmav22 -lefa -lhns-rdmav22 -li40iw-rdmav22 -lmlx4 -lmlx5 -lmthca-rdmav22 -lnes-rdmav22 -locrdma-rdmav22 -lqedr-rdmav22 -lvmw_pvrdma-rdmav22 -lhfi1verbs-rdmav22 -lipathverbs-rdmav22 -lrxe-rdmav22 -libverbs -lpthread -L/usr/lib/x86_64-linux-gnu -lnl-route-3 -lnl-3 -lcrypto -ldl -pthread -lisal -ljansson -lelf -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lz
Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
In reply to Bruce RichardsonQuoted 11 lines · Bruce Richardson
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
A neat trick! Can we document that the new file is an implementation detail for internal usage, and that it should not be referenced directly?
I'm even pondering if it would be possible to install it in a private directory, need to check if there's a way for Requires to specify prefixes
Signature · 2 lines
Kind regards, Luca Boccassi
Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
Quoted 13 lines · Luca Boccassi
Quoted 11 lines · Bruce Richardson
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
Quoted 7 lines
A neat trick! Can we document that the new file is an implementation detail for internal usage, and that it should not be referenced directly?
I'm even pondering if it would be possible to install it in a private directory, need to check if there's a way for Requires to specify prefixes
That would be great, if there was a way to hide it. I also take it from your feedback that a package needing multiple .pc files is not an issue for debian packaging?
Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
Quoted 21 lines · Bruce Richardson
Quoted 13 lines · Luca Boccassi
Quoted 11 lines · Bruce Richardson
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
Quoted 7 lines
A neat trick! Can we document that the new file is an implementation detail for internal usage, and that it should not be referenced directly?
I'm even pondering if it would be possible to install it in a private directory, need to check if there's a way for Requires to specify prefixes
Quoted 3 lines
That would be great, if there was a way to hide it. I also take it from your feedback that a package needing multiple .pc files is not an issue for debian packaging?
Yeah it's fine, we can ship as many as we want - just concerned about it being used by mistake, but documenting it should be enough
Signature · 2 lines
Kind regards, Luca Boccassi
PATCH 6/7 build/pkg-config: improve static linking flags
In reply to Bruce RichardsonRather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
--- buildtools/pkg-config/meson.build | 13 ++++--- .../pkg-config/set-static-linker-flags.py | 38 +++++++++++++++++++ doc/guides/prog_guide/build-sdk-meson.rst | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- 45 files changed, 88 insertions(+), 49 deletions(-) create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
buildtools/pkg-config/meson.build +7 -6
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation -# for static builds, include the drivers as libs and we need to "whole-archive" -# them. -dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] - pkg = import('pkgconfig') pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args if is_freebsd
@@ -37,6 +33,11 @@ Note that CFLAGS might contain an -march flag higher than typical baseline. This is required for a number of static inline functions in the public headers.''', requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs # if libbsd is not enabled, then this is blank - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + libraries_private: ['-Wl,--whole-archive'] + + dpdk_drivers + dpdk_static_libraries + + ['-Wl,--no-whole-archive'] ) + +# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)
buildtools/pkg-config/set-static-linker-flags.py new file +38 -0
@@ -0,0 +1,38 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +# Script to fix flags for static linking in pkgconfig files from meson +# Should be called from meson build itself +import os +import sys + + +def fix_ldflag(f): + if not f.startswith('-lrte_'): + return f + return '-l:lib' + f[2:] + '.a' + + +def fix_libs_private(line): + if not line.startswith('Libs.private'): + return line + ldflags = [fix_ldflag(flag) for flag in line.split()] + return ' '.join(ldflags) + '\n' + + +def process_pc_file(filepath): + print('Processing', filepath) + with open(filepath) as src: + lines = src.readlines() + with open(filepath, 'w') as dst: + dst.writelines([fix_libs_private(line) for line in lines]) + + +if 'MESON_BUILD_ROOT' not in os.environ: + print('This script must be called from a meson build environment') + sys.exit(1) +for root, dirs, files in os.walk(os.environ['MESON_BUILD_ROOT']): + pc_files = [f for f in files if f.endswith('.pc')] + for f in pc_files: + process_pc_file(os.path.join(root, f))
doc/guides/prog_guide/build-sdk-meson.rst +1 -1
@@ -191,7 +191,7 @@ From examples/helloworld/Makefile:: PC_FILE := $(shell pkg-config --path libdpdk) CFLAGS += -O3 $(shell pkg-config --cflags libdpdk) LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk) - LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk) + LDFLAGS_STATIC = $(shell pkg-config --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/bbdev_app/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/bond/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/cmdline/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/distributor/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/eventdev_pipeline/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/fips_validation/Makefile +1 -1
@@ -32,7 +32,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/flow_classify/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/flow_filtering/Makefile +1 -1
@@ -20,7 +20,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/helloworld/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ioat/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ip_fragmentation/Makefile +1 -1
@@ -24,7 +24,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ip_pipeline/Makefile +1 -1
@@ -35,7 +35,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -I.
examples/ip_reassembly/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ipsec-secgw/Makefile +1 -1
@@ -36,7 +36,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/ipv4_multicast/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/kni/Makefile +1 -1
@@ -23,7 +23,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-cat/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) LDFLAGS += -lpqos
examples/l2fwd-crypto/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-event/Makefile +1 -1
@@ -28,7 +28,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-jobstats/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-keepalive/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd/Makefile +1 -1
@@ -24,7 +24,7 @@ CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) # Add flag to allow experimental API as l2fwd uses rte_ethdev_set_ptype API CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l3fwd-acl/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l3fwd-power/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/l3fwd/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/link_status_interrupt/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ntb/Makefile +1 -1
@@ -27,7 +27,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/packet_ordering/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ptpclient/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/qos_meter/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/qos_sched/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/rxtx_callbacks/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/service_cores/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/skeleton/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/tep_termination/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -Wno-deprecated-declarations
examples/timer/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vdpa/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vhost/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/vhost_blk/Makefile +1 -1
@@ -25,7 +25,7 @@ LDFLAGS += -pthread PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/vhost_crypto/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vmdq/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vmdq_dcb/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
29/04/2020 12:08, Bruce Richardson:
Quoted 6 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
It looks to be the same workaround I did for ibverbs static linkage :)
sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a,"
Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
Quoted 11 lines · Thomas Monjalon
29/04/2020 12:08, Bruce Richardson:
Quoted 6 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
It looks to be the same workaround I did for ibverbs static linkage :)
sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a,"
Are you implying that I normally learn nothing from your patches? :-)
Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
29/04/2020 12:56, Bruce Richardson:
Quoted 9 lines · Thomas Monjalon
Quoted 8 lines
29/04/2020 12:08, Bruce Richardson:
Quoted 6 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Quoted 4 lines
Quoted 3 lines
It looks to be the same workaround I did for ibverbs static linkage :)
sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a,"Are you implying that I normally learn nothing from your patches? :-)
I'm happy it helped the general case :-)
Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
In reply to Bruce RichardsonQuoted 9 lines · Bruce Richardson
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag
This sounds like a worthwhile feature request for Meson to me. Would you be up for opening an RFE on their issue tracker explaining the use case, please?
Signature · 2 lines
Kind regards, Luca Boccassi
Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
Quoted 8 lines · Luca Boccassi
Quoted 7 lines · Bruce Richardson
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Quoted 7 lines
Quoted 2 lines
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag
This sounds like a worthwhile feature request for Meson to me. Would you be up for opening an RFE on their issue tracker explaining the use case, please?
Yes, I can do so.
I didn't look to implement this in meson myself because it would take so long to get into a version that we would use as our minimum version. :-(
/Bruce
Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
Quoted 16 lines · Bruce Richardson
Quoted 8 lines · Luca Boccassi
Quoted 7 lines · Bruce Richardson
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Quoted 7 lines
Quoted 2 lines
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag
This sounds like a worthwhile feature request for Meson to me. Would you be up for opening an RFE on their issue tracker explaining the use case, please?
Quoted 6 lines
Yes, I can do so.
I didn't look to implement this in meson myself because it would take so long to get into a version that we would use as our minimum version. :-(
/Bruce
Yeah that's fair, an issue to put in the radar is fine, and if anyone has time to implement it then we can remove the workarounds in the future
Signature · 2 lines
Kind regards, Luca Boccassi
PATCH 7/7 build/pkg-config: prevent overlinking
In reply to Bruce RichardsonAdd the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
--- buildtools/pkg-config/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
buildtools/pkg-config/meson.build +1 -1
@@ -22,7 +22,7 @@ pkg.generate(name: 'dpdk-libs', version: meson.project_version(), subdirs: [get_option('include_subdir_arch'), '.'], extra_cflags: pkg_extra_cflags, - libraries: dpdk_libraries, + libraries: ['-Wl,--as-needed'] + dpdk_libraries, libraries_private: dpdk_extra_ldflags) pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking
29/04/2020 12:08, Bruce Richardson:
Quoted 5 lines
Add the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
I consider "--as-needed" as a workaround here.
The root issue is that pkg-config does not distinguish clearly shared and static linkage, right?
Re: [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking
Quoted 11 lines · Thomas Monjalon
29/04/2020 12:08, Bruce Richardson:
Quoted 5 lines
Add the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
I consider "--as-needed" as a workaround here.
The root issue is that pkg-config does not distinguish clearly shared and static linkage, right?
Yeah, pretty much. Improved static linking support in pkg-config would really help with all this - and probably make much of this set unnecessary. Unfortunately, how pkg-config works right now is how it works, and a change to support what we want would be a fairly major change in functionality.
/Bruce
v2 cover improve DPDK static builds with meson
In reply to Bruce RichardsonThis set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole-archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK rather than just one.
v2: improved log messages for a number of patches, and clearly marked
internal-only pkg-config file as such
Bruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variable devtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinking
app/meson.build | 2 +- app/test/meson.build | 2 +- buildtools/pkg-config/meson.build | 43 +++++++++++++++++++ .../pkg-config/set-static-linker-flags.py | 38 ++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/prog_guide/build-sdk-meson.rst | 2 +- drivers/meson.build | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/meson.build | 6 +-- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- lib/librte_telemetry/meson.build | 1 - lib/meson.build | 2 +- meson.build | 26 +---------- 53 files changed, 134 insertions(+), 76 deletions(-) create mode 100644 buildtools/pkg-config/meson.build create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
Signature · 1 line
2.20.1
PATCH v2 1/7 build: always link-whole DPDK static libraries
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.
After this patch is applied, all DPDK .a files are inside --whole-archive/--no-whole-archive flags, but external dependencies and shared libs being linked against remain outside.
---
V2: amended git log to clarify that external dependencies are unaffected by this change
--- app/test/meson.build | 2 +- drivers/meson.build | 2 +- examples/meson.build | 6 +++--- lib/meson.build | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
app/test/meson.build +1 -1
@@ -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',
drivers/meson.build +1 -1
@@ -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)
examples/meson.build +3 -3
@@ -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)
lib/meson.build +1 -1
@@ -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)
Signature · 1 line
2.20.1
PATCH v2 2/7 build: remove unnecessary variable
In reply to Bruce RichardsonSince all libraries are explicitly linked as part of a build, we no longer need to track ones that should be always included for linking against apps.
Previously telemetry was special-cased for linking as it was not directly needed by the linker when linking the apps, since they never called into it directly. This meant that it could be forgotten when specifying the app dependencies, and so the telemetry support would not work. This special-casing was never needed for make as it always linked in all libraries, as meson does now.
---
V2: added more detail on the history to the commit log
--- app/meson.build | 2 +- lib/librte_telemetry/meson.build | 1 - meson.build | 1 - 3 files changed, 1 insertion(+), 3 deletions(-)
app/meson.build +1 -1
@@ -36,7 +36,7 @@ foreach app:apps # use "deps" for internal DPDK dependencies, and "ext_deps" for # external package/library requirements ext_deps = [] - deps = dpdk_app_link_libraries + deps = [] subdir(name)
lib/librte_telemetry/meson.build +0 -1
@@ -8,7 +8,6 @@ deps += ['metrics', 'ethdev'] jansson = dependency('jansson', required: false) if jansson.found() ext_deps += jansson - dpdk_app_link_libraries += ['telemetry'] else build = false reason = 'missing dependency "jansson"'
meson.build +0 -1
@@ -19,7 +19,6 @@ dpdk_static_libraries = [] dpdk_driver_classes = [] dpdk_drivers = [] dpdk_extra_ldflags = [] -dpdk_app_link_libraries = [] dpdk_libs_disabled = [] dpdk_drvs_disabled = [] abi_version_file = files('ABI_VERSION')
Signature · 1 line
2.20.1
PATCH v2 3/7 devtools/test-meson-builds.sh: add pkg-config static builds
In reply to Bruce RichardsonThe pkg-config file was tested by building some of the examples using make, pulling the cflags and ldflags from the pkg-config file for DPDK. However, this only tested the shared library linkage, and not the static, so this patch updates it to test both.
--- devtools/test-meson-builds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
devtools/test-meson-builds.sh +1 -1
@@ -219,6 +219,6 @@ if pkg-config --define-prefix libdpdk >/dev/null 2>&1; then export PKGCONF="pkg-config --define-prefix" for example in cmdline helloworld l2fwd l3fwd skeleton timer; do echo "## Building $example" - $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all + $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean shared static done fi
Signature · 1 line
2.20.1
PATCH v2 4/7 build: move pkg-config creation to separate file
In reply to Bruce RichardsonAhead of changes to rework the file, move the pkg-config file generation to a new directory under buildtools. This allows the meson code to be separated out from the main meson.build for simplicity, and also allows any additional scripts for working with the pkg-config files to be placed there too.
--- buildtools/pkg-config/meson.build | 26 ++++++++++++++++++++++++++ meson.build | 25 ++----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 buildtools/pkg-config/meson.build
buildtools/pkg-config/meson.build new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +# for static builds, include the drivers as libs and we need to "whole-archive" +# them. +dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] + +pkg = import('pkgconfig') +pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args +if is_freebsd + pkg_extra_cflags += ['-D__BSD_VISIBLE'] +endif +pkg.generate(name: meson.project_name(), + filebase: 'lib' + meson.project_name().to_lower(), + version: meson.project_version(), + libraries: dpdk_libraries, + libraries_private: dpdk_drivers + dpdk_static_libraries + + ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, + requires: libbsd, # apps using rte_string_fns.h may need this if enabled + # if libbsd is not enabled, then this is blank + description: '''The Data Plane Development Kit (DPDK). +Note that CFLAGS might contain an -march flag higher than typical baseline. +This is required for a number of static inline functions in the public headers.''', + subdirs: [get_option('include_subdir_arch'), '.'], + extra_cflags: pkg_extra_cflags +)
meson.build +2 -23
@@ -60,29 +60,8 @@ configure_file(output: build_cfg, install_dir: join_paths(get_option('includedir'), get_option('include_subdir_arch'))) -# for static builds, include the drivers as libs and we need to "whole-archive" -# them. -dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] - -pkg = import('pkgconfig') -pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args -if is_freebsd - pkg_extra_cflags += ['-D__BSD_VISIBLE'] -endif -pkg.generate(name: meson.project_name(), - filebase: 'lib' + meson.project_name().to_lower(), - version: meson.project_version(), - libraries: dpdk_libraries, - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, - requires: libbsd, # apps using rte_string_fns.h may need this if enabled - # if libbsd is not enabled, then this is blank - description: '''The Data Plane Development Kit (DPDK). -Note that CFLAGS might contain an -march flag higher than typical baseline. -This is required for a number of static inline functions in the public headers.''', - subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: pkg_extra_cflags -) +# build pkg-config files for dpdk +subdir('buildtools/pkg-config') # final output, list all the libs and drivers to be built # this does not affect any part of the build, for information only.
Signature · 1 line
2.20.1
PATCH v2 5/7 build/pkg-config: output driver libs first for static build
In reply to Bruce RichardsonWhen calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
---
V2: expanded commit log message with extra info, and updated pkg-config file description to make it clearer that one file is internal-only
--- buildtools/pkg-config/meson.build | 33 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
buildtools/pkg-config/meson.build +25 -8
@@ -10,17 +10,34 @@ pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args if is_freebsd pkg_extra_cflags += ['-D__BSD_VISIBLE'] endif -pkg.generate(name: meson.project_name(), - filebase: 'lib' + meson.project_name().to_lower(), + +# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before. +pkg.generate(name: 'dpdk-libs', + filebase: 'libdpdk-libs', + description: '''Internal-only DPDK pkgconfig file. Not for direct use. +Use libdpdk.pc instead of this file to query DPDK compile/link arguments''', version: meson.project_version(), + subdirs: [get_option('include_subdir_arch'), '.'], + extra_cflags: pkg_extra_cflags, libraries: dpdk_libraries, - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, - requires: libbsd, # apps using rte_string_fns.h may need this if enabled - # if libbsd is not enabled, then this is blank + libraries_private: dpdk_extra_ldflags) + +pkg.generate(name: 'DPDK', # main DPDK pkgconfig file + filebase: 'libdpdk', + version: meson.project_version(), description: '''The Data Plane Development Kit (DPDK). Note that CFLAGS might contain an -march flag higher than typical baseline. This is required for a number of static inline functions in the public headers.''', - subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: pkg_extra_cflags + requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs + # if libbsd is not enabled, then this is blank + libraries_private: dpdk_drivers + dpdk_static_libraries + + ['-Wl,-Bdynamic'] )
Signature · 1 line
2.20.1
PATCH v2 6/7 build/pkg-config: improve static linking flags
In reply to Bruce RichardsonRather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
--- buildtools/pkg-config/meson.build | 13 ++++--- .../pkg-config/set-static-linker-flags.py | 38 +++++++++++++++++++ doc/guides/prog_guide/build-sdk-meson.rst | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- 45 files changed, 88 insertions(+), 49 deletions(-) create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
buildtools/pkg-config/meson.build +7 -6
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation -# for static builds, include the drivers as libs and we need to "whole-archive" -# them. -dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] - pkg = import('pkgconfig') pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args if is_freebsd
@@ -38,6 +34,11 @@ Note that CFLAGS might contain an -march flag higher than typical baseline. This is required for a number of static inline functions in the public headers.''', requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs # if libbsd is not enabled, then this is blank - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + libraries_private: ['-Wl,--whole-archive'] + + dpdk_drivers + dpdk_static_libraries + + ['-Wl,--no-whole-archive'] ) + +# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)
buildtools/pkg-config/set-static-linker-flags.py new file +38 -0
@@ -0,0 +1,38 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +# Script to fix flags for static linking in pkgconfig files from meson +# Should be called from meson build itself +import os +import sys + + +def fix_ldflag(f): + if not f.startswith('-lrte_'): + return f + return '-l:lib' + f[2:] + '.a' + + +def fix_libs_private(line): + if not line.startswith('Libs.private'): + return line + ldflags = [fix_ldflag(flag) for flag in line.split()] + return ' '.join(ldflags) + '\n' + + +def process_pc_file(filepath): + print('Processing', filepath) + with open(filepath) as src: + lines = src.readlines() + with open(filepath, 'w') as dst: + dst.writelines([fix_libs_private(line) for line in lines]) + + +if 'MESON_BUILD_ROOT' not in os.environ: + print('This script must be called from a meson build environment') + sys.exit(1) +for root, dirs, files in os.walk(os.environ['MESON_BUILD_ROOT']): + pc_files = [f for f in files if f.endswith('.pc')] + for f in pc_files: + process_pc_file(os.path.join(root, f))
doc/guides/prog_guide/build-sdk-meson.rst +1 -1
@@ -191,7 +191,7 @@ From examples/helloworld/Makefile:: PC_FILE := $(shell pkg-config --path libdpdk) CFLAGS += -O3 $(shell pkg-config --cflags libdpdk) LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk) - LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk) + LDFLAGS_STATIC = $(shell pkg-config --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/bbdev_app/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/bond/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/cmdline/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/distributor/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/eventdev_pipeline/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/fips_validation/Makefile +1 -1
@@ -32,7 +32,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/flow_classify/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/flow_filtering/Makefile +1 -1
@@ -20,7 +20,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/helloworld/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ioat/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ip_fragmentation/Makefile +1 -1
@@ -24,7 +24,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ip_pipeline/Makefile +1 -1
@@ -35,7 +35,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -I.
examples/ip_reassembly/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ipsec-secgw/Makefile +1 -1
@@ -36,7 +36,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/ipv4_multicast/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/kni/Makefile +1 -1
@@ -23,7 +23,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-cat/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) LDFLAGS += -lpqos
examples/l2fwd-crypto/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-event/Makefile +1 -1
@@ -28,7 +28,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-jobstats/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-keepalive/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd/Makefile +1 -1
@@ -24,7 +24,7 @@ CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) # Add flag to allow experimental API as l2fwd uses rte_ethdev_set_ptype API CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l3fwd-acl/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l3fwd-power/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/l3fwd/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/link_status_interrupt/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ntb/Makefile +1 -1
@@ -27,7 +27,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/packet_ordering/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ptpclient/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/qos_meter/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/qos_sched/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/rxtx_callbacks/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/service_cores/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/skeleton/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/tep_termination/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -Wno-deprecated-declarations
examples/timer/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vdpa/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vhost/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/vhost_blk/Makefile +1 -1
@@ -25,7 +25,7 @@ LDFLAGS += -pthread PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/vhost_crypto/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vmdq/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vmdq_dcb/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
Signature · 1 line
2.20.1
PATCH v2 7/7 build/pkg-config: prevent overlinking
In reply to Bruce RichardsonAdd the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
The real root-cause of this issue is that the DPDK libraries need to be duplicated in the linker command when doing static linking, due to the behaviour of pkg-config, but since that behaviour cannot be easily changed, this is a simple workaround to avoid problems.
---
V2: expand commit log to explain that pkg-config behaviour of part of the problem.
--- buildtools/pkg-config/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
buildtools/pkg-config/meson.build +1 -1
@@ -23,7 +23,7 @@ Use libdpdk.pc instead of this file to query DPDK compile/link arguments''', version: meson.project_version(), subdirs: [get_option('include_subdir_arch'), '.'], extra_cflags: pkg_extra_cflags, - libraries: dpdk_libraries, + libraries: ['-Wl,--as-needed'] + dpdk_libraries, libraries_private: dpdk_extra_ldflags) pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
Signature · 1 line
2.20.1
Quoted 70 lines · Bruce Richardson
This set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole-archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK rather than just one.
v2: improved log messages for a number of patches, and clearly marked
internal-only pkg-config file as suchBruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variabledevtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinkingapp/meson.build | 2 +- app/test/meson.build | 2 +- buildtools/pkg-config/meson.build | 43 +++++++++++++++++++ .../pkg-config/set-static-linker-flags.py | 38 ++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/prog_guide/build-sdk-meson.rst | 2 +- drivers/meson.build | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/meson.build | 6 +-- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +-
Quoted 8 lines
examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- lib/librte_telemetry/meson.build | 1 - lib/meson.build | 2 +- meson.build | 26 +---------- 53 files changed, 134 insertions(+), 76 deletions(-) create mode 100644 buildtools/pkg-config/meson.build create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
Signature · 2 lines
Kind regards, Luca Boccassi
Quoted 84 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Bruce Richardson
Sent: Friday, May 1, 2020 7:24 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Richardson, Bruce <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with mesonThis set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole- archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK rather than just one.
v2: improved log messages for a number of patches, and clearly marked
internal-only pkg-config file as suchBruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variabledevtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinkingapp/meson.build | 2 +- app/test/meson.build | 2 +- buildtools/pkg-config/meson.build | 43 +++++++++++++++++++ .../pkg-config/set-static-linker-flags.py | 38 ++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/prog_guide/build-sdk-meson.rst | 2 +- drivers/meson.build | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/meson.build | 6 +-- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- lib/librte_telemetry/meson.build | 1 - lib/meson.build | 2 +- meson.build | 26 +---------- 53 files changed, 134 insertions(+), 76 deletions(-) create mode 100644
Quoted 5 lines
buildtools/pkg-config/meson.build create mode 100644 buildtools/pkg-
config/set-static-linker-flags.py--
2.20.1
This series allows OVS to consume the DPDK libraries appropriately (static and shared) and simplifies the build.
When building OVS with DPDK, without this patch, the linker would always pick the shared libraries over static even after specifying the -Bstatic flag. With this patch, no such behavior is observed. So, it would be very helpful for the OVS community if this patch is merged in DPDK.
I would also ask this series to be back ported to 19.11 as OVS can immediately consume it on the latest master instead of waiting on the next DPDK release i.e 20.11
Quoted 98 lines
Quoted 9 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Bruce Richardson
Sent: Friday, May 1, 2020 7:24 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Richardson, Bruce <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with mesonQuoted 8 lines
This set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole- archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK
rather than just one.
Quoted 67 lines
v2: improved log messages for a number of patches, and clearly marked
internal-only pkg-config file as suchBruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variabledevtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinkingapp/meson.build | 2 +- app/test/meson.build | 2 +- buildtools/pkg-config/meson.build | 43 +++++++++++++++++++ .../pkg-config/set-static-linker-flags.py | 38 ++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/prog_guide/build-sdk-meson.rst | 2 +- drivers/meson.build | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/meson.build | 6 +-- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- lib/librte_telemetry/meson.build | 1 - lib/meson.build | 2 +- meson.build | 26 +---------- 53 files changed, 134 insertions(+), 76 deletions(-) create modeQuoted 5 lines
100644 buildtools/pkg-config/meson.build create mode 100644 buildtools/pkg-
config/set-static-linker-flags.py--
2.20.1This series allows OVS to consume the DPDK libraries appropriately (static and shared) and simplifies the build.
When building OVS with DPDK, without this patch, the linker would always pick the shared libraries over static even after specifying the -Bstatic flag. With this patch, no such behavior is observed. So, it would be very helpful for the OVS community if this patch is merged in DPDK.
Quoted 3 lines
I would also ask this series to be back ported to 19.11 as OVS can immediately consume it on the latest master instead of waiting on the next DPDK release i.e 20.11
+1, if this would be possible to apply to 19.11 as a backport it would enable OVS to move quicker and update the OVS Travis as well as docs and build scripts rather than waiting for DPDK 20.11. Sunil has already been working on these changes I believe.
Alternatively if it cant be backported to 19.11, then possibly we could look at merging Sunil's patches to the dpdk-latest branch in OVS once makefiles are deprecated in DPDK master?
Regards
Ian
Quoted 3 lines
Series-acked-by Sunil Pai G <[email protected]>
30/06/2020 18:37, Stokes, Ian:
Quoted 7 lines
Quoted 7 lines
This series allows OVS to consume the DPDK libraries appropriately (static and shared) and simplifies the build.
When building OVS with DPDK, without this patch, the linker would always pick the shared libraries over static even after specifying the -Bstatic flag. With this patch, no such behavior is observed. So, it would be very helpful for the OVS community if this patch is merged in DPDK.
Quoted 7 lines
Quoted 3 lines
I would also ask this series to be back ported to 19.11 as OVS can immediately consume it on the latest master instead of waiting on the next DPDK release i.e 20.11
+1, if this would be possible to apply to 19.11 as a backport it would enable OVS to move quicker and update the OVS Travis as well as docs and build scripts rather than waiting for DPDK 20.11. Sunil has already been working on these changes I believe.
Alternatively if it cant be backported to 19.11, then possibly we could look at merging Sunil's patches to the dpdk-latest branch in OVS once makefiles are deprecated in DPDK master?
Why waiting for makefiles to be deprecated?
These patches are merged in latest DPDK, so you can proceed in OVS.
Quoted 20 lines
30/06/2020 18:37, Stokes, Ian:
Quoted 5 lines
Quoted 5 lines
This series allows OVS to consume the DPDK libraries appropriately (static and
shared) and simplifies the build.
When building OVS with DPDK, without this patch, the linker would always pick the shared libraries over static even after specifying the -Bstatic flag.
Quoted 9 lines
Quoted 7 lines
With this patch, no such behavior is observed. So, it would be very helpful for the OVS community if this patch is merged in DPDK.
I would also ask this series to be back ported to 19.11 as OVS can immediately consume it on the latest master instead of waiting on the next DPDK release i.e
20.11+1, if this would be possible to apply to 19.11 as a backport it would enable
OVS to move quicker and update the OVS Travis as well as docs and build scripts rather than waiting for DPDK 20.11. Sunil has already been working on these changes I believe.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Alternatively if it cant be backported to 19.11, then possibly we could look
at merging Sunil's patches to the dpdk-latest branch in OVS once makefiles are deprecated in DPDK master?
Why waiting for makefiles to be deprecated?
These patches are merged in latest DPDK, so you can proceed in OVS.
Good point, Sunil has a patchset ready to go, will have him post them to the OVS ML for dpdk-latest branch today.
Regards
Ian
v3 cover improve DPDK static builds with meson
In reply to Bruce RichardsonThis set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole-archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK rather than just one.
v3: rebased to latest on main branch
v2: improved log messages for a number of patches, and clearly marked
internal-only pkg-config file as such
Bruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variable devtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinking
app/meson.build | 2 +- app/test/meson.build | 2 +- buildtools/pkg-config/meson.build | 44 +++++++++++++++++++ .../pkg-config/set-static-linker-flags.py | 38 ++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/prog_guide/build-sdk-meson.rst | 2 +- drivers/meson.build | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/meson.build | 6 +-- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- lib/meson.build | 2 +- meson.build | 26 +---------- 52 files changed, 135 insertions(+), 75 deletions(-) create mode 100644 buildtools/pkg-config/meson.build create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
Signature · 1 line
2.25.1
PATCH v3 1/7 build: always link-whole DPDK static libraries
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.
After this patch is applied, all DPDK .a files are inside --whole-archive/--no-whole-archive flags, but external dependencies and shared libs being linked against remain outside.
--- app/test/meson.build | 2 +- drivers/meson.build | 2 +- examples/meson.build | 6 +++--- lib/meson.build | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
app/test/meson.build +1 -1
@@ -415,7 +415,7 @@ test_dep_objs += cc.find_library('execinfo', required: false) link_libs = [] link_nodes = [] if get_option('default_library') == 'static' - link_libs = dpdk_drivers + link_libs = dpdk_static_libraries + dpdk_drivers link_nodes = dpdk_graph_nodes endif
drivers/meson.build +1 -1
@@ -200,7 +200,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)
examples/meson.build +3 -3
@@ -1,10 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -driver_libs = [] +link_whole_libs = [] node_libs = [] if get_option('default_library') == 'static' - driver_libs = dpdk_drivers + link_whole_libs = dpdk_static_libraries + dpdk_drivers node_libs = dpdk_graph_nodes endif
@@ -101,7 +101,7 @@ foreach example: examples endif executable('dpdk-' + name, sources, include_directories: includes, - link_whole: driver_libs + node_libs, + link_whole: link_whole_libs + node_libs, link_args: dpdk_extra_ldflags, c_args: cflags, dependencies: dep_objs)
lib/meson.build +1 -1
@@ -134,7 +134,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)
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries
30/06/2020 16:14, Bruce Richardson:
Quoted 20 lines
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 uselink_wholefor all libs, we no longer need to track the lib as part of the static dependency, just the path to the headers for compiling.After this patch is applied, all DPDK .a files are inside --whole-archive/--no-whole-archive flags, but external dependencies and shared libs being linked against remain outside.
Signed-off-by Bruce Richardson <[email protected]>Tested-by Andrzej Ostruszka <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
app/test/meson.build +1
-1- link_libs = dpdk_drivers + link_libs = dpdk_static_libraries + dpdk_drivers link_nodes = dpdk_graph_nodes
[...]
examples/meson.build line 8
Quoted 9 lines
examples/meson.build +2
-2-driver_libs = [] +link_whole_libs = [] node_libs = [] if get_option('default_library') == 'static' - driver_libs = dpdk_drivers + link_whole_libs = dpdk_static_libraries + dpdk_drivers node_libs = dpdk_graph_nodes
I think the special case for librte_node may be removed. I will propose a separate patch for this case.
PATCH v3 2/7 build: remove unnecessary variable
In reply to Bruce RichardsonSince all libraries are explicitly linked as part of a build, we no longer need to track ones that should be always included for linking against apps.
Previously telemetry was special-cased for linking as it was not directly needed by the linker when linking the apps, since they never called into it directly. This meant that it could be forgotten when specifying the app dependencies, and so the telemetry support would not work. This special-casing was never needed for make as it always linked in all libraries, as meson does now.
--- app/meson.build | 2 +- meson.build | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
app/meson.build +1 -1
@@ -37,7 +37,7 @@ foreach app:apps # use "deps" for internal DPDK dependencies, and "ext_deps" for # external package/library requirements ext_deps = [] - deps = dpdk_app_link_libraries + deps = [] subdir(name)
meson.build +0 -1
@@ -20,7 +20,6 @@ dpdk_graph_nodes = [] dpdk_driver_classes = [] dpdk_drivers = [] dpdk_extra_ldflags = [] -dpdk_app_link_libraries = [] dpdk_libs_disabled = [] dpdk_drvs_disabled = [] abi_version_file = files('ABI_VERSION')
Signature · 1 line
2.25.1
PATCH v3 3/7 devtools/test-meson-builds.sh: add pkg-config static builds
In reply to Bruce RichardsonThe pkg-config file was tested by building some of the examples using make, pulling the cflags and ldflags from the pkg-config file for DPDK. However, this only tested the shared library linkage, and not the static, so this patch updates it to test both.
--- devtools/test-meson-builds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
devtools/test-meson-builds.sh +1 -1
@@ -238,6 +238,6 @@ if pkg-config --define-prefix libdpdk >/dev/null 2>&1; then export PKGCONF="pkg-config --define-prefix" for example in cmdline helloworld l2fwd l3fwd skeleton timer; do echo "## Building $example" - $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all + $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean shared static done fi
Signature · 1 line
2.25.1
PATCH v3 4/7 build: move pkg-config creation to separate file
In reply to Bruce RichardsonAhead of changes to rework the file, move the pkg-config file generation to a new directory under buildtools. This allows the meson code to be separated out from the main meson.build for simplicity, and also allows any additional scripts for working with the pkg-config files to be placed there too.
--- buildtools/pkg-config/meson.build | 26 ++++++++++++++++++++++++++ meson.build | 25 ++----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 buildtools/pkg-config/meson.build
buildtools/pkg-config/meson.build new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +# for static builds, include the drivers as libs and we need to "whole-archive" +# them. +dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] + +pkg = import('pkgconfig') +pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args +if is_freebsd + pkg_extra_cflags += ['-D__BSD_VISIBLE'] +endif +pkg.generate(name: meson.project_name(), + filebase: 'lib' + meson.project_name().to_lower(), + version: meson.project_version(), + libraries: dpdk_libraries, + libraries_private: dpdk_drivers + dpdk_static_libraries + + ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, + requires: libbsd, # apps using rte_string_fns.h may need this if enabled + # if libbsd is not enabled, then this is blank + description: '''The Data Plane Development Kit (DPDK). +Note that CFLAGS might contain an -march flag higher than typical baseline. +This is required for a number of static inline functions in the public headers.''', + subdirs: [get_option('include_subdir_arch'), '.'], + extra_cflags: pkg_extra_cflags +)
meson.build +2 -23
@@ -70,29 +70,8 @@ configure_file(output: build_cfg, install_dir: join_paths(get_option('includedir'), get_option('include_subdir_arch'))) -# for static builds, include the drivers as libs and we need to "whole-archive" -# them. -dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] - -pkg = import('pkgconfig') -pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args -if is_freebsd - pkg_extra_cflags += ['-D__BSD_VISIBLE'] -endif -pkg.generate(name: meson.project_name(), - filebase: 'lib' + meson.project_name().to_lower(), - version: meson.project_version(), - libraries: dpdk_libraries, - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, - requires: libbsd, # apps using rte_string_fns.h may need this if enabled - # if libbsd is not enabled, then this is blank - description: '''The Data Plane Development Kit (DPDK). -Note that CFLAGS might contain an -march flag higher than typical baseline. -This is required for a number of static inline functions in the public headers.''', - subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: pkg_extra_cflags -) +# build pkg-config files for dpdk +subdir('buildtools/pkg-config') # final output, list all the libs and drivers to be built # this does not affect any part of the build, for information only.
Signature · 1 line
2.25.1
PATCH v3 5/7 build/pkg-config: output driver libs first for static build
In reply to Bruce RichardsonWhen calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
--- buildtools/pkg-config/meson.build | 33 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
buildtools/pkg-config/meson.build +25 -8
@@ -10,17 +10,34 @@ pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args if is_freebsd pkg_extra_cflags += ['-D__BSD_VISIBLE'] endif -pkg.generate(name: meson.project_name(), - filebase: 'lib' + meson.project_name().to_lower(), + +# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before. +pkg.generate(name: 'dpdk-libs', + filebase: 'libdpdk-libs', + description: '''Internal-only DPDK pkgconfig file. Not for direct use. +Use libdpdk.pc instead of this file to query DPDK compile/link arguments''', version: meson.project_version(), + subdirs: [get_option('include_subdir_arch'), '.'], + extra_cflags: pkg_extra_cflags, libraries: dpdk_libraries, - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, - requires: libbsd, # apps using rte_string_fns.h may need this if enabled - # if libbsd is not enabled, then this is blank + libraries_private: dpdk_extra_ldflags) + +pkg.generate(name: 'DPDK', # main DPDK pkgconfig file + filebase: 'libdpdk', + version: meson.project_version(), description: '''The Data Plane Development Kit (DPDK). Note that CFLAGS might contain an -march flag higher than typical baseline. This is required for a number of static inline functions in the public headers.''', - subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: pkg_extra_cflags + requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs + # if libbsd is not enabled, then this is blank + libraries_private: dpdk_drivers + dpdk_static_libraries + + ['-Wl,-Bdynamic'] )
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
30/06/2020 16:14, Bruce Richardson:
Quoted 6 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and
Sorry, I'm lost here. Why "only" driver files?
Quoted 1 line
those need to come *before* the regular libraries.
Given whole libs are linked, is it really needed to have drivers first?
Quoted 6 lines
To get this result, we
need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
Quoted 9 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries.
I'm completely lost. In which case we link both static and shared libs?
Quoted 7 lines
By ensuring the shared libraries come last in the link
link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
Quoted 9 lines · Thomas Monjalon
30/06/2020 16:14, Bruce Richardson:
Quoted 6 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and
Sorry, I'm lost here. Why "only" driver files?
My fault for poor word ordering. Should be rewritten as "link the driver files only for static builds".
Quoted 4 lines
Quoted 2 lines
those need to come *before* the regular libraries.
Given whole libs are linked, is it really needed to have drivers first?
If we are considering only static libs, then I suspect not, but to avoid having the shared libraries also linked into the static binaries they definitely need to come last, so they can be linked with as-needed i.e. skipped by the linker.
Quoted 17 lines
Quoted 7 lines
To get this result, we
need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.Quoted 9 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries.
Quoted 2 lines
I'm completely lost. In which case we link both static and shared libs?
It will depend partially upon other linker flags used before the pkgconfig insert. We would be relying upon the user integrating this to explicitly pass in -Bstatic flag before putting the pkgconfig flags output. With the current config, we can't add that ourselves because to go first it would have to go (ironically) in the shared lib part of the pkg-config file. By splitting things into two, it allows the static libs to come before the shared ones, which gives us the ability to control things far better.
Quoted 10 lines
Quoted 7 lines
By ensuring the shared libraries come last in the link
link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
In reply to Bruce Richardson30/06/2020 16:14, Bruce Richardson:
Quoted 2 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field,
s/libraries.private/Libs.private/
Quoted 9 lines
since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
s/libraries.private/Libs.private/
Quoted 16 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args · line 22
Quoted 9 lines
buildtools/pkg-config/meson.build +9
-0+# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before.
This is not obvious. In order to avoid messing it up in future, I suggest this longer reword:
# When calling pkg-config --static --libs, pkg-config will always output the
# regular libs first, and then the extra libs from Libs.private field, # since the assumption is that those are additional dependencies for building # statically that the .a files depend upon. The output order of .pc fields is: # Cflags Libs Libs.private Requires Requires.private # The fields Requires* are for package names. # The flags of the DPDK libraries must be defined in Libs* fields. # However, the DPDK drivers are linked only in static builds (Libs.private), # and those need to come *before* the regular libraries (Libs field). # This requirement is satisfied by moving the regular libs in a separate file # included in the field Requires (after Libs.private). # Another requirement is to allow linking dependencies as shared libraries, # while linking static DPDK libraries and drivers. It is satisfied by # listing the static files in Libs.private with the explicit syntax -l:libfoo.a. # As a consequence, the regular DPDK libraries are already listed as static # in the field Libs.private. The second occurences of DPDK libraries, # included from Requires and used for shared library linkage case, # are skipped in the case of static linkage thanks to the flag --as-needed.
# Link order summary:
# libdpdk.Libs.private: whole-archive(static drivers/libs), drivers deps flags # libdpdk.Requires: libdpdk-libs package # libdpdk-libs.Libs: as-needed(shared libs) # libdpdk-libs.Libs.private: libs deps flags # libdpdk.pc.Requires.private: deps packages
If you agree, I could change this comment while merging. I would add my Signed-off ;)
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
Quoted 74 lines · Thomas Monjalon
30/06/2020 16:14, Bruce Richardson:
Quoted 2 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field,
s/libraries.private/Libs.private/
Quoted 9 lines
since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
s/libraries.private/Libs.private/
Quoted 16 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args · line 22
Quoted 9 lines
buildtools/pkg-config/meson.build +9
-0+# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before.This is not obvious. In order to avoid messing it up in future, I suggest this longer reword:
# When calling pkg-config --static --libs, pkg-config will always output the
# regular libs first, and then the extra libs from Libs.private field, # since the assumption is that those are additional dependencies for building # statically that the .a files depend upon. The output order of .pc fields is: # Cflags Libs Libs.private Requires Requires.private # The fields Requires* are for package names. # The flags of the DPDK libraries must be defined in Libs* fields. # However, the DPDK drivers are linked only in static builds (Libs.private), # and those need to come *before* the regular libraries (Libs field). # This requirement is satisfied by moving the regular libs in a separate file # included in the field Requires (after Libs.private). # Another requirement is to allow linking dependencies as shared libraries, # while linking static DPDK libraries and drivers. It is satisfied by # listing the static files in Libs.private with the explicit syntax -l:libfoo.a. # As a consequence, the regular DPDK libraries are already listed as static # in the field Libs.private. The second occurences of DPDK libraries, # included from Requires and used for shared library linkage case, # are skipped in the case of static linkage thanks to the flag --as-needed.# Link order summary:
# libdpdk.Libs.private: whole-archive(static drivers/libs), drivers deps flags # libdpdk.Requires: libdpdk-libs package # libdpdk-libs.Libs: as-needed(shared libs) # libdpdk-libs.Libs.private: libs deps flags # libdpdk.pc.Requires.private: deps packages
Quoted 3 lines
If you agree, I could change this comment while merging. I would add my Signed-off ;)
This seems generally ok, but probably should just be added as part of patch #7 when all parts of the above have been applied.
Couple of comments:
* One small nit is that cflags are not output as part of the --libs call, so you can remove them from the list on line 5 of the comment. They aren't really relevant to this comment/essay.
* I find the link-order summary to actually be more confusing than helpful. I think the text block is explanatory enough. It just confuses things introducing the extra details of what goes in the requires-private or libs-private of the libdpdk.pc file. That's just regular stuff, unrelated to the changes or to DPDK special-case of needing private libs first.
/Bruce
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
01/07/2020 17:16, Bruce Richardson:
Quoted 79 lines · Thomas Monjalon
Quoted 74 lines
30/06/2020 16:14, Bruce Richardson:
Quoted 2 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field,
s/libraries.private/Libs.private/
Quoted 9 lines
since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
s/libraries.private/Libs.private/
Quoted 16 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args · line 22
Quoted 9 lines
buildtools/pkg-config/meson.build +9
-0+# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before.This is not obvious. In order to avoid messing it up in future, I suggest this longer reword:
# When calling pkg-config --static --libs, pkg-config will always output the
# regular libs first, and then the extra libs from Libs.private field, # since the assumption is that those are additional dependencies for building # statically that the .a files depend upon. The output order of .pc fields is: # Cflags Libs Libs.private Requires Requires.private # The fields Requires* are for package names. # The flags of the DPDK libraries must be defined in Libs* fields. # However, the DPDK drivers are linked only in static builds (Libs.private), # and those need to come *before* the regular libraries (Libs field). # This requirement is satisfied by moving the regular libs in a separate file # included in the field Requires (after Libs.private). # Another requirement is to allow linking dependencies as shared libraries, # while linking static DPDK libraries and drivers. It is satisfied by # listing the static files in Libs.private with the explicit syntax -l:libfoo.a. # As a consequence, the regular DPDK libraries are already listed as static # in the field Libs.private. The second occurences of DPDK libraries, # included from Requires and used for shared library linkage case, # are skipped in the case of static linkage thanks to the flag --as-needed.# Link order summary:
# libdpdk.Libs.private: whole-archive(static drivers/libs), drivers deps flags # libdpdk.Requires: libdpdk-libs package # libdpdk-libs.Libs: as-needed(shared libs) # libdpdk-libs.Libs.private: libs deps flags # libdpdk.pc.Requires.private: deps packagesQuoted 3 lines
If you agree, I could change this comment while merging. I would add my Signed-off ;)
Quoted 7 lines
This seems generally ok, but probably should just be added as part of patch #7 when all parts of the above have been applied.
Couple of comments:
* One small nit is that cflags are not output as part of the --libs call, so you can remove them from the list on line 5 of the comment. They aren't really relevant to this comment/essay.
Yes, I will remove Cflags.
Quoted 5 lines
* I find the link-order summary to actually be more confusing than helpful. I think the text block is explanatory enough. It just confuses things introducing the extra details of what goes in the requires-private or libs-private of the libdpdk.pc file. That's just regular stuff, unrelated to the changes or to DPDK special-case of needing private libs first.
The intent of this summary was to help navigating for future changes in this area.
Personnaly it helps me, but it is maybe more a developer note that can be deduced from the rest.
I can remove it.
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
Quoted 96 lines · Thomas Monjalon
01/07/2020 17:16, Bruce Richardson:
Quoted 79 lines · Thomas Monjalon
Quoted 74 lines
30/06/2020 16:14, Bruce Richardson:
Quoted 2 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field,
s/libraries.private/Libs.private/
Quoted 9 lines
since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
s/libraries.private/Libs.private/
Quoted 16 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args · line 22
Quoted 9 lines
buildtools/pkg-config/meson.build +9
-0+# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before.This is not obvious. In order to avoid messing it up in future, I suggest this longer reword:
# When calling pkg-config --static --libs, pkg-config will always output the
# regular libs first, and then the extra libs from Libs.private field, # since the assumption is that those are additional dependencies for building # statically that the .a files depend upon. The output order of .pc fields is: # Cflags Libs Libs.private Requires Requires.private # The fields Requires* are for package names. # The flags of the DPDK libraries must be defined in Libs* fields. # However, the DPDK drivers are linked only in static builds (Libs.private), # and those need to come *before* the regular libraries (Libs field). # This requirement is satisfied by moving the regular libs in a separate file # included in the field Requires (after Libs.private). # Another requirement is to allow linking dependencies as shared libraries, # while linking static DPDK libraries and drivers. It is satisfied by # listing the static files in Libs.private with the explicit syntax -l:libfoo.a. # As a consequence, the regular DPDK libraries are already listed as static # in the field Libs.private. The second occurences of DPDK libraries, # included from Requires and used for shared library linkage case, # are skipped in the case of static linkage thanks to the flag --as-needed.# Link order summary:
# libdpdk.Libs.private: whole-archive(static drivers/libs), drivers deps flags # libdpdk.Requires: libdpdk-libs package # libdpdk-libs.Libs: as-needed(shared libs) # libdpdk-libs.Libs.private: libs deps flags # libdpdk.pc.Requires.private: deps packagesQuoted 3 lines
If you agree, I could change this comment while merging. I would add my Signed-off ;)
Quoted 7 lines
This seems generally ok, but probably should just be added as part of patch #7 when all parts of the above have been applied.
Couple of comments:
* One small nit is that cflags are not output as part of the --libs call, so you can remove them from the list on line 5 of the comment. They aren't really relevant to this comment/essay.Yes, I will remove Cflags.
Quoted 5 lines
* I find the link-order summary to actually be more confusing than helpful. I think the text block is explanatory enough. It just confuses things introducing the extra details of what goes in the requires-private or libs-private of the libdpdk.pc file. That's just regular stuff, unrelated to the changes or to DPDK special-case of needing private libs first.
Quoted 6 lines
The intent of this summary was to help navigating for future changes in this area.
Personnaly it helps me, but it is maybe more a developer note that can be deduced from the rest.
I can remove it.
Ok thanks. If you are happy to make these comment changes on apply, please feel free to do so, thanks.
[BTW: I think the shebang line on the new python script needs a "python" changed to "python3" also. I missed that in the latest revision, sorry!]
Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
01/07/2020 17:45, Bruce Richardson:
Quoted 103 lines · Thomas Monjalon
Quoted 96 lines
01/07/2020 17:16, Bruce Richardson:
Quoted 79 lines · Thomas Monjalon
Quoted 74 lines
30/06/2020 16:14, Bruce Richardson:
Quoted 2 lines
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from libraries.private field,
s/libraries.private/Libs.private/
Quoted 9 lines
since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the libraries.private field rather than before.
s/libraries.private/Libs.private/
Quoted 16 lines
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args · line 22
Quoted 9 lines
buildtools/pkg-config/meson.build +9
-0+# When calling pkg-config --static --libs, pkg-config will always output the +# regular libs first, and then the extra libs from libraries.private field, +# since the assumption is that those are additional dependencies for building +# statically that the .a files depend upon. However, for DPDK, we only link +# the driver files for static builds, and those need to come *before* the +# regular libraries. To get this result, we need two pkgconfig files for DPDK, +# one for the shared libs, and a second for the static libs and drivers, which +# depends upon the first. Using a dependency means that the shared libs are +# printed only after the libraries.private field rather than before.This is not obvious. In order to avoid messing it up in future, I suggest this longer reword:
# When calling pkg-config --static --libs, pkg-config will always output the
# regular libs first, and then the extra libs from Libs.private field, # since the assumption is that those are additional dependencies for building # statically that the .a files depend upon. The output order of .pc fields is: # Cflags Libs Libs.private Requires Requires.private # The fields Requires* are for package names. # The flags of the DPDK libraries must be defined in Libs* fields. # However, the DPDK drivers are linked only in static builds (Libs.private), # and those need to come *before* the regular libraries (Libs field). # This requirement is satisfied by moving the regular libs in a separate file # included in the field Requires (after Libs.private). # Another requirement is to allow linking dependencies as shared libraries, # while linking static DPDK libraries and drivers. It is satisfied by # listing the static files in Libs.private with the explicit syntax -l:libfoo.a. # As a consequence, the regular DPDK libraries are already listed as static # in the field Libs.private. The second occurences of DPDK libraries, # included from Requires and used for shared library linkage case, # are skipped in the case of static linkage thanks to the flag --as-needed.# Link order summary:
# libdpdk.Libs.private: whole-archive(static drivers/libs), drivers deps flags # libdpdk.Requires: libdpdk-libs package # libdpdk-libs.Libs: as-needed(shared libs) # libdpdk-libs.Libs.private: libs deps flags # libdpdk.pc.Requires.private: deps packagesQuoted 3 lines
If you agree, I could change this comment while merging. I would add my Signed-off ;)
Quoted 7 lines
This seems generally ok, but probably should just be added as part of patch #7 when all parts of the above have been applied.
Couple of comments:
* One small nit is that cflags are not output as part of the --libs call, so you can remove them from the list on line 5 of the comment. They aren't really relevant to this comment/essay.Yes, I will remove Cflags.
Quoted 5 lines
* I find the link-order summary to actually be more confusing than helpful. I think the text block is explanatory enough. It just confuses things introducing the extra details of what goes in the requires-private or libs-private of the libdpdk.pc file. That's just regular stuff, unrelated to the changes or to DPDK special-case of needing private libs first.
Quoted 6 lines
The intent of this summary was to help navigating for future changes in this area.
Personnaly it helps me, but it is maybe more a developer note that can be deduced from the rest.
I can remove it.
Quoted 5 lines
Ok thanks. If you are happy to make these comment changes on apply, please feel free to do so, thanks.
[BTW: I think the shebang line on the new python script needs a "python" changed to "python3" also. I missed that in the latest revision, sorry!]
OK will do.
PATCH v3 6/7 build/pkg-config: improve static linking flags
In reply to Bruce RichardsonRather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
--- buildtools/pkg-config/meson.build | 13 ++++--- .../pkg-config/set-static-linker-flags.py | 38 +++++++++++++++++++ doc/guides/prog_guide/build-sdk-meson.rst | 2 +- examples/bbdev_app/Makefile | 2 +- examples/bond/Makefile | 2 +- examples/cmdline/Makefile | 2 +- examples/distributor/Makefile | 2 +- examples/eventdev_pipeline/Makefile | 2 +- examples/fips_validation/Makefile | 2 +- examples/flow_classify/Makefile | 2 +- examples/flow_filtering/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/ioat/Makefile | 2 +- examples/ip_fragmentation/Makefile | 2 +- examples/ip_pipeline/Makefile | 2 +- examples/ip_reassembly/Makefile | 2 +- examples/ipsec-secgw/Makefile | 2 +- examples/ipv4_multicast/Makefile | 2 +- examples/kni/Makefile | 2 +- examples/l2fwd-cat/Makefile | 2 +- examples/l2fwd-crypto/Makefile | 2 +- examples/l2fwd-event/Makefile | 2 +- examples/l2fwd-jobstats/Makefile | 2 +- examples/l2fwd-keepalive/Makefile | 2 +- examples/l2fwd/Makefile | 2 +- examples/l3fwd-acl/Makefile | 2 +- examples/l3fwd-power/Makefile | 2 +- examples/l3fwd/Makefile | 2 +- examples/link_status_interrupt/Makefile | 2 +- examples/ntb/Makefile | 2 +- examples/packet_ordering/Makefile | 2 +- examples/ptpclient/Makefile | 2 +- examples/qos_meter/Makefile | 2 +- examples/qos_sched/Makefile | 2 +- examples/rxtx_callbacks/Makefile | 2 +- examples/service_cores/Makefile | 2 +- examples/skeleton/Makefile | 2 +- examples/tep_termination/Makefile | 2 +- examples/timer/Makefile | 2 +- examples/vdpa/Makefile | 2 +- examples/vhost/Makefile | 2 +- examples/vhost_blk/Makefile | 2 +- examples/vhost_crypto/Makefile | 2 +- examples/vmdq/Makefile | 2 +- examples/vmdq_dcb/Makefile | 2 +- 45 files changed, 88 insertions(+), 49 deletions(-) create mode 100644 buildtools/pkg-config/set-static-linker-flags.py
buildtools/pkg-config/meson.build +7 -6
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation -# for static builds, include the drivers as libs and we need to "whole-archive" -# them. -dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] - pkg = import('pkgconfig') pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args if is_freebsd
@@ -38,6 +34,11 @@ Note that CFLAGS might contain an -march flag higher than typical baseline. This is required for a number of static inline functions in the public headers.''', requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs # if libbsd is not enabled, then this is blank - libraries_private: dpdk_drivers + dpdk_static_libraries + - ['-Wl,-Bdynamic'] + libraries_private: ['-Wl,--whole-archive'] + + dpdk_drivers + dpdk_static_libraries + + ['-Wl,--no-whole-archive'] ) + +# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)
buildtools/pkg-config/set-static-linker-flags.py new file +38 -0
@@ -0,0 +1,38 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +# Script to fix flags for static linking in pkgconfig files from meson +# Should be called from meson build itself +import os +import sys + + +def fix_ldflag(f): + if not f.startswith('-lrte_'): + return f + return '-l:lib' + f[2:] + '.a' + + +def fix_libs_private(line): + if not line.startswith('Libs.private'): + return line + ldflags = [fix_ldflag(flag) for flag in line.split()] + return ' '.join(ldflags) + '\n' + + +def process_pc_file(filepath): + print('Processing', filepath) + with open(filepath) as src: + lines = src.readlines() + with open(filepath, 'w') as dst: + dst.writelines([fix_libs_private(line) for line in lines]) + + +if 'MESON_BUILD_ROOT' not in os.environ: + print('This script must be called from a meson build environment') + sys.exit(1) +for root, dirs, files in os.walk(os.environ['MESON_BUILD_ROOT']): + pc_files = [f for f in files if f.endswith('.pc')] + for f in pc_files: + process_pc_file(os.path.join(root, f))
doc/guides/prog_guide/build-sdk-meson.rst +1 -1
@@ -191,7 +191,7 @@ From examples/helloworld/Makefile:: PC_FILE := $(shell pkg-config --path libdpdk) CFLAGS += -O3 $(shell pkg-config --cflags libdpdk) LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk) - LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk) + LDFLAGS_STATIC = $(shell pkg-config --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/bbdev_app/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/bond/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/cmdline/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/distributor/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/eventdev_pipeline/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/fips_validation/Makefile +1 -1
@@ -32,7 +32,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/flow_classify/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/flow_filtering/Makefile +1 -1
@@ -20,7 +20,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/helloworld/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ioat/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ip_fragmentation/Makefile +1 -1
@@ -24,7 +24,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ip_pipeline/Makefile +1 -1
@@ -35,7 +35,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -I.
examples/ip_reassembly/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ipsec-secgw/Makefile +1 -1
@@ -36,7 +36,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/ipv4_multicast/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/kni/Makefile +1 -1
@@ -23,7 +23,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-cat/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) LDFLAGS += -lpqos
examples/l2fwd-crypto/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-event/Makefile +1 -1
@@ -28,7 +28,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-jobstats/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd-keepalive/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l2fwd/Makefile +1 -1
@@ -24,7 +24,7 @@ CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) # Add flag to allow experimental API as l2fwd uses rte_ethdev_set_ptype API CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l3fwd-acl/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/l3fwd-power/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/l3fwd/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/link_status_interrupt/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ntb/Makefile +1 -1
@@ -27,7 +27,7 @@ PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/packet_ordering/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/ptpclient/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/qos_meter/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/qos_sched/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/rxtx_callbacks/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/service_cores/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/skeleton/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/tep_termination/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -Wno-deprecated-declarations
examples/timer/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vdpa/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vhost/Makefile +1 -1
@@ -24,7 +24,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/vhost_blk/Makefile +1 -1
@@ -25,7 +25,7 @@ LDFLAGS += -pthread PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) CFLAGS += -DALLOW_EXPERIMENTAL_API
examples/vhost_crypto/Makefile +1 -1
@@ -23,7 +23,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vmdq/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
examples/vmdq_dcb/Makefile +1 -1
@@ -22,7 +22,7 @@ PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
30/06/2020 16:14, Bruce Richardson:
Quoted 16 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build Note that CFLAGS might contain an -march flag higher than typical baseline. · line 44
Quoted 3 lines
buildtools/pkg-config/meson.build +3
-0+# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)
The comment could be made more precise:
# For static linking with dependencies as shared libraries,
# the static libraries must be flagged explicitly.
For the rest,
Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
01/07/2020 16:30, Thomas Monjalon:
Quoted 23 lines
30/06/2020 16:14, Bruce Richardson:
Quoted 16 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build Note that CFLAGS might contain an -march flag higher than typical baseline. · line 44
Quoted 3 lines
buildtools/pkg-config/meson.build +3
-0+# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)The comment could be made more precise:
# For static linking with dependencies as shared libraries,
Quoted 1 line
# the static libraries must be flagged explicitly.
Even better:
Quoted 2 lines
# For static linking with dependencies as shared libraries,
# the internal static libraries must be flagged explicitly.
Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
Quoted 26 lines · Thomas Monjalon
01/07/2020 16:30, Thomas Monjalon:
Quoted 23 lines
30/06/2020 16:14, Bruce Richardson:
Quoted 16 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build Note that CFLAGS might contain an -march flag higher than typical baseline. · line 44
Quoted 3 lines
buildtools/pkg-config/meson.build +3
-0+# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)The comment could be made more precise:
# For static linking with dependencies as shared libraries,Quoted 1 line
# the static libraries must be flagged explicitly.
Quoted 5 lines
Even better:
Quoted 2 lines
# For static linking with dependencies as shared libraries,
# the internal static libraries must be flagged explicitly.
Should "dependencies" be clarified as "external" or "non-DPDK" dependencies?
/Bruce
Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
01/07/2020 16:36, Bruce Richardson:
Quoted 27 lines · Thomas Monjalon
Quoted 26 lines
01/07/2020 16:30, Thomas Monjalon:
Quoted 24 lines
30/06/2020 16:14, Bruce Richardson:
Quoted 16 lines
Rather than setting -Bstatic in the linker flags when doing a static link, and then having to explicitly set -Bdynamic again afterwards, we can update the pkg-config file to use -l:libfoo.a syntax to explicitly refer to the static library in question. Since this syntax is not supported by meson's pkg-config module directly, we can post-process the .pc files instead to adjust them.
Once done, we can simplify the examples' makefiles and the docs by removing the explicit static flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Luca Boccassi <[email protected]>Acked-by Sunil Pai G <[email protected]>---
buildtools/pkg-config/meson.build Note that CFLAGS might contain an -march flag higher than typical baseline. · line 44
Quoted 3 lines
buildtools/pkg-config/meson.build +3
-0+# the pkg-config file generated is not best tuned for static linking so +# use a script to adjust the linker flags +run_command(py3, 'set-static-linker-flags.py', check: true)The comment could be made more precise:
# For static linking with dependencies as shared libraries,# the static libraries must be flagged explicitly.
Quoted 7 lines
Quoted 5 lines
Even better:
Quoted 2 lines
# For static linking with dependencies as shared libraries,
# the internal static libraries must be flagged explicitly.Should "dependencies" be clarified as "external" or "non-DPDK" dependencies?
Yes:
# For static linking with external dependencies as shared libraries,
# the internal static libraries must be flagged explicitly.
PATCH v3 7/7 build/pkg-config: prevent overlinking
In reply to Bruce RichardsonAdd the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
The real root-cause of this issue is that the DPDK libraries need to be duplicated in the linker command when doing static linking, due to the behaviour of pkg-config, but since that behaviour cannot be easily changed, this is a simple workaround to avoid problems.
--- buildtools/pkg-config/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
buildtools/pkg-config/meson.build +1 -1
@@ -23,7 +23,7 @@ Use libdpdk.pc instead of this file to query DPDK compile/link arguments''', version: meson.project_version(), subdirs: [get_option('include_subdir_arch'), '.'], extra_cflags: pkg_extra_cflags, - libraries: dpdk_libraries, + libraries: ['-Wl,--as-needed'] + dpdk_libraries, libraries_private: dpdk_extra_ldflags) pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking
30/06/2020 16:14, Bruce Richardson:
Quoted 10 lines
Add the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
The real root-cause of this issue is that the DPDK libraries need to be duplicated in the linker command when doing static linking, due to the behaviour of pkg-config, but since that behaviour cannot be easily changed, this is a simple workaround to avoid problems.
It deserves to give a more detailed explanation here.
Re: [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking
Quoted 7 lines · Thomas Monjalon
30/06/2020 16:14, Bruce Richardson:
Quoted 6 lines
Add the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
Quoted 7 lines
Quoted 4 lines
The real root-cause of this issue is that the DPDK libraries need to be duplicated in the linker command when doing static linking, due to the behaviour of pkg-config, but since that behaviour cannot be easily changed, this is a simple workaround to avoid problems.
It deserves to give a more detailed explanation here.
It's already explained in commit log for patch 5 and in the code comments added in patch 5 also, so I didn't think it was necessary again. However can add in a V4, if needed.
/Bruce
30/06/2020 16:14, Bruce Richardson:
Quoted 15 lines
This set fixes a number of minor issues with static builds when using meson, both for linking apps/examples as part of a meson build itself or when using pkg-config subsequently.
Following this patchset, all DPDK static builds should be linking with --whole-archive to ensure all lib and driver constructors are included, and the use of pkg-config for doing static builds is simplified. The downside is that for correctness we need two .pc files for DPDK rather than just one.
v3: rebased to latest on main branch
v2: improved log messages for a number of patches, and clearly marked
internal-only pkg-config file as such
Quoted 8 lines
Bruce Richardson (7):
build: always link-whole DPDK static libraries
build: remove unnecessary variabledevtools/test-meson-builds.sh: add pkg-config static builds
build: move pkg-config creation to separate file build/pkg-config: output driver libs first for static build build/pkg-config: improve static linking flags build/pkg-config: prevent overlinking
Applied with changes discussed in the thread, thanks