From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B1730A09FD; Fri, 18 Dec 2020 14:15:08 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0AC0CCADE; Fri, 18 Dec 2020 14:14:44 +0100 (CET) Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id B3C72CAD2; Fri, 18 Dec 2020 14:14:41 +0100 (CET) Received: from glumotte.dev.6wind.com. (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 80E884AC36A; Fri, 18 Dec 2020 14:14:41 +0100 (CET) From: Olivier Matz To: dev@dpdk.org Cc: bruce.richardson@intel.com, harry.van.haaren@intel.com, keith.wiles@intel.com, luca.boccassi@gmail.com, olivier.matz@6wind.com, stable@dpdk.org, thomas@monjalon.net Date: Fri, 18 Dec 2020 14:14:22 +0100 Message-Id: <20201218131422.15131-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201126142042.24741-1-olivier.matz@6wind.com> References: <20201126142042.24741-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3] build: fix plugin load on static builds X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Also add it to the pkg-config file. Fixes: 16ade738fd0d ("app/testpmd: build with meson") Fixes: 89f0711f9ddf ("examples: build some samples with meson") Cc: stable@dpdk.org Signed-off-by: Olivier Matz --- v2 * only set examples/applications flags if build is static v3 * add missing pkg-config part in previous version app/meson.build | 6 ++++++ buildtools/pkg-config/meson.build | 2 +- examples/meson.build | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/meson.build b/app/meson.build index eb74f215a3..fd72d7da68 100644 --- a/app/meson.build +++ b/app/meson.build @@ -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'), diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build index 5f19304289..168ee08e58 100644 --- a/buildtools/pkg-config/meson.build +++ b/buildtools/pkg-config/meson.build @@ -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, diff --git a/examples/meson.build b/examples/meson.build index 46ec80919e..f643ec1bad 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -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 -- 2.25.1