patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Harry van Haaren <harry.van.haaren@intel.com>,
	Keith Wiles <keith.wiles@intel.com>,
	Luca Boccassi <luca.boccassi@gmail.com>,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH] app: fix plugin load on static builds
Date: Thu, 26 Nov 2020 15:20:42 +0100	[thread overview]
Message-ID: <20201126142042.24741-1-olivier.matz@6wind.com> (raw)

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>
---

Hi,

Maybe the patch can be improved: I suppose that --export-dynamic
should only be added in case we are linking in static mode. Any
help about how to do that is welcome.

There is probably a better place to define the default ldflags for
all applications (to factorize between app and example).

Also, should this flag be advertised in pkg-config?

Thanks,
Olivier


 app/meson.build      | 3 +++
 examples/meson.build | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/meson.build b/app/meson.build
index eb74f215a3..92479c7729 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -25,6 +25,7 @@ apps = [
 lib_execinfo = cc.find_library('execinfo', required: false)
 
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
+default_ldflags = ['-Wl,--export-dynamic']
 
 foreach app:apps
 	build = true
@@ -32,6 +33,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 +60,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'),
diff --git a/examples/meson.build b/examples/meson.build
index 46ec80919e..def4540e8f 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -63,6 +63,7 @@ default_cflags = machine_args
 if cc.has_argument('-Wno-format-truncation')
 	default_cflags += '-Wno-format-truncation'
 endif
+default_ldflags = ['-Wl,--export-dynamic'] + dpdk_extra_ldflags
 
 foreach example: examples
 	name = example.split('/')[-1]
@@ -70,6 +71,7 @@ foreach example: examples
 	sources = []
 	allow_experimental_apis = false
 	cflags = default_cflags
+	ldflags = default_ldflags
 
 	ext_deps = [execinfo]
 	includes = [include_directories(example)]
@@ -91,7 +93,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
-- 
2.25.1


             reply	other threads:[~2020-11-26 14:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26 14:20 Olivier Matz [this message]
2020-11-26 15:28 ` Bruce Richardson
2020-11-26 16:32   ` Olivier Matz
2020-11-26 16:37     ` Bruce Richardson
2020-11-26 17:07       ` Thomas Monjalon
2020-11-26 17:13         ` Olivier Matz
2020-11-26 17:15         ` Bruce Richardson
2020-12-18 12:52 ` [dpdk-stable] [PATCH v2] " Olivier Matz
2020-12-18 13:14 ` [dpdk-stable] [PATCH v3] build: " Olivier Matz
2020-12-21 11:04   ` Bruce Richardson
2021-01-05 21:46     ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201126142042.24741-1-olivier.matz@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=keith.wiles@intel.com \
    --cc=luca.boccassi@gmail.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).