DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson
@ 2020-04-29 10:08 Bruce Richardson
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries Bruce Richardson
                   ` (8 more replies)
  0 siblings, 9 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, 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.

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

-- 
2.20.1


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

* [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:18   ` Thomas Monjalon
  2020-04-29 14:04   ` Andrzej Ostruszka [C]
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable Bruce Richardson
                   ` (7 subsequent siblings)
  8 siblings, 2 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

To ensure all constructors are included in static build, we need to pass
the --whole-archive flag when linking, which is used with the
"link_whole" meson option. Since we use link_whole for all libs, we no
longer need to track the lib as part of the static dependency, just the
path to the headers for compiling.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test/meson.build | 2 +-
 drivers/meson.build  | 2 +-
 examples/meson.build | 6 +++---
 lib/meson.build      | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index fc60acbe7..5f2c803d6 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -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',
diff --git a/drivers/meson.build b/drivers/meson.build
index dc293b270..53c2ff0f3 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -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)
 
diff --git a/examples/meson.build b/examples/meson.build
index 1f2b6f516..ec6bd5a08 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -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)
diff --git a/lib/meson.build b/lib/meson.build
index 07a65a625..44b850033 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -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)
 
-- 
2.20.1


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

* [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:19   ` Thomas Monjalon
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build                  | 2 +-
 lib/librte_telemetry/meson.build | 1 -
 meson.build                      | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 0f7fe9464..25f2da82e 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -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)
 
diff --git a/lib/librte_telemetry/meson.build b/lib/librte_telemetry/meson.build
index 1bdf128c1..c6e8cc5de 100644
--- a/lib/librte_telemetry/meson.build
+++ b/lib/librte_telemetry/meson.build
@@ -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"'
diff --git a/meson.build b/meson.build
index d36580438..d8504afbf 100644
--- a/meson.build
+++ b/meson.build
@@ -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')
-- 
2.20.1


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

* [dpdk-dev] [PATCH 3/7] devtools/test-meson-builds.sh: add pkg-config static builds
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries Bruce Richardson
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 4/7] build: move pkg-config creation to separate file Bruce Richardson
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

The 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 devtools/test-meson-builds.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index e8df01759..132b801e6 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -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
-- 
2.20.1


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

* [dpdk-dev] [PATCH 4/7] build: move pkg-config creation to separate file
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
                   ` (2 preceding siblings ...)
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

Ahead 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/pkg-config/meson.build | 26 ++++++++++++++++++++++++++
 meson.build                       | 25 ++-----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)
 create mode 100644 buildtools/pkg-config/meson.build

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
new file mode 100644
index 000000000..85d59972d
--- /dev/null
+++ b/buildtools/pkg-config/meson.build
@@ -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
+)
diff --git a/meson.build b/meson.build
index d8504afbf..5e46ebd8d 100644
--- a/meson.build
+++ b/meson.build
@@ -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.
-- 
2.20.1


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

* [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
                   ` (3 preceding siblings ...)
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 4/7] build: move pkg-config creation to separate file Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:30   ` Thomas Monjalon
  2020-04-29 10:40   ` Luca Boccassi
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags Bruce Richardson
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/pkg-config/meson.build | 32 +++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index 85d59972d..f08ca54ed 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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']
 )
-- 
2.20.1


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

* [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
                   ` (4 preceding siblings ...)
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:32   ` Thomas Monjalon
  2020-04-29 10:37   ` Luca Boccassi
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking Bruce Richardson
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 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

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index f08ca54ed..bc723317c 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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)
diff --git a/buildtools/pkg-config/set-static-linker-flags.py b/buildtools/pkg-config/set-static-linker-flags.py
new file mode 100644
index 000000000..516c3678b
--- /dev/null
+++ b/buildtools/pkg-config/set-static-linker-flags.py
@@ -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))
diff --git a/doc/guides/prog_guide/build-sdk-meson.rst b/doc/guides/prog_guide/build-sdk-meson.rst
index 7679c049a..44d1cafdf 100644
--- a/doc/guides/prog_guide/build-sdk-meson.rst
+++ b/doc/guides/prog_guide/build-sdk-meson.rst
@@ -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)
diff --git a/examples/bbdev_app/Makefile b/examples/bbdev_app/Makefile
index ead3f016b..3c8eb75a4 100644
--- a/examples/bbdev_app/Makefile
+++ b/examples/bbdev_app/Makefile
@@ -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
 
diff --git a/examples/bond/Makefile b/examples/bond/Makefile
index 2030ca410..4e4289e15 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -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
 
diff --git a/examples/cmdline/Makefile b/examples/cmdline/Makefile
index 9a33355d0..732509772 100644
--- a/examples/cmdline/Makefile
+++ b/examples/cmdline/Makefile
@@ -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)
diff --git a/examples/distributor/Makefile b/examples/distributor/Makefile
index 63c14dfca..6e3fef981 100644
--- a/examples/distributor/Makefile
+++ b/examples/distributor/Makefile
@@ -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)
diff --git a/examples/eventdev_pipeline/Makefile b/examples/eventdev_pipeline/Makefile
index 96cd24437..95a8d0884 100644
--- a/examples/eventdev_pipeline/Makefile
+++ b/examples/eventdev_pipeline/Makefile
@@ -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)
diff --git a/examples/fips_validation/Makefile b/examples/fips_validation/Makefile
index c207d11b9..b44ca2ee6 100644
--- a/examples/fips_validation/Makefile
+++ b/examples/fips_validation/Makefile
@@ -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)
diff --git a/examples/flow_classify/Makefile b/examples/flow_classify/Makefile
index 6864941b3..161d576b6 100644
--- a/examples/flow_classify/Makefile
+++ b/examples/flow_classify/Makefile
@@ -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
 
diff --git a/examples/flow_filtering/Makefile b/examples/flow_filtering/Makefile
index e0d546de9..010a1383e 100644
--- a/examples/flow_filtering/Makefile
+++ b/examples/flow_filtering/Makefile
@@ -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)
diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile
index 0f5af0806..94a1074cf 100644
--- a/examples/helloworld/Makefile
+++ b/examples/helloworld/Makefile
@@ -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)
diff --git a/examples/ioat/Makefile b/examples/ioat/Makefile
index 9b277eb7b..86308854e 100644
--- a/examples/ioat/Makefile
+++ b/examples/ioat/Makefile
@@ -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)
diff --git a/examples/ip_fragmentation/Makefile b/examples/ip_fragmentation/Makefile
index 8babbbf82..3f4db3f59 100644
--- a/examples/ip_fragmentation/Makefile
+++ b/examples/ip_fragmentation/Makefile
@@ -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)
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 3a0193818..1116bb6c1 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -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.
 
diff --git a/examples/ip_reassembly/Makefile b/examples/ip_reassembly/Makefile
index 11be2a74a..be9e541bd 100644
--- a/examples/ip_reassembly/Makefile
+++ b/examples/ip_reassembly/Makefile
@@ -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)
diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefile
index c4a272a30..ab15fca9e 100644
--- a/examples/ipsec-secgw/Makefile
+++ b/examples/ipsec-secgw/Makefile
@@ -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
 
diff --git a/examples/ipv4_multicast/Makefile b/examples/ipv4_multicast/Makefile
index b9f0813ed..0ed78c1cc 100644
--- a/examples/ipv4_multicast/Makefile
+++ b/examples/ipv4_multicast/Makefile
@@ -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)
diff --git a/examples/kni/Makefile b/examples/kni/Makefile
index c7ca96d8a..8fcb67c61 100644
--- a/examples/kni/Makefile
+++ b/examples/kni/Makefile
@@ -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)
diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
index ca1202be1..d767a10d7 100644
--- a/examples/l2fwd-cat/Makefile
+++ b/examples/l2fwd-cat/Makefile
@@ -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
 
diff --git a/examples/l2fwd-crypto/Makefile b/examples/l2fwd-crypto/Makefile
index 2f1405a72..cdbb91a1e 100644
--- a/examples/l2fwd-crypto/Makefile
+++ b/examples/l2fwd-crypto/Makefile
@@ -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)
diff --git a/examples/l2fwd-event/Makefile b/examples/l2fwd-event/Makefile
index 807f7f1b8..ddee388ae 100644
--- a/examples/l2fwd-event/Makefile
+++ b/examples/l2fwd-event/Makefile
@@ -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)
diff --git a/examples/l2fwd-jobstats/Makefile b/examples/l2fwd-jobstats/Makefile
index 6cd9dcd9c..bdb83c3e1 100644
--- a/examples/l2fwd-jobstats/Makefile
+++ b/examples/l2fwd-jobstats/Makefile
@@ -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)
diff --git a/examples/l2fwd-keepalive/Makefile b/examples/l2fwd-keepalive/Makefile
index 0db5e6015..9fd9db497 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -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)
diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile
index 8b7b26cb9..15105ac57 100644
--- a/examples/l2fwd/Makefile
+++ b/examples/l2fwd/Makefile
@@ -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)
diff --git a/examples/l3fwd-acl/Makefile b/examples/l3fwd-acl/Makefile
index 9f31abef8..6644a2cf1 100644
--- a/examples/l3fwd-acl/Makefile
+++ b/examples/l3fwd-acl/Makefile
@@ -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)
diff --git a/examples/l3fwd-power/Makefile b/examples/l3fwd-power/Makefile
index 729d49639..74441f98c 100644
--- a/examples/l3fwd-power/Makefile
+++ b/examples/l3fwd-power/Makefile
@@ -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
 
diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 839439f0f..b25a51581 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -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)
diff --git a/examples/link_status_interrupt/Makefile b/examples/link_status_interrupt/Makefile
index 613bb1167..f16916faa 100644
--- a/examples/link_status_interrupt/Makefile
+++ b/examples/link_status_interrupt/Makefile
@@ -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)
diff --git a/examples/ntb/Makefile b/examples/ntb/Makefile
index f2920ed54..81ec6017f 100644
--- a/examples/ntb/Makefile
+++ b/examples/ntb/Makefile
@@ -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)
diff --git a/examples/packet_ordering/Makefile b/examples/packet_ordering/Makefile
index f5b68c97e..f99b69dc2 100644
--- a/examples/packet_ordering/Makefile
+++ b/examples/packet_ordering/Makefile
@@ -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)
diff --git a/examples/ptpclient/Makefile b/examples/ptpclient/Makefile
index 7cd36632a..a9555fc66 100644
--- a/examples/ptpclient/Makefile
+++ b/examples/ptpclient/Makefile
@@ -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)
diff --git a/examples/qos_meter/Makefile b/examples/qos_meter/Makefile
index 90e3533d1..165e07ee2 100644
--- a/examples/qos_meter/Makefile
+++ b/examples/qos_meter/Makefile
@@ -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
 
diff --git a/examples/qos_sched/Makefile b/examples/qos_sched/Makefile
index 92e3de79b..0dd7d9105 100644
--- a/examples/qos_sched/Makefile
+++ b/examples/qos_sched/Makefile
@@ -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)
diff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile
index 584b9fafb..10e5f14d5 100644
--- a/examples/rxtx_callbacks/Makefile
+++ b/examples/rxtx_callbacks/Makefile
@@ -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)
diff --git a/examples/service_cores/Makefile b/examples/service_cores/Makefile
index aac207bd9..e742d88f6 100644
--- a/examples/service_cores/Makefile
+++ b/examples/service_cores/Makefile
@@ -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)
diff --git a/examples/skeleton/Makefile b/examples/skeleton/Makefile
index 2612688c0..5f5acf715 100644
--- a/examples/skeleton/Makefile
+++ b/examples/skeleton/Makefile
@@ -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)
diff --git a/examples/tep_termination/Makefile b/examples/tep_termination/Makefile
index 645112498..548ca3cee 100644
--- a/examples/tep_termination/Makefile
+++ b/examples/tep_termination/Makefile
@@ -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
 
diff --git a/examples/timer/Makefile b/examples/timer/Makefile
index e58e90a28..b40b65995 100644
--- a/examples/timer/Makefile
+++ b/examples/timer/Makefile
@@ -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)
diff --git a/examples/vdpa/Makefile b/examples/vdpa/Makefile
index 6a25497cd..bc0b6793e 100644
--- a/examples/vdpa/Makefile
+++ b/examples/vdpa/Makefile
@@ -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)
diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index f2b161541..ef6f3550f 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -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
 
diff --git a/examples/vhost_blk/Makefile b/examples/vhost_blk/Makefile
index 39244320d..395279178 100644
--- a/examples/vhost_blk/Makefile
+++ b/examples/vhost_blk/Makefile
@@ -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
 
diff --git a/examples/vhost_crypto/Makefile b/examples/vhost_crypto/Makefile
index ae8cb81f8..28e3e4de7 100644
--- a/examples/vhost_crypto/Makefile
+++ b/examples/vhost_crypto/Makefile
@@ -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)
diff --git a/examples/vmdq/Makefile b/examples/vmdq/Makefile
index 98e644fa7..b73373d3f 100644
--- a/examples/vmdq/Makefile
+++ b/examples/vmdq/Makefile
@@ -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)
diff --git a/examples/vmdq_dcb/Makefile b/examples/vmdq_dcb/Makefile
index 3eb7c9f43..8d8baf729 100644
--- a/examples/vmdq_dcb/Makefile
+++ b/examples/vmdq_dcb/Makefile
@@ -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)
-- 
2.20.1


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

* [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
                   ` (5 preceding siblings ...)
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags Bruce Richardson
@ 2020-04-29 10:08 ` Bruce Richardson
  2020-04-29 10:34   ` Thomas Monjalon
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
  8 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:08 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/pkg-config/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index bc723317c..07b556288 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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
-- 
2.20.1


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

* Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries Bruce Richardson
@ 2020-04-29 10:18   ` Thomas Monjalon
  2020-04-29 10:42     ` Bruce Richardson
  2020-04-29 14:04   ` Andrzej Ostruszka [C]
  1 sibling, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:18 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor, bingz

29/04/2020 12:08, Bruce Richardson:
> To ensure all constructors are included in static build, we need to pass
> the --whole-archive flag when linking, which is used with the
> "link_whole" meson option. Since we use link_whole for all libs, we no
> longer need to track the lib as part of the static dependency, just the
> path to the headers for compiling.

Please could you add the generated command line before/after?

I would like to make sure that the external dependencies are out of
the whole-archive option.

Thanks



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

* Re: [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable Bruce Richardson
@ 2020-04-29 10:19   ` Thomas Monjalon
  2020-04-29 10:29     ` Bruce Richardson
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:19 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor

29/04/2020 12:08, Bruce Richardson:
> 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.




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

* Re: [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable
  2020-04-29 10:19   ` Thomas Monjalon
@ 2020-04-29 10:29     ` Bruce Richardson
  0 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:29 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, bluca, david.marchand, ktraynor

O Wed, Apr 29, 2020 at 12:19:38PM +0200, Thomas Monjalon wrote:
> 29/04/2020 12:08, Bruce Richardson:
> > 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

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

* Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
@ 2020-04-29 10:30   ` Thomas Monjalon
  2020-04-29 10:54     ` Bruce Richardson
  2020-04-29 10:40   ` Luca Boccassi
  1 sibling, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:30 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor

29/04/2020 12:08, 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.

Please could you add the error here?

> 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



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

* Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags Bruce Richardson
@ 2020-04-29 10:32   ` Thomas Monjalon
  2020-04-29 10:56     ` Bruce Richardson
  2020-04-29 10:37   ` Luca Boccassi
  1 sibling, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:32 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor

29/04/2020 12:08, 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.

It looks to be the same workaround I did for ibverbs static linkage :)
	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a,"




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

* Re: [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking Bruce Richardson
@ 2020-04-29 10:34   ` Thomas Monjalon
  2020-04-29 11:00     ` Bruce Richardson
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:34 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor

29/04/2020 12:08, Bruce Richardson:
> 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?




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

* Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags Bruce Richardson
  2020-04-29 10:32   ` Thomas Monjalon
@ 2020-04-29 10:37   ` Luca Boccassi
  2020-04-29 10:58     ` Bruce Richardson
  1 sibling, 1 reply; 63+ messages in thread
From: Luca Boccassi @ 2020-04-29 10:37 UTC (permalink / raw)
  To: Bruce Richardson, dev; +Cc: thomas, david.marchand, ktraynor

On Wed, 2020-04-29 at 11:08 +0100, Bruce Richardson wrote:
> 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?

-- 
Kind regards,
Luca Boccassi

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

* Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
  2020-04-29 10:30   ` Thomas Monjalon
@ 2020-04-29 10:40   ` Luca Boccassi
  2020-04-29 11:03     ` Bruce Richardson
  1 sibling, 1 reply; 63+ messages in thread
From: Luca Boccassi @ 2020-04-29 10:40 UTC (permalink / raw)
  To: Bruce Richardson, dev; +Cc: thomas, david.marchand, ktraynor

On Wed, 2020-04-29 at 11:08 +0100, Bruce Richardson wrote:
> 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

-- 
Kind regards,
Luca Boccassi

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

* Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
  2020-04-29 10:18   ` Thomas Monjalon
@ 2020-04-29 10:42     ` Bruce Richardson
  2020-04-29 10:49       ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:42 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, bluca, david.marchand, ktraynor, bingz

On Wed, Apr 29, 2020 at 12:18:19PM +0200, Thomas Monjalon wrote:
> 29/04/2020 12:08, Bruce Richardson:
> > To ensure all constructors are included in static build, we need to pass
> > the --whole-archive flag when linking, which is used with the
> > "link_whole" meson option. Since we use link_whole for all libs, we no
> > longer need to track the lib as part of the static dependency, just the
> > path to the headers for compiling.
> 
> Please could you add the generated command line before/after?
> 
> I would like to make sure that the external dependencies are out of
> the whole-archive option.
> 
> Thanks
> 
Sure,

the link args for the helloworld example from build.ninja are now (snipping
out some .a's from the middle for brevity):

 LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
-Wl,--start-group lib/librte_telemetry.a lib/librte_bpf.a
lib/librte_flow_classify.a lib/librte_pipeline.a lib/librte_table.a
lib/librte_port.a lib/librte_fib.a lib/librte_ipsec.a lib/librte_vhost.a
lib/librte_stack.a lib/librte_security.a lib/librte_sched.a
lib/librte_reorder.a lib/librte_rib.a lib/librte_rawdev.a
lib/librte_pdump.a lib/librte_power.a lib/librte_member.a lib/librte_lpm.a
lib/librte_latencystats.a lib/librte_kni.a lib/librte_jobstats.a
lib/librte_ip_frag.a lib/librte_gso.a lib/librte_gro.a
  <snip> 
drivers/librte_pmd_mlx5_vdpa.a drivers/librte_pmd_bbdev_null.a
drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
-Wl,--no-as-needed -pthread -lm -ldl -lnuma -lpcap
/usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libjansson.so
/usr/lib/x86_64-linux-gnu/libelf.so -lpcap -lpcap -lpcap -lpcap
/usr/lib/x86_64-linux-gnu/libmlx5.so
/usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
/usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -Wl,--end-group

The before case is below (again snipping some drivers):

 LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
-Wl,--start-group drivers/librte_common_cpt.a drivers/librte_common_dpaax.a
drivers/librte_common_iavf.a drivers/librte_common_mlx5.a
drivers/librte_common_octeontx.a drivers/librte_common_octeontx2.a
drivers/librte_bus_dpaa.a drivers/librte_bus_fslmc.a
drivers/librte_bus_ifpga.a drivers/librte_bus_pci.a
  <snip>
drivers/librte_pmd_octeontx_event.a drivers/librte_pmd_bbdev_null.a
drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
-Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_eal.a
lib/librte_kvargs.a lib/librte_mempool.a lib/librte_ring.a lib/librte_net.a
lib/librte_mbuf.a lib/librte_ethdev.a lib/librte_meter.a
lib/librte_cmdline.a lib/librte_pci.a lib/librte_cryptodev.a
lib/librte_hash.a lib/librte_eventdev.a lib/librte_timer.a
lib/librte_rawdev.a lib/librte_stack.a lib/librte_sched.a
lib/librte_ip_frag.a lib/librte_security.a lib/librte_kni.a
lib/librte_pipeline.a lib/librte_port.a lib/librte_table.a lib/librte_lpm.a
lib/librte_acl.a lib/librte_gso.a lib/librte_vhost.a lib/librte_reorder.a
lib/librte_compressdev.a lib/librte_bbdev.a -lpcap
/usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libmlx5.so
/usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
/usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -lpcap -lpcap -lpcap
-lIPSec_MB -lIPSec_MB /usr/lib/x86_64-linux-gnu/libcrypto.so
/usr/lib/x86_64-linux-gnu/libisal.so -Wl,--end-group
'-Wl,-rpath,$$ORIGIN/../lib' -Wl,-rpath-link,/home/bruce/dpdk.org/build/lib

These both come from builds with meson 0.54. I can also check that things
look the same for 0.47 too.

/Bruce

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

* Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
  2020-04-29 10:42     ` Bruce Richardson
@ 2020-04-29 10:49       ` Thomas Monjalon
  0 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:49 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor, bingz

29/04/2020 12:42, Bruce Richardson:
> On Wed, Apr 29, 2020 at 12:18:19PM +0200, Thomas Monjalon wrote:
> > 29/04/2020 12:08, Bruce Richardson:
> > > To ensure all constructors are included in static build, we need to pass
> > > the --whole-archive flag when linking, which is used with the
> > > "link_whole" meson option. Since we use link_whole for all libs, we no
> > > longer need to track the lib as part of the static dependency, just the
> > > path to the headers for compiling.
> > 
> > Please could you add the generated command line before/after?
> > 
> > I would like to make sure that the external dependencies are out of
> > the whole-archive option.
> > 
> > Thanks
> > 
> Sure,
> 
> the link args for the helloworld example from build.ninja are now (snipping
> out some .a's from the middle for brevity):
> 
>  LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
> -Wl,--start-group lib/librte_telemetry.a lib/librte_bpf.a
> lib/librte_flow_classify.a lib/librte_pipeline.a lib/librte_table.a
> lib/librte_port.a lib/librte_fib.a lib/librte_ipsec.a lib/librte_vhost.a
> lib/librte_stack.a lib/librte_security.a lib/librte_sched.a
> lib/librte_reorder.a lib/librte_rib.a lib/librte_rawdev.a
> lib/librte_pdump.a lib/librte_power.a lib/librte_member.a lib/librte_lpm.a
> lib/librte_latencystats.a lib/librte_kni.a lib/librte_jobstats.a
> lib/librte_ip_frag.a lib/librte_gso.a lib/librte_gro.a
>   <snip> 
> drivers/librte_pmd_mlx5_vdpa.a drivers/librte_pmd_bbdev_null.a
> drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
> drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
> -Wl,--no-as-needed -pthread -lm -ldl -lnuma -lpcap
> /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libjansson.so
> /usr/lib/x86_64-linux-gnu/libelf.so -lpcap -lpcap -lpcap -lpcap
> /usr/lib/x86_64-linux-gnu/libmlx5.so
> /usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
> /usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -Wl,--end-group
> 
> The before case is below (again snipping some drivers):
> 
>  LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--whole-archive
> -Wl,--start-group drivers/librte_common_cpt.a drivers/librte_common_dpaax.a
> drivers/librte_common_iavf.a drivers/librte_common_mlx5.a
> drivers/librte_common_octeontx.a drivers/librte_common_octeontx2.a
> drivers/librte_bus_dpaa.a drivers/librte_bus_fslmc.a
> drivers/librte_bus_ifpga.a drivers/librte_bus_pci.a
>   <snip>
> drivers/librte_pmd_octeontx_event.a drivers/librte_pmd_bbdev_null.a
> drivers/librte_pmd_bbdev_turbo_sw.a drivers/librte_pmd_bbdev_fpga_lte_fec.a
> drivers/librte_pmd_bbdev_fpga_5gnr_fec.a -Wl,--no-whole-archive
> -Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_eal.a
> lib/librte_kvargs.a lib/librte_mempool.a lib/librte_ring.a lib/librte_net.a
> lib/librte_mbuf.a lib/librte_ethdev.a lib/librte_meter.a
> lib/librte_cmdline.a lib/librte_pci.a lib/librte_cryptodev.a
> lib/librte_hash.a lib/librte_eventdev.a lib/librte_timer.a
> lib/librte_rawdev.a lib/librte_stack.a lib/librte_sched.a
> lib/librte_ip_frag.a lib/librte_security.a lib/librte_kni.a
> lib/librte_pipeline.a lib/librte_port.a lib/librte_table.a lib/librte_lpm.a
> lib/librte_acl.a lib/librte_gso.a lib/librte_vhost.a lib/librte_reorder.a
> lib/librte_compressdev.a lib/librte_bbdev.a -lpcap
> /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libmlx5.so
> /usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/libz.so
> /usr/lib/x86_64-linux-gnu/libmlx4.so -lpcap -lpcap -lpcap -lpcap -lpcap
> -lIPSec_MB -lIPSec_MB /usr/lib/x86_64-linux-gnu/libcrypto.so
> /usr/lib/x86_64-linux-gnu/libisal.so -Wl,--end-group
> '-Wl,-rpath,$$ORIGIN/../lib' -Wl,-rpath-link,/home/bruce/dpdk.org/build/lib
> 
> These both come from builds with meson 0.54. I can also check that things
> look the same for 0.47 too.

That's fine, it looks good.
Please mention that you move DPDK libs inside but external dependencies
are still outside of whole-archive block.

Thanks




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

* Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
  2020-04-29 10:30   ` Thomas Monjalon
@ 2020-04-29 10:54     ` Bruce Richardson
  0 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:54 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, bluca, david.marchand, ktraynor

On Wed, Apr 29, 2020 at 12:30:10PM +0200, Thomas Monjalon wrote:
> 29/04/2020 12:08, 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.
> 
> 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.
 
> > 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.

> 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=native
  
The 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

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

* Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:32   ` Thomas Monjalon
@ 2020-04-29 10:56     ` Bruce Richardson
  2020-04-29 10:57       ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:56 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, bluca, david.marchand, ktraynor

On Wed, Apr 29, 2020 at 12:32:51PM +0200, Thomas Monjalon wrote:
> 29/04/2020 12:08, 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.
> 
> 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? :-)

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

* Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:56     ` Bruce Richardson
@ 2020-04-29 10:57       ` Thomas Monjalon
  0 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2020-04-29 10:57 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, bluca, david.marchand, ktraynor

29/04/2020 12:56, Bruce Richardson:
> On Wed, Apr 29, 2020 at 12:32:51PM +0200, Thomas Monjalon wrote:
> > 29/04/2020 12:08, 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.
> > 
> > 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 :-)



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

* Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:37   ` Luca Boccassi
@ 2020-04-29 10:58     ` Bruce Richardson
  2020-04-29 11:10       ` Luca Boccassi
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 10:58 UTC (permalink / raw)
  To: Luca Boccassi; +Cc: dev, thomas, david.marchand, ktraynor

On Wed, Apr 29, 2020 at 11:37:02AM +0100, Luca Boccassi wrote:
> On Wed, 2020-04-29 at 11:08 +0100, Bruce Richardson wrote:
> > 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?
>
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

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

* Re: [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking
  2020-04-29 10:34   ` Thomas Monjalon
@ 2020-04-29 11:00     ` Bruce Richardson
  0 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 11:00 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, bluca, david.marchand, ktraynor

On Wed, Apr 29, 2020 at 12:34:56PM +0200, Thomas Monjalon wrote:
> 29/04/2020 12:08, Bruce Richardson:
> > 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

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

* Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
  2020-04-29 10:40   ` Luca Boccassi
@ 2020-04-29 11:03     ` Bruce Richardson
  2020-04-29 11:12       ` Luca Boccassi
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-04-29 11:03 UTC (permalink / raw)
  To: Luca Boccassi; +Cc: dev, thomas, david.marchand, ktraynor

On Wed, Apr 29, 2020 at 11:40:33AM +0100, Luca Boccassi wrote:
> On Wed, 2020-04-29 at 11:08 +0100, Bruce Richardson wrote:
> > 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
> 
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?

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

* Re: [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags
  2020-04-29 10:58     ` Bruce Richardson
@ 2020-04-29 11:10       ` Luca Boccassi
  0 siblings, 0 replies; 63+ messages in thread
From: Luca Boccassi @ 2020-04-29 11:10 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, thomas, david.marchand, ktraynor

On Wed, 2020-04-29 at 11:58 +0100, Bruce Richardson wrote:
> On Wed, Apr 29, 2020 at 11:37:02AM +0100, Luca Boccassi wrote:
> > On Wed, 2020-04-29 at 11:08 +0100, Bruce Richardson wrote:
> > > 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?
> > 
> 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

-- 
Kind regards,
Luca Boccassi

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

* Re: [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build
  2020-04-29 11:03     ` Bruce Richardson
@ 2020-04-29 11:12       ` Luca Boccassi
  0 siblings, 0 replies; 63+ messages in thread
From: Luca Boccassi @ 2020-04-29 11:12 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, thomas, david.marchand, ktraynor

On Wed, 2020-04-29 at 12:03 +0100, Bruce Richardson wrote:
> On Wed, Apr 29, 2020 at 11:40:33AM +0100, Luca Boccassi wrote:
> > On Wed, 2020-04-29 at 11:08 +0100, Bruce Richardson wrote:
> > > 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
> > 
> 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

-- 
Kind regards,
Luca Boccassi

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

* Re: [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries Bruce Richardson
  2020-04-29 10:18   ` Thomas Monjalon
@ 2020-04-29 14:04   ` Andrzej Ostruszka [C]
  1 sibling, 0 replies; 63+ messages in thread
From: Andrzej Ostruszka [C] @ 2020-04-29 14:04 UTC (permalink / raw)
  To: dev

On 29/04/2020 12:08, Bruce Richardson wrote:
> To ensure all constructors are included in static build, we need to pass
> the --whole-archive flag when linking, which is used with the
> "link_whole" meson option. Since we use link_whole for all libs, we no
> longer need to track the lib as part of the static dependency, just the
> path to the headers for compiling.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---

Thank you Bruce!

I was just searching for the same.  My problem was that IF Proxy builds 
were crashing on static builds with meson.  It turned out that the 
culprit is that at the end of rte_eth_iterator_init() there is a call:

	iter->cls = rte_class_find_by_name("eth");

which was failing (because constructor registering eth class was not 
being called).

This patch solves this issue.

Tested-by: Andrzej Ostruszka <aostruszka@marvell.com>

With regards
Andrzej Ostruszka

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

* [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
                   ` (6 preceding siblings ...)
  2020-04-29 10:08 ` [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking Bruce Richardson
@ 2020-05-01 13:53 ` Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 1/7] build: always link-whole DPDK static libraries Bruce Richardson
                     ` (8 more replies)
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
  8 siblings, 9 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:53 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, 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 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

-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 1/7] build: always link-whole DPDK static libraries
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
@ 2020-05-01 13:53   ` Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 2/7] build: remove unnecessary variable Bruce Richardson
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:53 UTC (permalink / raw)
  To: dev
  Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson,
	Andrzej Ostruszka

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Andrzej Ostruszka <aostruszka@marvell.com>
---
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(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index fc60acbe7..5f2c803d6 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -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',
diff --git a/drivers/meson.build b/drivers/meson.build
index dc293b270..53c2ff0f3 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -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)
 
diff --git a/examples/meson.build b/examples/meson.build
index 1f2b6f516..ec6bd5a08 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -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)
diff --git a/lib/meson.build b/lib/meson.build
index 07a65a625..44b850033 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -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)
 
-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 2/7] build: remove unnecessary variable
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 1/7] build: always link-whole DPDK static libraries Bruce Richardson
@ 2020-05-01 13:53   ` Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:53 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

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.

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
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(-)

diff --git a/app/meson.build b/app/meson.build
index 0f7fe9464..25f2da82e 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -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)
 
diff --git a/lib/librte_telemetry/meson.build b/lib/librte_telemetry/meson.build
index 1bdf128c1..c6e8cc5de 100644
--- a/lib/librte_telemetry/meson.build
+++ b/lib/librte_telemetry/meson.build
@@ -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"'
diff --git a/meson.build b/meson.build
index d36580438..d8504afbf 100644
--- a/meson.build
+++ b/meson.build
@@ -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')
-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 3/7] devtools/test-meson-builds.sh: add pkg-config static builds
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 1/7] build: always link-whole DPDK static libraries Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 2/7] build: remove unnecessary variable Bruce Richardson
@ 2020-05-01 13:53   ` Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 4/7] build: move pkg-config creation to separate file Bruce Richardson
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:53 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

The 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 devtools/test-meson-builds.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index e8df01759..132b801e6 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -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
-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 4/7] build: move pkg-config creation to separate file
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
                     ` (2 preceding siblings ...)
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
@ 2020-05-01 13:53   ` Bruce Richardson
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:53 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

Ahead 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/pkg-config/meson.build | 26 ++++++++++++++++++++++++++
 meson.build                       | 25 ++-----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)
 create mode 100644 buildtools/pkg-config/meson.build

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
new file mode 100644
index 000000000..85d59972d
--- /dev/null
+++ b/buildtools/pkg-config/meson.build
@@ -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
+)
diff --git a/meson.build b/meson.build
index d8504afbf..5e46ebd8d 100644
--- a/meson.build
+++ b/meson.build
@@ -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.
-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 5/7] build/pkg-config: output driver libs first for static build
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
                     ` (3 preceding siblings ...)
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 4/7] build: move pkg-config creation to separate file Bruce Richardson
@ 2020-05-01 13:53   ` Bruce Richardson
  2020-05-01 13:54   ` [dpdk-dev] [PATCH v2 6/7] build/pkg-config: improve static linking flags Bruce Richardson
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:53 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, 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.

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 <bruce.richardson@intel.com>
---
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(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index 85d59972d..aabd00eed 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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']
 )
-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 6/7] build/pkg-config: improve static linking flags
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
                     ` (4 preceding siblings ...)
  2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
@ 2020-05-01 13:54   ` Bruce Richardson
  2020-05-01 13:54   ` [dpdk-dev] [PATCH v2 7/7] build/pkg-config: prevent overlinking Bruce Richardson
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:54 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 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

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index aabd00eed..e043c5ee1 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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)
diff --git a/buildtools/pkg-config/set-static-linker-flags.py b/buildtools/pkg-config/set-static-linker-flags.py
new file mode 100644
index 000000000..516c3678b
--- /dev/null
+++ b/buildtools/pkg-config/set-static-linker-flags.py
@@ -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))
diff --git a/doc/guides/prog_guide/build-sdk-meson.rst b/doc/guides/prog_guide/build-sdk-meson.rst
index 7679c049a..44d1cafdf 100644
--- a/doc/guides/prog_guide/build-sdk-meson.rst
+++ b/doc/guides/prog_guide/build-sdk-meson.rst
@@ -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)
diff --git a/examples/bbdev_app/Makefile b/examples/bbdev_app/Makefile
index ead3f016b..3c8eb75a4 100644
--- a/examples/bbdev_app/Makefile
+++ b/examples/bbdev_app/Makefile
@@ -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
 
diff --git a/examples/bond/Makefile b/examples/bond/Makefile
index 2030ca410..4e4289e15 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -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
 
diff --git a/examples/cmdline/Makefile b/examples/cmdline/Makefile
index 9a33355d0..732509772 100644
--- a/examples/cmdline/Makefile
+++ b/examples/cmdline/Makefile
@@ -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)
diff --git a/examples/distributor/Makefile b/examples/distributor/Makefile
index 63c14dfca..6e3fef981 100644
--- a/examples/distributor/Makefile
+++ b/examples/distributor/Makefile
@@ -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)
diff --git a/examples/eventdev_pipeline/Makefile b/examples/eventdev_pipeline/Makefile
index 96cd24437..95a8d0884 100644
--- a/examples/eventdev_pipeline/Makefile
+++ b/examples/eventdev_pipeline/Makefile
@@ -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)
diff --git a/examples/fips_validation/Makefile b/examples/fips_validation/Makefile
index c207d11b9..b44ca2ee6 100644
--- a/examples/fips_validation/Makefile
+++ b/examples/fips_validation/Makefile
@@ -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)
diff --git a/examples/flow_classify/Makefile b/examples/flow_classify/Makefile
index 6864941b3..161d576b6 100644
--- a/examples/flow_classify/Makefile
+++ b/examples/flow_classify/Makefile
@@ -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
 
diff --git a/examples/flow_filtering/Makefile b/examples/flow_filtering/Makefile
index e0d546de9..010a1383e 100644
--- a/examples/flow_filtering/Makefile
+++ b/examples/flow_filtering/Makefile
@@ -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)
diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile
index 0f5af0806..94a1074cf 100644
--- a/examples/helloworld/Makefile
+++ b/examples/helloworld/Makefile
@@ -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)
diff --git a/examples/ioat/Makefile b/examples/ioat/Makefile
index 9b277eb7b..86308854e 100644
--- a/examples/ioat/Makefile
+++ b/examples/ioat/Makefile
@@ -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)
diff --git a/examples/ip_fragmentation/Makefile b/examples/ip_fragmentation/Makefile
index 8babbbf82..3f4db3f59 100644
--- a/examples/ip_fragmentation/Makefile
+++ b/examples/ip_fragmentation/Makefile
@@ -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)
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 3a0193818..1116bb6c1 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -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.
 
diff --git a/examples/ip_reassembly/Makefile b/examples/ip_reassembly/Makefile
index 11be2a74a..be9e541bd 100644
--- a/examples/ip_reassembly/Makefile
+++ b/examples/ip_reassembly/Makefile
@@ -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)
diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefile
index c4a272a30..ab15fca9e 100644
--- a/examples/ipsec-secgw/Makefile
+++ b/examples/ipsec-secgw/Makefile
@@ -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
 
diff --git a/examples/ipv4_multicast/Makefile b/examples/ipv4_multicast/Makefile
index b9f0813ed..0ed78c1cc 100644
--- a/examples/ipv4_multicast/Makefile
+++ b/examples/ipv4_multicast/Makefile
@@ -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)
diff --git a/examples/kni/Makefile b/examples/kni/Makefile
index c7ca96d8a..8fcb67c61 100644
--- a/examples/kni/Makefile
+++ b/examples/kni/Makefile
@@ -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)
diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
index ca1202be1..d767a10d7 100644
--- a/examples/l2fwd-cat/Makefile
+++ b/examples/l2fwd-cat/Makefile
@@ -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
 
diff --git a/examples/l2fwd-crypto/Makefile b/examples/l2fwd-crypto/Makefile
index 2f1405a72..cdbb91a1e 100644
--- a/examples/l2fwd-crypto/Makefile
+++ b/examples/l2fwd-crypto/Makefile
@@ -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)
diff --git a/examples/l2fwd-event/Makefile b/examples/l2fwd-event/Makefile
index 807f7f1b8..ddee388ae 100644
--- a/examples/l2fwd-event/Makefile
+++ b/examples/l2fwd-event/Makefile
@@ -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)
diff --git a/examples/l2fwd-jobstats/Makefile b/examples/l2fwd-jobstats/Makefile
index 6cd9dcd9c..bdb83c3e1 100644
--- a/examples/l2fwd-jobstats/Makefile
+++ b/examples/l2fwd-jobstats/Makefile
@@ -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)
diff --git a/examples/l2fwd-keepalive/Makefile b/examples/l2fwd-keepalive/Makefile
index 0db5e6015..9fd9db497 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -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)
diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile
index 8b7b26cb9..15105ac57 100644
--- a/examples/l2fwd/Makefile
+++ b/examples/l2fwd/Makefile
@@ -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)
diff --git a/examples/l3fwd-acl/Makefile b/examples/l3fwd-acl/Makefile
index 9f31abef8..6644a2cf1 100644
--- a/examples/l3fwd-acl/Makefile
+++ b/examples/l3fwd-acl/Makefile
@@ -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)
diff --git a/examples/l3fwd-power/Makefile b/examples/l3fwd-power/Makefile
index 729d49639..74441f98c 100644
--- a/examples/l3fwd-power/Makefile
+++ b/examples/l3fwd-power/Makefile
@@ -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
 
diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 839439f0f..b25a51581 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -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)
diff --git a/examples/link_status_interrupt/Makefile b/examples/link_status_interrupt/Makefile
index 613bb1167..f16916faa 100644
--- a/examples/link_status_interrupt/Makefile
+++ b/examples/link_status_interrupt/Makefile
@@ -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)
diff --git a/examples/ntb/Makefile b/examples/ntb/Makefile
index f2920ed54..81ec6017f 100644
--- a/examples/ntb/Makefile
+++ b/examples/ntb/Makefile
@@ -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)
diff --git a/examples/packet_ordering/Makefile b/examples/packet_ordering/Makefile
index f5b68c97e..f99b69dc2 100644
--- a/examples/packet_ordering/Makefile
+++ b/examples/packet_ordering/Makefile
@@ -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)
diff --git a/examples/ptpclient/Makefile b/examples/ptpclient/Makefile
index 7cd36632a..a9555fc66 100644
--- a/examples/ptpclient/Makefile
+++ b/examples/ptpclient/Makefile
@@ -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)
diff --git a/examples/qos_meter/Makefile b/examples/qos_meter/Makefile
index 90e3533d1..165e07ee2 100644
--- a/examples/qos_meter/Makefile
+++ b/examples/qos_meter/Makefile
@@ -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
 
diff --git a/examples/qos_sched/Makefile b/examples/qos_sched/Makefile
index 92e3de79b..0dd7d9105 100644
--- a/examples/qos_sched/Makefile
+++ b/examples/qos_sched/Makefile
@@ -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)
diff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile
index 584b9fafb..10e5f14d5 100644
--- a/examples/rxtx_callbacks/Makefile
+++ b/examples/rxtx_callbacks/Makefile
@@ -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)
diff --git a/examples/service_cores/Makefile b/examples/service_cores/Makefile
index aac207bd9..e742d88f6 100644
--- a/examples/service_cores/Makefile
+++ b/examples/service_cores/Makefile
@@ -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)
diff --git a/examples/skeleton/Makefile b/examples/skeleton/Makefile
index 2612688c0..5f5acf715 100644
--- a/examples/skeleton/Makefile
+++ b/examples/skeleton/Makefile
@@ -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)
diff --git a/examples/tep_termination/Makefile b/examples/tep_termination/Makefile
index 645112498..548ca3cee 100644
--- a/examples/tep_termination/Makefile
+++ b/examples/tep_termination/Makefile
@@ -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
 
diff --git a/examples/timer/Makefile b/examples/timer/Makefile
index e58e90a28..b40b65995 100644
--- a/examples/timer/Makefile
+++ b/examples/timer/Makefile
@@ -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)
diff --git a/examples/vdpa/Makefile b/examples/vdpa/Makefile
index 6a25497cd..bc0b6793e 100644
--- a/examples/vdpa/Makefile
+++ b/examples/vdpa/Makefile
@@ -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)
diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index f2b161541..ef6f3550f 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -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
 
diff --git a/examples/vhost_blk/Makefile b/examples/vhost_blk/Makefile
index 39244320d..395279178 100644
--- a/examples/vhost_blk/Makefile
+++ b/examples/vhost_blk/Makefile
@@ -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
 
diff --git a/examples/vhost_crypto/Makefile b/examples/vhost_crypto/Makefile
index ae8cb81f8..28e3e4de7 100644
--- a/examples/vhost_crypto/Makefile
+++ b/examples/vhost_crypto/Makefile
@@ -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)
diff --git a/examples/vmdq/Makefile b/examples/vmdq/Makefile
index 98e644fa7..b73373d3f 100644
--- a/examples/vmdq/Makefile
+++ b/examples/vmdq/Makefile
@@ -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)
diff --git a/examples/vmdq_dcb/Makefile b/examples/vmdq_dcb/Makefile
index 3eb7c9f43..8d8baf729 100644
--- a/examples/vmdq_dcb/Makefile
+++ b/examples/vmdq_dcb/Makefile
@@ -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)
-- 
2.20.1


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

* [dpdk-dev] [PATCH v2 7/7] build/pkg-config: prevent overlinking
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
                     ` (5 preceding siblings ...)
  2020-05-01 13:54   ` [dpdk-dev] [PATCH v2 6/7] build/pkg-config: improve static linking flags Bruce Richardson
@ 2020-05-01 13:54   ` Bruce Richardson
  2020-05-01 14:02   ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Luca Boccassi
  2020-06-30 13:25   ` Pai G, Sunil
  8 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-05-01 13:54 UTC (permalink / raw)
  To: dev; +Cc: thomas, bluca, david.marchand, ktraynor, Bruce Richardson

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
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(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index e043c5ee1..5c1e31c4d 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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
-- 
2.20.1


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

* Re: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
                     ` (6 preceding siblings ...)
  2020-05-01 13:54   ` [dpdk-dev] [PATCH v2 7/7] build/pkg-config: prevent overlinking Bruce Richardson
@ 2020-05-01 14:02   ` Luca Boccassi
  2020-06-30 13:25   ` Pai G, Sunil
  8 siblings, 0 replies; 63+ messages in thread
From: Luca Boccassi @ 2020-05-01 14:02 UTC (permalink / raw)
  To: Bruce Richardson, dev; +Cc: thomas, david.marchand, ktraynor

On Fri, 2020-05-01 at 14:53 +0100, Bruce Richardson wrote:
> 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 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

Series-acked-by: Luca Boccassi <bluca@debian.org>

-- 
Kind regards,
Luca Boccassi

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

* Re: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
                     ` (7 preceding siblings ...)
  2020-05-01 14:02   ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Luca Boccassi
@ 2020-06-30 13:25   ` Pai G, Sunil
  2020-06-30 16:37     ` Stokes, Ian
  8 siblings, 1 reply; 63+ messages in thread
From: Pai G, Sunil @ 2020-06-30 13:25 UTC (permalink / raw)
  To: Richardson, Bruce, dev
  Cc: thomas, bluca, david.marchand, ktraynor, Richardson, Bruce,
	Stokes, Ian, Pai G, Sunil

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Bruce Richardson
> Sent: Friday, May 1, 2020 7:24 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; bluca@debian.org;
> david.marchand@redhat.com; ktraynor@redhat.com; Richardson, Bruce
> <bruce.richardson@intel.com>
> Subject: [dpdk-dev] [PATCH v2 0/7] 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.
> 
> 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
> 
> --
> 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 

Series-acked-by: Sunil Pai G <sunil.pai.g@intel.com>


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

* [dpdk-dev] [PATCH v3 0/7] improve DPDK static builds with meson
  2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
                   ` (7 preceding siblings ...)
  2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
@ 2020-06-30 14:14 ` Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries Bruce Richardson
                     ` (7 more replies)
  8 siblings, 8 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, 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.

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

-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-07-01 14:19     ` Thomas Monjalon
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 2/7] build: remove unnecessary variable Bruce Richardson
                     ` (6 subsequent siblings)
  7 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g,
	Bruce Richardson, Andrzej Ostruszka

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Andrzej Ostruszka <aostruszka@marvell.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 app/test/meson.build | 2 +-
 drivers/meson.build  | 2 +-
 examples/meson.build | 6 +++---
 lib/meson.build      | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index 5233ead46..b2a1c1273 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -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
 
diff --git a/drivers/meson.build b/drivers/meson.build
index 01c860c06..e78c76c55 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -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)
 
diff --git a/examples/meson.build b/examples/meson.build
index 3b540012f..120eebf71 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -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)
diff --git a/lib/meson.build b/lib/meson.build
index 4cbbca041..c1b9e1633 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -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)
 
-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 2/7] build: remove unnecessary variable
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, Bruce Richardson

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.

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 app/meson.build | 2 +-
 meson.build     | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 408676b06..585b90832 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -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)
 
diff --git a/meson.build b/meson.build
index 750fdeab1..d6ca58b85 100644
--- a/meson.build
+++ b/meson.build
@@ -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')
-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 3/7] devtools/test-meson-builds.sh: add pkg-config static builds
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 2/7] build: remove unnecessary variable Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 4/7] build: move pkg-config creation to separate file Bruce Richardson
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, Bruce Richardson

The 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 devtools/test-meson-builds.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index 64a022ccf..d96d1af5f 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -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
-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 4/7] build: move pkg-config creation to separate file
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
                     ` (2 preceding siblings ...)
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, Bruce Richardson

Ahead 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 buildtools/pkg-config/meson.build | 26 ++++++++++++++++++++++++++
 meson.build                       | 25 ++-----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)
 create mode 100644 buildtools/pkg-config/meson.build

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
new file mode 100644
index 000000000..85d59972d
--- /dev/null
+++ b/buildtools/pkg-config/meson.build
@@ -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
+)
diff --git a/meson.build b/meson.build
index d6ca58b85..d21adfd30 100644
--- a/meson.build
+++ b/meson.build
@@ -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.
-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
                     ` (3 preceding siblings ...)
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 4/7] build: move pkg-config creation to separate file Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-07-01  7:50     ` Thomas Monjalon
  2020-07-01 14:42     ` Thomas Monjalon
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags Bruce Richardson
                     ` (2 subsequent siblings)
  7 siblings, 2 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, 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.

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 <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 buildtools/pkg-config/meson.build | 33 +++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index 85d59972d..aabd00eed 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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']
 )
-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
                     ` (4 preceding siblings ...)
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-07-01 14:30     ` Thomas Monjalon
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking Bruce Richardson
  2020-07-01 17:33   ` [dpdk-dev] [PATCH v3 0/7] improve DPDK static builds with meson Thomas Monjalon
  7 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, 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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 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

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index aabd00eed..e043c5ee1 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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)
diff --git a/buildtools/pkg-config/set-static-linker-flags.py b/buildtools/pkg-config/set-static-linker-flags.py
new file mode 100644
index 000000000..516c3678b
--- /dev/null
+++ b/buildtools/pkg-config/set-static-linker-flags.py
@@ -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))
diff --git a/doc/guides/prog_guide/build-sdk-meson.rst b/doc/guides/prog_guide/build-sdk-meson.rst
index 7679c049a..44d1cafdf 100644
--- a/doc/guides/prog_guide/build-sdk-meson.rst
+++ b/doc/guides/prog_guide/build-sdk-meson.rst
@@ -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)
diff --git a/examples/bbdev_app/Makefile b/examples/bbdev_app/Makefile
index ead3f016b..3c8eb75a4 100644
--- a/examples/bbdev_app/Makefile
+++ b/examples/bbdev_app/Makefile
@@ -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
 
diff --git a/examples/bond/Makefile b/examples/bond/Makefile
index 2030ca410..4e4289e15 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -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
 
diff --git a/examples/cmdline/Makefile b/examples/cmdline/Makefile
index 9a33355d0..732509772 100644
--- a/examples/cmdline/Makefile
+++ b/examples/cmdline/Makefile
@@ -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)
diff --git a/examples/distributor/Makefile b/examples/distributor/Makefile
index 63c14dfca..6e3fef981 100644
--- a/examples/distributor/Makefile
+++ b/examples/distributor/Makefile
@@ -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)
diff --git a/examples/eventdev_pipeline/Makefile b/examples/eventdev_pipeline/Makefile
index 96cd24437..95a8d0884 100644
--- a/examples/eventdev_pipeline/Makefile
+++ b/examples/eventdev_pipeline/Makefile
@@ -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)
diff --git a/examples/fips_validation/Makefile b/examples/fips_validation/Makefile
index c207d11b9..b44ca2ee6 100644
--- a/examples/fips_validation/Makefile
+++ b/examples/fips_validation/Makefile
@@ -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)
diff --git a/examples/flow_classify/Makefile b/examples/flow_classify/Makefile
index 6864941b3..161d576b6 100644
--- a/examples/flow_classify/Makefile
+++ b/examples/flow_classify/Makefile
@@ -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
 
diff --git a/examples/flow_filtering/Makefile b/examples/flow_filtering/Makefile
index e0d546de9..010a1383e 100644
--- a/examples/flow_filtering/Makefile
+++ b/examples/flow_filtering/Makefile
@@ -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)
diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile
index 0f5af0806..94a1074cf 100644
--- a/examples/helloworld/Makefile
+++ b/examples/helloworld/Makefile
@@ -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)
diff --git a/examples/ioat/Makefile b/examples/ioat/Makefile
index 9b277eb7b..86308854e 100644
--- a/examples/ioat/Makefile
+++ b/examples/ioat/Makefile
@@ -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)
diff --git a/examples/ip_fragmentation/Makefile b/examples/ip_fragmentation/Makefile
index 8babbbf82..3f4db3f59 100644
--- a/examples/ip_fragmentation/Makefile
+++ b/examples/ip_fragmentation/Makefile
@@ -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)
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 3a0193818..1116bb6c1 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -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.
 
diff --git a/examples/ip_reassembly/Makefile b/examples/ip_reassembly/Makefile
index 11be2a74a..be9e541bd 100644
--- a/examples/ip_reassembly/Makefile
+++ b/examples/ip_reassembly/Makefile
@@ -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)
diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefile
index c4a272a30..ab15fca9e 100644
--- a/examples/ipsec-secgw/Makefile
+++ b/examples/ipsec-secgw/Makefile
@@ -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
 
diff --git a/examples/ipv4_multicast/Makefile b/examples/ipv4_multicast/Makefile
index b9f0813ed..0ed78c1cc 100644
--- a/examples/ipv4_multicast/Makefile
+++ b/examples/ipv4_multicast/Makefile
@@ -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)
diff --git a/examples/kni/Makefile b/examples/kni/Makefile
index c7ca96d8a..8fcb67c61 100644
--- a/examples/kni/Makefile
+++ b/examples/kni/Makefile
@@ -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)
diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
index ca1202be1..d767a10d7 100644
--- a/examples/l2fwd-cat/Makefile
+++ b/examples/l2fwd-cat/Makefile
@@ -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
 
diff --git a/examples/l2fwd-crypto/Makefile b/examples/l2fwd-crypto/Makefile
index 2f1405a72..cdbb91a1e 100644
--- a/examples/l2fwd-crypto/Makefile
+++ b/examples/l2fwd-crypto/Makefile
@@ -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)
diff --git a/examples/l2fwd-event/Makefile b/examples/l2fwd-event/Makefile
index 807f7f1b8..ddee388ae 100644
--- a/examples/l2fwd-event/Makefile
+++ b/examples/l2fwd-event/Makefile
@@ -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)
diff --git a/examples/l2fwd-jobstats/Makefile b/examples/l2fwd-jobstats/Makefile
index 6cd9dcd9c..bdb83c3e1 100644
--- a/examples/l2fwd-jobstats/Makefile
+++ b/examples/l2fwd-jobstats/Makefile
@@ -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)
diff --git a/examples/l2fwd-keepalive/Makefile b/examples/l2fwd-keepalive/Makefile
index 0db5e6015..9fd9db497 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -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)
diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile
index 8b7b26cb9..15105ac57 100644
--- a/examples/l2fwd/Makefile
+++ b/examples/l2fwd/Makefile
@@ -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)
diff --git a/examples/l3fwd-acl/Makefile b/examples/l3fwd-acl/Makefile
index 9f31abef8..6644a2cf1 100644
--- a/examples/l3fwd-acl/Makefile
+++ b/examples/l3fwd-acl/Makefile
@@ -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)
diff --git a/examples/l3fwd-power/Makefile b/examples/l3fwd-power/Makefile
index 852877c1f..ac1ccdcf6 100644
--- a/examples/l3fwd-power/Makefile
+++ b/examples/l3fwd-power/Makefile
@@ -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
 
diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 839439f0f..b25a51581 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -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)
diff --git a/examples/link_status_interrupt/Makefile b/examples/link_status_interrupt/Makefile
index 613bb1167..f16916faa 100644
--- a/examples/link_status_interrupt/Makefile
+++ b/examples/link_status_interrupt/Makefile
@@ -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)
diff --git a/examples/ntb/Makefile b/examples/ntb/Makefile
index f2920ed54..81ec6017f 100644
--- a/examples/ntb/Makefile
+++ b/examples/ntb/Makefile
@@ -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)
diff --git a/examples/packet_ordering/Makefile b/examples/packet_ordering/Makefile
index f5b68c97e..f99b69dc2 100644
--- a/examples/packet_ordering/Makefile
+++ b/examples/packet_ordering/Makefile
@@ -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)
diff --git a/examples/ptpclient/Makefile b/examples/ptpclient/Makefile
index 7cd36632a..a9555fc66 100644
--- a/examples/ptpclient/Makefile
+++ b/examples/ptpclient/Makefile
@@ -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)
diff --git a/examples/qos_meter/Makefile b/examples/qos_meter/Makefile
index 90e3533d1..165e07ee2 100644
--- a/examples/qos_meter/Makefile
+++ b/examples/qos_meter/Makefile
@@ -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
 
diff --git a/examples/qos_sched/Makefile b/examples/qos_sched/Makefile
index 92e3de79b..0dd7d9105 100644
--- a/examples/qos_sched/Makefile
+++ b/examples/qos_sched/Makefile
@@ -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)
diff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile
index 584b9fafb..10e5f14d5 100644
--- a/examples/rxtx_callbacks/Makefile
+++ b/examples/rxtx_callbacks/Makefile
@@ -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)
diff --git a/examples/service_cores/Makefile b/examples/service_cores/Makefile
index aac207bd9..e742d88f6 100644
--- a/examples/service_cores/Makefile
+++ b/examples/service_cores/Makefile
@@ -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)
diff --git a/examples/skeleton/Makefile b/examples/skeleton/Makefile
index 2612688c0..5f5acf715 100644
--- a/examples/skeleton/Makefile
+++ b/examples/skeleton/Makefile
@@ -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)
diff --git a/examples/tep_termination/Makefile b/examples/tep_termination/Makefile
index 645112498..548ca3cee 100644
--- a/examples/tep_termination/Makefile
+++ b/examples/tep_termination/Makefile
@@ -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
 
diff --git a/examples/timer/Makefile b/examples/timer/Makefile
index e58e90a28..b40b65995 100644
--- a/examples/timer/Makefile
+++ b/examples/timer/Makefile
@@ -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)
diff --git a/examples/vdpa/Makefile b/examples/vdpa/Makefile
index 6a25497cd..bc0b6793e 100644
--- a/examples/vdpa/Makefile
+++ b/examples/vdpa/Makefile
@@ -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)
diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index f2b161541..ef6f3550f 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -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
 
diff --git a/examples/vhost_blk/Makefile b/examples/vhost_blk/Makefile
index 39244320d..395279178 100644
--- a/examples/vhost_blk/Makefile
+++ b/examples/vhost_blk/Makefile
@@ -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
 
diff --git a/examples/vhost_crypto/Makefile b/examples/vhost_crypto/Makefile
index ae8cb81f8..28e3e4de7 100644
--- a/examples/vhost_crypto/Makefile
+++ b/examples/vhost_crypto/Makefile
@@ -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)
diff --git a/examples/vmdq/Makefile b/examples/vmdq/Makefile
index 98e644fa7..b73373d3f 100644
--- a/examples/vmdq/Makefile
+++ b/examples/vmdq/Makefile
@@ -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)
diff --git a/examples/vmdq_dcb/Makefile b/examples/vmdq_dcb/Makefile
index 3eb7c9f43..8d8baf729 100644
--- a/examples/vmdq_dcb/Makefile
+++ b/examples/vmdq_dcb/Makefile
@@ -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)
-- 
2.25.1


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

* [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
                     ` (5 preceding siblings ...)
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags Bruce Richardson
@ 2020-06-30 14:14   ` Bruce Richardson
  2020-07-01  7:56     ` Thomas Monjalon
  2020-07-01 17:33   ` [dpdk-dev] [PATCH v3 0/7] improve DPDK static builds with meson Thomas Monjalon
  7 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-06-30 14:14 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, ktraynor, bluca, sunil.pai.g, Bruce Richardson

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 buildtools/pkg-config/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index e043c5ee1..5c1e31c4d 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -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
-- 
2.25.1


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

* Re: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson
  2020-06-30 13:25   ` Pai G, Sunil
@ 2020-06-30 16:37     ` Stokes, Ian
  2020-07-01 17:29       ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Stokes, Ian @ 2020-06-30 16:37 UTC (permalink / raw)
  To: Pai G, Sunil, Richardson, Bruce, dev
  Cc: thomas, bluca, david.marchand, ktraynor, Richardson, Bruce

> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Bruce Richardson
> > Sent: Friday, May 1, 2020 7:24 PM
> > To: dev@dpdk.org
> > Cc: thomas@monjalon.net; bluca@debian.org; david.marchand@redhat.com;
> > ktraynor@redhat.com; Richardson, Bruce <bruce.richardson@intel.com>
> > Subject: [dpdk-dev] [PATCH v2 0/7] 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.
> >
> > 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
> >
> > --
> > 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

+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
> 
> Series-acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> 


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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
@ 2020-07-01  7:50     ` Thomas Monjalon
  2020-07-01  8:43       ` Bruce Richardson
  2020-07-01 14:42     ` Thomas Monjalon
  1 sibling, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01  7:50 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

30/06/2020 16:14, 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

Sorry, I'm lost here. Why "only" driver files?

> those need to come *before* the regular libraries.

Given whole libs are linked, is it really needed to have drivers first?

> 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.

I'm completely lost. In which case we link both static and shared libs?

> 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 <bruce.richardson@intel.com>
> Acked-by: Luca Boccassi <bluca@debian.org>
> Acked-by: Sunil Pai G <sunil.pai.g@intel.com>




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

* Re: [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking Bruce Richardson
@ 2020-07-01  7:56     ` Thomas Monjalon
  2020-07-01  8:58       ` Bruce Richardson
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01  7:56 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

30/06/2020 16:14, Bruce Richardson:
> 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.



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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-07-01  7:50     ` Thomas Monjalon
@ 2020-07-01  8:43       ` Bruce Richardson
  0 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-07-01  8:43 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

On Wed, Jul 01, 2020 at 09:50:20AM +0200, Thomas Monjalon wrote:
> 30/06/2020 16:14, 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
> 
> 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".

> 
> > 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.

> 
> > 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.
> 
> 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.

> > 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 <bruce.richardson@intel.com>
> > Acked-by: Luca Boccassi <bluca@debian.org>
> > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> 
> 
> 

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

* Re: [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking
  2020-07-01  7:56     ` Thomas Monjalon
@ 2020-07-01  8:58       ` Bruce Richardson
  0 siblings, 0 replies; 63+ messages in thread
From: Bruce Richardson @ 2020-07-01  8:58 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

On Wed, Jul 01, 2020 at 09:56:13AM +0200, Thomas Monjalon wrote:
> 30/06/2020 16:14, Bruce Richardson:
> > 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.
>
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

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

* Re: [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries Bruce Richardson
@ 2020-07-01 14:19     ` Thomas Monjalon
  0 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 14:19 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g,
	Bruce Richardson, Andrzej Ostruszka

30/06/2020 16:14, Bruce Richardson:
> To ensure all constructors are included in static build, we need to pass
> the --whole-archive flag when linking, which is used with the
> "link_whole" meson option. Since we use link_whole for all libs, we no
> longer need to track the lib as part of the static dependency, just the
> path to the headers for compiling.
> 
> 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 <bruce.richardson@intel.com>
> Tested-by: Andrzej Ostruszka <aostruszka@marvell.com>
> Acked-by: Luca Boccassi <bluca@debian.org>
> Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> ---
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> -	link_libs = dpdk_drivers
> +	link_libs = dpdk_static_libraries + dpdk_drivers
>  	link_nodes = dpdk_graph_nodes
[...]
> --- a/examples/meson.build
> +++ b/examples/meson.build
> -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.

Acked-by: Thomas Monjalon <thomas@monjalon.net>



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

* Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags Bruce Richardson
@ 2020-07-01 14:30     ` Thomas Monjalon
  2020-07-01 14:33       ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 14:30 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

30/06/2020 16:14, 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.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Luca Boccassi <bluca@debian.org>
> Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> ---
> --- a/buildtools/pkg-config/meson.build
> +++ b/buildtools/pkg-config/meson.build
> +# 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,
Acked-by: Thomas Monjalon <thomas@monjalon.net>



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

* Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
  2020-07-01 14:30     ` Thomas Monjalon
@ 2020-07-01 14:33       ` Thomas Monjalon
  2020-07-01 14:36         ` Bruce Richardson
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 14:33 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

01/07/2020 16:30, Thomas Monjalon:
> 30/06/2020 16:14, 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.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > Acked-by: Luca Boccassi <bluca@debian.org>
> > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > ---
> > --- a/buildtools/pkg-config/meson.build
> > +++ b/buildtools/pkg-config/meson.build
> > +# 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.

Even better:

> # For static linking with dependencies as shared libraries,
> # the internal static libraries must be flagged explicitly.




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

* Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
  2020-07-01 14:33       ` Thomas Monjalon
@ 2020-07-01 14:36         ` Bruce Richardson
  2020-07-01 14:45           ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-07-01 14:36 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

On Wed, Jul 01, 2020 at 04:33:27PM +0200, Thomas Monjalon wrote:
> 01/07/2020 16:30, Thomas Monjalon:
> > 30/06/2020 16:14, 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.
> > > 
> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > Acked-by: Luca Boccassi <bluca@debian.org>
> > > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > > ---
> > > --- a/buildtools/pkg-config/meson.build
> > > +++ b/buildtools/pkg-config/meson.build
> > > +# 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.
> 
> Even better:
> 
> > # 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

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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
  2020-07-01  7:50     ` Thomas Monjalon
@ 2020-07-01 14:42     ` Thomas Monjalon
  2020-07-01 15:16       ` Bruce Richardson
  1 sibling, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 14:42 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

30/06/2020 16:14, 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,

s/libraries.private/Libs.private/

> 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/

> 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 <bruce.richardson@intel.com>
> Acked-by: Luca Boccassi <bluca@debian.org>
> Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> ---
> +# 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 ;)



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

* Re: [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags
  2020-07-01 14:36         ` Bruce Richardson
@ 2020-07-01 14:45           ` Thomas Monjalon
  0 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 14:45 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

01/07/2020 16:36, Bruce Richardson:
> On Wed, Jul 01, 2020 at 04:33:27PM +0200, Thomas Monjalon wrote:
> > 01/07/2020 16:30, Thomas Monjalon:
> > > 30/06/2020 16:14, 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.
> > > > 
> > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > > Acked-by: Luca Boccassi <bluca@debian.org>
> > > > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > > > ---
> > > > --- a/buildtools/pkg-config/meson.build
> > > > +++ b/buildtools/pkg-config/meson.build
> > > > +# 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.
> > 
> > Even better:
> > 
> > > # 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.




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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-07-01 14:42     ` Thomas Monjalon
@ 2020-07-01 15:16       ` Bruce Richardson
  2020-07-01 15:36         ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-07-01 15:16 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

On Wed, Jul 01, 2020 at 04:42:33PM +0200, Thomas Monjalon wrote:
> 30/06/2020 16:14, 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,
> 
> s/libraries.private/Libs.private/
> 
> > 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/
> 
> > 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 <bruce.richardson@intel.com>
> > Acked-by: Luca Boccassi <bluca@debian.org>
> > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > ---
> > +# 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 ;)
>

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

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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-07-01 15:16       ` Bruce Richardson
@ 2020-07-01 15:36         ` Thomas Monjalon
  2020-07-01 15:45           ` Bruce Richardson
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 15:36 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

01/07/2020 17:16, Bruce Richardson:
> On Wed, Jul 01, 2020 at 04:42:33PM +0200, Thomas Monjalon wrote:
> > 30/06/2020 16:14, 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,
> > 
> > s/libraries.private/Libs.private/
> > 
> > > 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/
> > 
> > > 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 <bruce.richardson@intel.com>
> > > Acked-by: Luca Boccassi <bluca@debian.org>
> > > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > > ---
> > > +# 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 ;)
> >
> 
> 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.

> * 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.



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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-07-01 15:36         ` Thomas Monjalon
@ 2020-07-01 15:45           ` Bruce Richardson
  2020-07-01 16:04             ` Thomas Monjalon
  0 siblings, 1 reply; 63+ messages in thread
From: Bruce Richardson @ 2020-07-01 15:45 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

On Wed, Jul 01, 2020 at 05:36:07PM +0200, Thomas Monjalon wrote:
> 01/07/2020 17:16, Bruce Richardson:
> > On Wed, Jul 01, 2020 at 04:42:33PM +0200, Thomas Monjalon wrote:
> > > 30/06/2020 16:14, 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,
> > > 
> > > s/libraries.private/Libs.private/
> > > 
> > > > 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/
> > > 
> > > > 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 <bruce.richardson@intel.com>
> > > > Acked-by: Luca Boccassi <bluca@debian.org>
> > > > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > > > ---
> > > > +# 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 ;)
> > >
> > 
> > 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.
> 
> > * 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.
> 
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!]

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

* Re: [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build
  2020-07-01 15:45           ` Bruce Richardson
@ 2020-07-01 16:04             ` Thomas Monjalon
  0 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 16:04 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

01/07/2020 17:45, Bruce Richardson:
> On Wed, Jul 01, 2020 at 05:36:07PM +0200, Thomas Monjalon wrote:
> > 01/07/2020 17:16, Bruce Richardson:
> > > On Wed, Jul 01, 2020 at 04:42:33PM +0200, Thomas Monjalon wrote:
> > > > 30/06/2020 16:14, 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,
> > > > 
> > > > s/libraries.private/Libs.private/
> > > > 
> > > > > 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/
> > > > 
> > > > > 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 <bruce.richardson@intel.com>
> > > > > Acked-by: Luca Boccassi <bluca@debian.org>
> > > > > Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
> > > > > ---
> > > > > +# 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 ;)
> > > >
> > > 
> > > 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.
> > 
> > > * 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.
> > 
> 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.




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

* Re: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson
  2020-06-30 16:37     ` Stokes, Ian
@ 2020-07-01 17:29       ` Thomas Monjalon
  2020-07-02 10:46         ` Stokes, Ian
  0 siblings, 1 reply; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 17:29 UTC (permalink / raw)
  To: Pai G, Sunil, dev, Stokes, Ian
  Cc: Richardson, Bruce, bluca, david.marchand, ktraynor, Richardson, Bruce

30/06/2020 18:37, Stokes, Ian:
> > 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
> 
> +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.




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

* Re: [dpdk-dev] [PATCH v3 0/7] improve DPDK static builds with meson
  2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
                     ` (6 preceding siblings ...)
  2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking Bruce Richardson
@ 2020-07-01 17:33   ` Thomas Monjalon
  7 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2020-07-01 17:33 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, david.marchand, ktraynor, bluca, sunil.pai.g

30/06/2020 16:14, 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.
> 
> 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

Applied with changes discussed in the thread, thanks




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

* Re: [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson
  2020-07-01 17:29       ` Thomas Monjalon
@ 2020-07-02 10:46         ` Stokes, Ian
  0 siblings, 0 replies; 63+ messages in thread
From: Stokes, Ian @ 2020-07-02 10:46 UTC (permalink / raw)
  To: Thomas Monjalon, Pai G, Sunil, dev
  Cc: Richardson, Bruce, bluca, david.marchand, ktraynor, Richardson, Bruce

> 30/06/2020 18:37, Stokes, Ian:
> > > 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
> >
> > +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.
> 
> 

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


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

end of thread, other threads:[~2020-07-02 10:47 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 10:08 [dpdk-dev] [PATCH 0/7] improve DPDK static builds with meson Bruce Richardson
2020-04-29 10:08 ` [dpdk-dev] [PATCH 1/7] build: always link-whole DPDK static libraries Bruce Richardson
2020-04-29 10:18   ` Thomas Monjalon
2020-04-29 10:42     ` Bruce Richardson
2020-04-29 10:49       ` Thomas Monjalon
2020-04-29 14:04   ` Andrzej Ostruszka [C]
2020-04-29 10:08 ` [dpdk-dev] [PATCH 2/7] build: remove unnecessary variable Bruce Richardson
2020-04-29 10:19   ` Thomas Monjalon
2020-04-29 10:29     ` Bruce Richardson
2020-04-29 10:08 ` [dpdk-dev] [PATCH 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
2020-04-29 10:08 ` [dpdk-dev] [PATCH 4/7] build: move pkg-config creation to separate file Bruce Richardson
2020-04-29 10:08 ` [dpdk-dev] [PATCH 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
2020-04-29 10:30   ` Thomas Monjalon
2020-04-29 10:54     ` Bruce Richardson
2020-04-29 10:40   ` Luca Boccassi
2020-04-29 11:03     ` Bruce Richardson
2020-04-29 11:12       ` Luca Boccassi
2020-04-29 10:08 ` [dpdk-dev] [PATCH 6/7] build/pkg-config: improve static linking flags Bruce Richardson
2020-04-29 10:32   ` Thomas Monjalon
2020-04-29 10:56     ` Bruce Richardson
2020-04-29 10:57       ` Thomas Monjalon
2020-04-29 10:37   ` Luca Boccassi
2020-04-29 10:58     ` Bruce Richardson
2020-04-29 11:10       ` Luca Boccassi
2020-04-29 10:08 ` [dpdk-dev] [PATCH 7/7] build/pkg-config: prevent overlinking Bruce Richardson
2020-04-29 10:34   ` Thomas Monjalon
2020-04-29 11:00     ` Bruce Richardson
2020-05-01 13:53 ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Bruce Richardson
2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 1/7] build: always link-whole DPDK static libraries Bruce Richardson
2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 2/7] build: remove unnecessary variable Bruce Richardson
2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 4/7] build: move pkg-config creation to separate file Bruce Richardson
2020-05-01 13:53   ` [dpdk-dev] [PATCH v2 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
2020-05-01 13:54   ` [dpdk-dev] [PATCH v2 6/7] build/pkg-config: improve static linking flags Bruce Richardson
2020-05-01 13:54   ` [dpdk-dev] [PATCH v2 7/7] build/pkg-config: prevent overlinking Bruce Richardson
2020-05-01 14:02   ` [dpdk-dev] [PATCH v2 0/7] improve DPDK static builds with meson Luca Boccassi
2020-06-30 13:25   ` Pai G, Sunil
2020-06-30 16:37     ` Stokes, Ian
2020-07-01 17:29       ` Thomas Monjalon
2020-07-02 10:46         ` Stokes, Ian
2020-06-30 14:14 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 1/7] build: always link-whole DPDK static libraries Bruce Richardson
2020-07-01 14:19     ` Thomas Monjalon
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 2/7] build: remove unnecessary variable Bruce Richardson
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 3/7] devtools/test-meson-builds.sh: add pkg-config static builds Bruce Richardson
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 4/7] build: move pkg-config creation to separate file Bruce Richardson
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 5/7] build/pkg-config: output driver libs first for static build Bruce Richardson
2020-07-01  7:50     ` Thomas Monjalon
2020-07-01  8:43       ` Bruce Richardson
2020-07-01 14:42     ` Thomas Monjalon
2020-07-01 15:16       ` Bruce Richardson
2020-07-01 15:36         ` Thomas Monjalon
2020-07-01 15:45           ` Bruce Richardson
2020-07-01 16:04             ` Thomas Monjalon
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 6/7] build/pkg-config: improve static linking flags Bruce Richardson
2020-07-01 14:30     ` Thomas Monjalon
2020-07-01 14:33       ` Thomas Monjalon
2020-07-01 14:36         ` Bruce Richardson
2020-07-01 14:45           ` Thomas Monjalon
2020-06-30 14:14   ` [dpdk-dev] [PATCH v3 7/7] build/pkg-config: prevent overlinking Bruce Richardson
2020-07-01  7:56     ` Thomas Monjalon
2020-07-01  8:58       ` Bruce Richardson
2020-07-01 17:33   ` [dpdk-dev] [PATCH v3 0/7] improve DPDK static builds with meson Thomas Monjalon

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