Skip to content

Commit

Permalink
build: detect execinfo library on Linux
Browse files Browse the repository at this point in the history
[ upstream commit 1cd512b ]

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: 9065b1f ("build: fix dependency on execinfo for BSD meson builds")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
tmonjalo authored and cpaelzer committed May 11, 2021
1 parent 0bbd0f5 commit 7f254be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
3 changes: 0 additions & 3 deletions app/meson.build
Expand Up @@ -18,8 +18,6 @@ apps = [
'test-pmd',
'test-sad']

# for BSD only
lib_execinfo = cc.find_library('execinfo', required: false)

default_cflags = machine_args
default_ldflags = []
Expand Down Expand Up @@ -51,7 +49,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'
Expand Down
1 change: 0 additions & 1 deletion app/test/meson.build
Expand Up @@ -387,7 +387,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'
Expand Down
9 changes: 6 additions & 3 deletions config/meson.build
Expand Up @@ -121,11 +121,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
Expand Down Expand Up @@ -155,6 +152,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()
Expand Down
4 changes: 1 addition & 3 deletions examples/meson.build
Expand Up @@ -6,8 +6,6 @@ if get_option('default_library') == 'static'
driver_libs = 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',
Expand Down Expand Up @@ -81,7 +79,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']
if is_windows
Expand Down

0 comments on commit 7f254be

Please sign in to comment.