From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: luca.boccassi@gmail.com, aconole@redhat.com,
Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 3/6] build: build all libs and drivers as both static and shared
Date: Tue, 12 Dec 2017 16:59:37 +0000 [thread overview]
Message-ID: <20171212165940.272969-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20171212165940.272969-1-bruce.richardson@intel.com>
This patch changes the build process to group all .o files for a driver or
library into a static archive first, and then link the .o files together
into a shared library. This eliminates the need for separate static or
shared object builds when packaging, for instance.
The "default_library" configuration option now only affects the apps and
examples, which are either linked against the static or shared library
versions depending on the value of the option.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test-pmd/meson.build | 4 ++--
drivers/meson.build | 43 +++++++++++++++++++++++++++-----------
drivers/net/e1000/base/meson.build | 2 +-
drivers/net/fm10k/base/meson.build | 2 +-
drivers/net/i40e/base/meson.build | 2 +-
drivers/net/ixgbe/base/meson.build | 2 +-
examples/meson.build | 2 +-
lib/meson.build | 37 ++++++++++++++++++++++++--------
meson.build | 22 +++++++------------
9 files changed, 73 insertions(+), 43 deletions(-)
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 3e591683d..b1820c77d 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -46,7 +46,7 @@ sources = files('cmdline.c',
'testpmd.c',
'txonly.c')
-deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter']
+deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
if dpdk_conf.has('RTE_LIBRTE_PDUMP')
deps += 'pdump'
endif
@@ -63,7 +63,7 @@ endif
dep_objs = []
foreach d:deps
- dep_objs += get_variable('dep_rte_' + d)
+ dep_objs += get_variable(get_option('default_library') + '_rte_' + d)
endforeach
link_libs = []
diff --git a/drivers/meson.build b/drivers/meson.build
index 889058d19..bb9a23523 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -69,11 +69,14 @@ foreach class:driver_classes
dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
# get dependency objs from strings
- dep_objs = []
+ shared_objs = []
+ static_objs = []
foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
+ shared_objs += [get_variable('shared_rte_' + d)]
+ static_objs += [get_variable('static_rte_' + d)]
endforeach
- dep_objs += ext_deps
+ shared_objs += ext_deps
+ static_objs += ext_deps
dpdk_extra_ldflags += pkgconfig_extra_libs
# generate pmdinfo sources
@@ -83,7 +86,7 @@ foreach class:driver_classes
out_filename = '@0@.pmd.c'.format(src.split('/')[-1])
tmp_lib = static_library('tmp_@0@'.format(src.underscorify()),
src, include_directories: includes,
- dependencies: dep_objs,
+ dependencies: static_objs,
c_args: cflags)
sources += custom_target(out_filename,
command: [pmdinfo, tmp_lib.full_path(),
@@ -102,16 +105,27 @@ foreach class:driver_classes
so_version = lib_version
endif
- # now build the driver itself, and add to the drivers list
+ # now build the static driver
lib_name = driver_name_fmt.format(name)
+ static_lib = static_library(lib_name,
+ sources,
+ objects: objs,
+ include_directories: includes,
+ dependencies: static_objs,
+ c_args: cflags,
+ install: true)
+
+ # now build the shared driver
+ sources = []
+ objs += static_lib.extract_all_objects()
version_map = '@0@/@1@/@2@_version.map'.format(
meson.current_source_dir(),
drv_path, lib_name)
- lib = library(lib_name,
+ shared_lib = shared_library(lib_name,
sources,
objects: objs,
include_directories: includes,
- dependencies: dep_objs,
+ dependencies: shared_objs,
c_args: cflags,
link_args: '-Wl,--version-script=' + version_map,
link_depends: version_map,
@@ -120,14 +134,19 @@ foreach class:driver_classes
install: true,
install_dir: driver_install_path)
- dpdk_drivers += lib
-
# create a dependency object and add it to the global dictionary so
# testpmd or other built-in apps can find it if necessary
- set_variable('dep_@0@'.format(lib_name),
- declare_dependency(link_with: lib,
+ shared_dep = declare_dependency(link_with: shared_lib,
+ include_directories: includes,
+ dependencies: shared_objs)
+ static_dep = declare_dependency(link_with: static_lib,
include_directories: includes,
- dependencies: dep_objs))
+ dependencies: static_objs)
+
+ dpdk_drivers += static_lib
+
+ set_variable('shared_@0@'.format(lib_name), shared_dep)
+ set_variable('static_@0@'.format(lib_name), static_dep)
endif # build
endforeach
endforeach
diff --git a/drivers/net/e1000/base/meson.build b/drivers/net/e1000/base/meson.build
index 7c0710ec9..dfd2b914c 100644
--- a/drivers/net/e1000/base/meson.build
+++ b/drivers/net/e1000/base/meson.build
@@ -60,6 +60,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('e1000_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/fm10k/base/meson.build b/drivers/net/fm10k/base/meson.build
index 8a371b6ca..490f64918 100644
--- a/drivers/net/fm10k/base/meson.build
+++ b/drivers/net/fm10k/base/meson.build
@@ -50,6 +50,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('fm10k_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/i40e/base/meson.build b/drivers/net/i40e/base/meson.build
index 8b491ad89..9128a9c61 100644
--- a/drivers/net/i40e/base/meson.build
+++ b/drivers/net/i40e/base/meson.build
@@ -51,6 +51,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('i40e_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/ixgbe/base/meson.build b/drivers/net/ixgbe/base/meson.build
index 1781f2eb3..3d0404bd0 100644
--- a/drivers/net/ixgbe/base/meson.build
+++ b/drivers/net/ixgbe/base/meson.build
@@ -55,6 +55,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('ixgbe_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/examples/meson.build b/examples/meson.build
index a17241817..d5397cdd0 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -45,7 +45,7 @@ foreach example: get_option('examples').split(',')
dep_objs = ext_deps
foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
+ dep_objs += [get_variable(get_option('default_library') + '_rte_' + d)]
endforeach
executable('dpdk-' + name, sources,
include_directories: includes,
diff --git a/lib/meson.build b/lib/meson.build
index 76cac1023..d12816f55 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -83,11 +83,14 @@ foreach l:libraries
if sources.length() == 0
# if no C files, just set a dependency on header path
- dep = declare_dependency(include_directories: includes)
+ shared_dep = declare_dependency(include_directories: includes)
+ static_dep = shared_dep
else
- dep_objs = ext_deps
+ shared_deps = ext_deps
+ static_deps = ext_deps
foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
+ shared_deps += [get_variable('shared_rte_' + d)]
+ static_deps += [get_variable('static_rte_' + d)]
endforeach
if get_option('per_library_versions')
@@ -100,26 +103,42 @@ foreach l:libraries
so_version = lib_version
endif
+ # first build static lib
+ static_lib = static_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: static_deps,
+ include_directories: includes,
+ install: true)
+ static_dep = declare_dependency(link_with: static_lib,
+ include_directories: includes,
+ dependencies: static_deps)
+
+ # then use pre-build objects to build shared lib
+ sources = []
+ objs += static_lib.extract_all_objects()
version_map = '@0@/@1@/rte_@2@_version.map'.format(
meson.current_source_dir(), dir_name, name)
- lib = library(libname,
+ shared_lib = shared_library(libname,
sources,
objects: objs,
c_args: cflags,
- dependencies: dep_objs,
+ dependencies: shared_deps,
include_directories: includes,
link_args: '-Wl,--version-script=' + version_map,
link_depends: version_map,
version: lib_version,
soversion: so_version,
install: true)
- dep = declare_dependency(link_with: lib,
+ shared_dep = declare_dependency(link_with: shared_lib,
include_directories: includes,
- dependencies: dep_objs)
+ dependencies: shared_deps)
- dpdk_libraries = [lib] + dpdk_libraries
+ dpdk_libraries = [shared_lib] + dpdk_libraries
endif # sources.length() > 0
- set_variable('dep_' + libname, dep)
+ set_variable('shared_' + libname, shared_dep)
+ set_variable('static_' + libname, static_dep)
endif # if build
endforeach
diff --git a/meson.build b/meson.build
index ad9eabb0f..28d37ff7a 100644
--- a/meson.build
+++ b/meson.build
@@ -43,15 +43,8 @@ dpdk_libraries = []
dpdk_drivers = []
dpdk_extra_ldflags = []
-# for static libs, treat the drivers as regular libraries, otherwise
-# for shared libs, put them in a driver folder
-if get_option('default_library') == 'static'
- driver_install_path = get_option('libdir')
- eal_pmd_path = ''
-else
- driver_install_path = join_paths(get_option('libdir'), 'dpdk/drivers')
- eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
-endif
+driver_install_path = join_paths(get_option('libdir'), 'dpdk/drivers')
+eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
# configure the build, and make sure configs here and in config folder are
# able to be included in any file. We also store a global array of include dirs
@@ -80,18 +73,17 @@ configure_file(output: build_cfg,
install_dir: join_paths(get_option('includedir'),
get_option('include_subdir_arch')))
-# for static builds, include the drivers as libs, and also any
-# other dependent libs that DPDK needs to link against
-if get_option('default_library') == 'static'
- dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
- dpdk_libraries = dpdk_drivers + dpdk_libraries + dpdk_extra_ldflags
-endif
+# for static builds, include the drivers as libs and we need to "whole-archive"
+# them.
+dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
pkg = import('pkgconfig')
pkg.generate(name: meson.project_name(),
filebase: 'lib' + meson.project_name().to_lower(),
version: meson.project_version(),
libraries: dpdk_libraries,
+ libraries_private: dpdk_drivers + dpdk_libraries +
+ ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
description: 'The Data Plane Development Kit (DPDK)',
subdirs: [get_option('include_subdir_arch'), '.'],
extra_cflags: ['-include "rte_config.h"', '-march=@0@'.format(machine)]
--
2.14.3
next prev parent reply other threads:[~2017-12-12 17:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 16:59 [dpdk-dev] [PATCH 0/6] next-build: create both static and shared libs Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 1/6] build: remove library special cases Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 2/6] eal: fix list of source files to meson build Bruce Richardson
2017-12-12 16:59 ` Bruce Richardson [this message]
2017-12-12 16:59 ` [dpdk-dev] [PATCH 4/6] build: change default library type to static Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 5/6] build: symlink drivers to library directory Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 6/6] examples: enable linking examples both static and shared Bruce Richardson
2017-12-12 17:14 ` [dpdk-dev] [PATCH 0/6] next-build: create both static and shared libs Bruce Richardson
2017-12-13 12:10 ` Luca Boccassi
2017-12-13 13:28 ` Bruce Richardson
2017-12-18 18:05 ` Aaron Conole
2017-12-19 10:07 ` Bruce Richardson
2017-12-13 12:11 ` Luca Boccassi
2017-12-15 12:02 ` Bruce Richardson
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=20171212165940.272969-4-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=aconole@redhat.com \
--cc=dev@dpdk.org \
--cc=luca.boccassi@gmail.com \
/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).