Skip to content

Commit

Permalink
build: fix plugin load on static build
Browse files Browse the repository at this point in the history
[ upstream commit b031e13 ]

When dpdk is compiled as static libraries, it is not possible
to load a plugin from an application. We get the following error:

  EAL: librte_pmd_xxxx.so: undefined symbol: per_lcore__rte_errno

This happens because the dpdk symbols are not exported. Add them to the
dynamic symbol table by using '-Wl,--export-dynamic'. This option was
previously present when compiled with Makefiles, it was introduced in
commit f9a08f6 ("eal: add support for shared object drivers")

Also add it to the pkg-config file.

Fixes: 16ade73 ("app/testpmd: build with meson")
Fixes: 89f0711 ("examples: build some samples with meson")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
  • Loading branch information
olivier-matz-6wind authored and bluca committed Feb 2, 2021
1 parent ac97254 commit 937675e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ apps = [
lib_execinfo = cc.find_library('execinfo', required: false)

default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
default_ldflags = []
if get_option('default_library') == 'static'
default_ldflags += ['-Wl,--export-dynamic']
endif

foreach app:apps
build = true
name = app
sources = []
includes = []
cflags = default_cflags
ldflags = default_ldflags
objs = [] # other object files to link against, used e.g. for
# instruction-set optimized versions of code

Expand All @@ -58,6 +63,7 @@ foreach app:apps
executable('dpdk-' + name,
sources,
c_args: cflags,
link_args: ldflags,
link_whole: link_libs,
dependencies: dep_objs,
install_rpath: join_paths(get_option('prefix'),
Expand Down
2 changes: 1 addition & 1 deletion buildtools/pkg-config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This is required for a number of static inline functions in the public headers.'
# if libbsd is not enabled, then this is blank
libraries_private: ['-Wl,--whole-archive'] +
dpdk_drivers + dpdk_static_libraries +
['-Wl,--no-whole-archive']
['-Wl,--no-whole-archive', '-Wl,--export-dynamic']
)

# For static linking with dependencies as shared libraries,
Expand Down
7 changes: 6 additions & 1 deletion examples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ default_cflags = machine_args
if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
default_ldflags = dpdk_extra_ldflags
if get_option('default_library') == 'static'
default_ldflags += ['-Wl,--export-dynamic']
endif

foreach example: examples
name = example.split('/')[-1]
build = true
sources = []
allow_experimental_apis = false
cflags = default_cflags
ldflags = default_ldflags

ext_deps = [execinfo]
includes = [include_directories(example)]
Expand All @@ -91,7 +96,7 @@ foreach example: examples
executable('dpdk-' + name, sources,
include_directories: includes,
link_whole: link_whole_libs,
link_args: dpdk_extra_ldflags,
link_args: ldflags,
c_args: cflags,
dependencies: dep_objs)
elif not allow_skips
Expand Down

0 comments on commit 937675e

Please sign in to comment.