summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Smoczynski <marcinx.smoczynski@intel.com>2019-05-14 16:04:16 +0200
committerKevin Traynor <ktraynor@redhat.com>2019-09-26 13:49:10 +0100
commitd908ee9de303b1c4f22410f0fd5be710ae1eb5fc (patch)
tree9a9d2a95db3af6aa8a89453bdbc79113c04966da
parent69ac7ce1e1d26e2569915166465c3323c402b2f3 (diff)
downloaddpdk-stable-d908ee9de303b1c4f22410f0fd5be710ae1eb5fc.zip
dpdk-stable-d908ee9de303b1c4f22410f0fd5be710ae1eb5fc.tar.gz
dpdk-stable-d908ee9de303b1c4f22410f0fd5be710ae1eb5fc.tar.xz
build: enable BSD features visibility for FreeBSD
[ upstream commit 28188cee2aa0b72d401d3e56942d0db9c7b9e654] When a component uses either XOPEN_SOURCE or POSIX_C_SOURCE macro explicitly in its build recipe, it restricts visibility of a non POSIX features subset, such as IANA protocol numbers (IPPROTO_* macros). Non standard features are enabled by default for DPDK both for Linux thanks to _GNU_SOURCE and for FreeBSD thanks to __BSD_VISIBLE. However using XOPEN_SOURCE or POSIX_(C_)SOURCE in a component causes __BSD_VISIBLE to be defined to 0 for FreeBSD, causing different feature sets visibility for Linux and FreeBSD. It restricts from using IPPROTO macros in public headers, such as rte_ip.h, despite the fact they are already widely used in sources. Add __BSD_VISIBLE macro specified unconditionally for FreeBSD targets which enforces feature sets visibility unification between Linux and FreeBSD. Add single -D_GNU_SOURCE to config/meson.build as a project argument instead of adding separate directive for each project subtree. This patch solves the problem of build breaks for [1] on FreeBSD [2] following the discussion [3]. [1] https://mails.dpdk.org/archives/dev/2019-May/131885.html [2] http://mails.dpdk.org/archives/test-report/2019-May/082263.html [3] https://mails.dpdk.org/archives/dev/2019-May/132110.html [branch 18.11] The following 18.11 branch commit needs __BSD_VISIBLE to be defined, so backporting this commit to 18.11 branch. Fixes: 54e4657b2385 ("net: define IPv4 IHL and VHL") Signed-off-by: Marcin Smoczynski <marcinx.smoczynski@intel.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Acked-by: Luca Boccassi <bluca@debian.org>
-rw-r--r--app/meson.build3
-rw-r--r--config/meson.build8
-rw-r--r--drivers/meson.build3
-rw-r--r--examples/meson.build3
-rw-r--r--lib/meson.build3
-rw-r--r--meson.build6
-rw-r--r--mk/target/generic/rte.vars.mk5
7 files changed, 18 insertions, 13 deletions
diff --git a/app/meson.build b/app/meson.build
index a9a026b..fd5f701 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -13,9 +13,6 @@ lib_execinfo = cc.find_library('execinfo', required: false)
default_cflags = machine_args
-# specify -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach app:apps
build = true
name = app
diff --git a/config/meson.build b/config/meson.build
index 80d2538..fd263b8 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -135,3 +135,11 @@ install_headers('rte_config.h', subdir: get_option('include_subdir_arch'))
# enable VFIO only if it is linux OS
dpdk_conf.set('RTE_EAL_VFIO', host_machine.system() == 'linux')
+
+# specify -D_GNU_SOURCE unconditionally
+add_project_arguments('-D_GNU_SOURCE', language: 'c')
+
+# specify -D__BSD_VISIBLE for FreeBSD
+if host_machine.system() == 'freebsd'
+ add_project_arguments('-D__BSD_VISIBLE', language: 'c')
+endif
diff --git a/drivers/meson.build b/drivers/meson.build
index c3c66bb..f965c33 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -17,9 +17,6 @@ if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
-# specify -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach class:driver_classes
drivers = []
std_deps = []
diff --git a/examples/meson.build b/examples/meson.build
index af81c76..2809e22 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -23,9 +23,6 @@ if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
-# specify -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach example: examples
name = example
build = true
diff --git a/lib/meson.build b/lib/meson.build
index df4226c..62b5cdf 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -34,9 +34,6 @@ endif
enabled_libs = [] # used to print summary at the end
-# -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach l:libraries
build = true
name = l
diff --git a/meson.build b/meson.build
index abe76f7..beb599d 100644
--- a/meson.build
+++ b/meson.build
@@ -70,6 +70,10 @@ configure_file(output: build_cfg,
dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
pkg = import('pkgconfig')
+pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
+if host_machine.system() == 'freebsd'
+ pkg_extra_cflags += ['-D__BSD_VISIBLE']
+endif
pkg.generate(name: meson.project_name(),
filebase: 'lib' + meson.project_name().to_lower(),
version: meson.project_version(),
@@ -80,7 +84,7 @@ pkg.generate(name: meson.project_name(),
Note that CFLAGS might contain an -march flag higher than typical baseline.
This is required for a number of static inline functions in the public headers.''',
subdirs: [get_option('include_subdir_arch'), '.'],
- extra_cflags: ['-include', 'rte_config.h'] + machine_args
+ extra_cflags: pkg_extra_cflags
)
# final output, list all the libs and drivers to be built
diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk
index dd149ac..3f40396 100644
--- a/mk/target/generic/rte.vars.mk
+++ b/mk/target/generic/rte.vars.mk
@@ -111,6 +111,11 @@ endif
# always define _GNU_SOURCE
CFLAGS += -D_GNU_SOURCE
+# define __BSD_VISIBLE when building for FreeBSD
+ifeq ($(CONFIG_RTE_EXEC_ENV_BSDAPP),y)
+CFLAGS += -D__BSD_VISIBLE
+endif
+
export CFLAGS
export LDFLAGS