app: fix plugin load on static builds
authorOlivier Matz <olivier.matz@6wind.com>
Tue, 17 Nov 2020 13:57:16 +0000 (14:57 +0100)
committerOlivier Matz <olivier.matz@6wind.com>
Thu, 26 Nov 2020 17:05:18 +0000 (18:05 +0100)
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 f9a08f650211 ("eal: add support for shared object drivers")

Fixes: 16ade738fd0d ("app/testpmd: build with meson")
Fixes: 89f0711f9ddf ("examples: build some samples with meson")
Cc: stable@dpdk.org
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
app/meson.build
examples/meson.build

index eb74f21..fd72d7d 100644 (file)
@@ -25,6 +25,10 @@ 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
@@ -32,6 +36,7 @@ foreach app:apps
        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
 
@@ -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'),
index 46ec809..f643ec1 100644 (file)
@@ -63,6 +63,10 @@ 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]
@@ -70,6 +74,7 @@ foreach example: examples
        sources = []
        allow_experimental_apis = false
        cflags = default_cflags
+       ldflags = default_ldflags
 
        ext_deps = [execinfo]
        includes = [include_directories(example)]
@@ -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