diff mbox series

[v3,1/7] build: always link-whole DPDK static libraries

Message ID 20200630141433.818517-2-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series improve DPDK static builds with meson | expand

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson June 30, 2020, 2:14 p.m. UTC
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(-)

Comments

Thomas Monjalon July 1, 2020, 2:19 p.m. UTC | #1
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>
diff mbox series

Patch

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)