diff mbox series

[v5,03/17] build: detect execinfo library on Linux

Message ID 20210225182250.1149592-4-thomas@monjalon.net (mailing list archive)
State Superseded
Headers show
Series Alpine/musl build support | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Feb. 25, 2021, 6:22 p.m. UTC
The library execinfo and its header file can be installed on Alpine Linux
where the backtrace feature is not part of musl libc:
	apk add libexecinfo-dev

As a consequence, this library should not be restricted to BSD only.

At the same time, the library and header are detected once and added
globally to be linked with any application, internal or external.

Fixes: 9065b1fac65f ("build: fix dependency on execinfo for BSD meson builds")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)

Comments

Bruce Richardson Feb. 26, 2021, 9:08 a.m. UTC | #1
On Thu, Feb 25, 2021 at 07:22:36PM +0100, Thomas Monjalon wrote:
> The library execinfo and its header file can be installed on Alpine Linux
> where the backtrace feature is not part of musl libc:
> 	apk add libexecinfo-dev
> 
> As a consequence, this library should not be restricted to BSD only.
> 
> At the same time, the library and header are detected once and added
> globally to be linked with any application, internal or external.
> 
> Fixes: 9065b1fac65f ("build: fix dependency on execinfo for BSD meson builds")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
diff mbox series

Patch

diff --git a/app/meson.build b/app/meson.build
index 87fc195dbf..50a53dbde8 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -21,9 +21,6 @@  apps = [
 	'test-regex',
 	'test-sad']
 
-# for BSD only
-lib_execinfo = cc.find_library('execinfo', required: false)
-
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
 default_ldflags = []
 if get_option('default_library') == 'static' and not is_windows
@@ -53,7 +50,6 @@  foreach app:apps
 			dep_objs += get_variable(get_option('default_library')
 				 + '_rte_' + d)
 		endforeach
-		dep_objs += lib_execinfo
 
 		link_libs = []
 		if get_option('default_library') == 'static'
diff --git a/app/test/meson.build b/app/test/meson.build
index 561e493a29..099895fc87 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -426,7 +426,6 @@  foreach d:test_deps
 	def_lib = get_option('default_library')
 	test_dep_objs += get_variable(def_lib + '_rte_' + d)
 endforeach
-test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
 if get_option('default_library') == 'static'
diff --git a/config/meson.build b/config/meson.build
index 3cf560b8a3..66a2edcc47 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -125,11 +125,8 @@  if cc.find_library('m', required : false).found()
 	dpdk_extra_ldflags += '-lm'
 endif
 
-# for linux link against dl, for bsd execinfo
 if is_linux
 	link_lib = 'dl'
-elif is_freebsd
-	link_lib = 'execinfo'
 else
 	link_lib = ''
 endif
@@ -166,6 +163,12 @@  if fdt_dep.found() and cc.has_header('fdt.h')
 	dpdk_extra_ldflags += '-lfdt'
 endif
 
+libexecinfo = cc.find_library('libexecinfo', required: false)
+if libexecinfo.found() and cc.has_header('execinfo.h')
+	add_project_link_arguments('-lexecinfo', language: 'c')
+	dpdk_extra_ldflags += '-lexecinfo'
+endif
+
 # check for libbsd
 libbsd = dependency('libbsd', required: false, method: 'pkg-config')
 if libbsd.found()
diff --git a/examples/meson.build b/examples/meson.build
index b9ab24223f..ab06e2da33 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -6,8 +6,6 @@  if get_option('default_library') == 'static'
 	link_whole_libs = dpdk_static_libraries + dpdk_drivers
 endif
 
-execinfo = cc.find_library('execinfo', required: false)
-
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
 all_examples = [
 	'bbdev_app', 'bond',
@@ -76,7 +74,7 @@  foreach example: examples
 	cflags = default_cflags
 	ldflags = default_ldflags
 
-	ext_deps = [execinfo]
+	ext_deps = []
 	includes = [include_directories(example)]
 	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
 	subdir(example)