* [dpdk-stable] [PATCH 18.11 1/1] build: enable BSD features visibility for FreeBSD
2019-09-25 17:12 [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE Kevin Traynor
@ 2019-09-25 17:12 ` Kevin Traynor
2019-09-25 18:03 ` Luca Boccassi
2019-09-26 8:19 ` [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE Richardson, Bruce
2019-09-26 13:19 ` Kevin Traynor
2 siblings, 1 reply; 5+ messages in thread
From: Kevin Traynor @ 2019-09-25 17:12 UTC (permalink / raw)
To: stable, marcinx.smoczynski, konstantin.ananyev, ferruh.yigit, salehals
Cc: bluca, bruce.richardson
From: Marcin Smoczynski <marcinx.smoczynski@intel.com>
[ 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
[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>
---
app/meson.build | 3 ---
config/meson.build | 8 ++++++++
drivers/meson.build | 3 ---
examples/meson.build | 3 ---
lib/meson.build | 3 ---
meson.build | 6 +++++-
mk/target/generic/rte.vars.mk | 5 +++++
7 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/app/meson.build b/app/meson.build
index a9a026bbf..fd5f701b3 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -14,7 +14,4 @@ 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
diff --git a/config/meson.build b/config/meson.build
index 80d253828..fd263b848 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -136,2 +136,10 @@ 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 c3c66bbc0..f965c33e7 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -18,7 +18,4 @@ if cc.has_argument('-Wno-format-truncation')
endif
-# specify -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach class:driver_classes
drivers = []
diff --git a/examples/meson.build b/examples/meson.build
index af81c762e..2809e2261 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -24,7 +24,4 @@ if cc.has_argument('-Wno-format-truncation')
endif
-# specify -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach example: examples
name = example
diff --git a/lib/meson.build b/lib/meson.build
index df4226c51..62b5cdfe8 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -35,7 +35,4 @@ endif
enabled_libs = [] # used to print summary at the end
-# -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
-
foreach l:libraries
build = true
diff --git a/meson.build b/meson.build
index abe76f7b7..beb599d2f 100644
--- a/meson.build
+++ b/meson.build
@@ -71,4 +71,8 @@ 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(),
@@ -81,5 +85,5 @@ 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
)
diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk
index dd149acc9..ca38d4181 100644
--- a/mk/target/generic/rte.vars.mk
+++ b/mk/target/generic/rte.vars.mk
@@ -112,4 +112,9 @@ endif
CFLAGS += -D_GNU_SOURCE
+# define __BSD_VISIBLE when building for FreeBSD
+ifeq ($(CONFIG_RTE_EXEC_ENV_FREEBSD),y)
+CFLAGS += -D__BSD_VISIBLE
+endif
+
export CFLAGS
export LDFLAGS
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE
2019-09-25 17:12 [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE Kevin Traynor
2019-09-25 17:12 ` [dpdk-stable] [PATCH 18.11 1/1] build: enable BSD features visibility for FreeBSD Kevin Traynor
@ 2019-09-26 8:19 ` Richardson, Bruce
2019-09-26 13:19 ` Kevin Traynor
2 siblings, 0 replies; 5+ messages in thread
From: Richardson, Bruce @ 2019-09-26 8:19 UTC (permalink / raw)
To: Kevin Traynor, stable, Smoczynski, MarcinX, Ananyev, Konstantin,
Yigit, Ferruh, salehals
Cc: bluca
+1 for the backport for the visibility change for BSD.
> -----Original Message-----
> From: Kevin Traynor [mailto:ktraynor@redhat.com]
> Sent: Wednesday, September 25, 2019 6:13 PM
> To: stable@dpdk.org; Smoczynski, MarcinX <marcinx.smoczynski@intel.com>;
> Ananyev, Konstantin <konstantin.ananyev@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; salehals@mellanox.com
> Cc: bluca@debian.org; Richardson, Bruce <bruce.richardson@intel.com>;
> Kevin Traynor <ktraynor@redhat.com>
> Subject: [PATCH 18.11 0/1] Enable __BSD_VISIBLE
>
> This backport is needed for 18.11 as the below commit
> [Fixes: 54e4657b2385 ("net: define IPv4 IHL and VHL")] requires that
> __BSD_VISIBLE is defined for <sys/types.h> in FreeBSD.
>
> Otherwise, there is a build error on FreeBSD similar to the one originally
> reported here http://inbox.dpdk.org/stable/3d694042-dbe9-7560-5912-
> d865da048c7c@intel.com/
>
> The other option is to revert the following commits from branch 18.11.
>
> commit d8084ac1f9c74ce9fe61b26c9d4198d872d5fc7e
> Author: Saleh Alsouqi <salehals@mellanox.com>
> Date: Thu Jul 4 07:33:22 2019 +0000
>
> app/testpmd: fix MPLS IPv4 encapsulation fields
>
> [ upstream commit a97ec9ba45d4357c172df71be3fcf601dfdb8147 ]
>
> Having version and ihl set to 0 would result in a
> corrupted/incorrect encapsulating packet for MPLS,
> this commit sets these fields to 4 and 5 respectively
> as defined in librte_net/rte_ip.h.
>
> Fixes: 3e77031be855 ("app/testpmd: add MPLSoGRE encapsulation")
> Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation")
>
> Signed-off-by: Saleh Alsouqi <salehals@mellanox.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
> commit 54e4657b238593c633367a2dda48ecf4e04249bb
> Author: Saleh Alsouqi <salehals@mellanox.com>
> Date: Thu Jul 4 07:33:19 2019 +0000
>
> net: define IPv4 IHL and VHL
>
> [ upstream commit 2318d8d5456532e8022d324937a77a416b701d2b ]
>
> Define IPv4 Minimum IHL and VHL according to rfc791 (see [1])
>
> "The Version field indicates the format of the
> internet header."
>
> "Internet Header Length (ihl) is the length of the
> internet header in 32 bit words, and thus points
> to the beginning of the data. Note that
> the minimum value for a correct header is 5."
>
> [1] https://tools.ietf.org/html/rfc791
>
> Signed-off-by: Saleh Alsouqi <salehals@mellanox.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
> Marcin Smoczynski (1):
> build: enable BSD features visibility for FreeBSD
>
> app/meson.build | 3 ---
> config/meson.build | 8 ++++++++
> drivers/meson.build | 3 ---
> examples/meson.build | 3 ---
> lib/meson.build | 3 ---
> meson.build | 6 +++++-
> mk/target/generic/rte.vars.mk | 5 +++++
> 7 files changed, 18 insertions(+), 13 deletions(-)
>
> --
> 2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE
2019-09-25 17:12 [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE Kevin Traynor
2019-09-25 17:12 ` [dpdk-stable] [PATCH 18.11 1/1] build: enable BSD features visibility for FreeBSD Kevin Traynor
2019-09-26 8:19 ` [dpdk-stable] [PATCH 18.11 0/1] Enable __BSD_VISIBLE Richardson, Bruce
@ 2019-09-26 13:19 ` Kevin Traynor
2 siblings, 0 replies; 5+ messages in thread
From: Kevin Traynor @ 2019-09-26 13:19 UTC (permalink / raw)
To: stable, marcinx.smoczynski, konstantin.ananyev, ferruh.yigit, salehals
Cc: bluca, bruce.richardson
On 25/09/2019 18:12, Kevin Traynor wrote:
> This backport is needed for 18.11 as the below commit
> [Fixes: 54e4657b2385 ("net: define IPv4 IHL and VHL")]
> requires that __BSD_VISIBLE is defined for <sys/types.h>
> in FreeBSD.
>
Thanks Luca and Bruce.
Re-tested on FreeBSD12 with clang and gcc.
s/CONFIG_RTE_EXEC_ENV_FREEBSD/CONFIG_RTE_EXEC_ENV_BSDAPP/ and pushed to
18.11 branch.
> Otherwise, there is a build error on FreeBSD similar to the one
> originally reported here
> http://inbox.dpdk.org/stable/3d694042-dbe9-7560-5912-d865da048c7c@intel.com/
>
> The other option is to revert the following commits from branch 18.11.
>
> commit d8084ac1f9c74ce9fe61b26c9d4198d872d5fc7e
> Author: Saleh Alsouqi <salehals@mellanox.com>
> Date: Thu Jul 4 07:33:22 2019 +0000
>
> app/testpmd: fix MPLS IPv4 encapsulation fields
>
> [ upstream commit a97ec9ba45d4357c172df71be3fcf601dfdb8147 ]
>
> Having version and ihl set to 0 would result in a
> corrupted/incorrect encapsulating packet for MPLS,
> this commit sets these fields to 4 and 5 respectively
> as defined in librte_net/rte_ip.h.
>
> Fixes: 3e77031be855 ("app/testpmd: add MPLSoGRE encapsulation")
> Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation")
>
> Signed-off-by: Saleh Alsouqi <salehals@mellanox.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
> commit 54e4657b238593c633367a2dda48ecf4e04249bb
> Author: Saleh Alsouqi <salehals@mellanox.com>
> Date: Thu Jul 4 07:33:19 2019 +0000
>
> net: define IPv4 IHL and VHL
>
> [ upstream commit 2318d8d5456532e8022d324937a77a416b701d2b ]
>
> Define IPv4 Minimum IHL and VHL according to rfc791 (see [1])
>
> "The Version field indicates the format of the
> internet header."
>
> "Internet Header Length (ihl) is the length of the
> internet header in 32 bit words, and thus points
> to the beginning of the data. Note that
> the minimum value for a correct header is 5."
>
> [1] https://tools.ietf.org/html/rfc791
>
> Signed-off-by: Saleh Alsouqi <salehals@mellanox.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
> Marcin Smoczynski (1):
> build: enable BSD features visibility for FreeBSD
>
> app/meson.build | 3 ---
> config/meson.build | 8 ++++++++
> drivers/meson.build | 3 ---
> examples/meson.build | 3 ---
> lib/meson.build | 3 ---
> meson.build | 6 +++++-
> mk/target/generic/rte.vars.mk | 5 +++++
> 7 files changed, 18 insertions(+), 13 deletions(-)
>
^ permalink raw reply [flat|nested] 5+ messages in thread