DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: "Bruce Richardson" <bruce.richardson@intel.com>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Tyler Retzlaff" <roretzla@linux.microsoft.com>
Subject: [PATCH v4] build: update DPDK to use C11 standard
Date: Tue,  1 Aug 2023 14:15:49 +0100	[thread overview]
Message-ID: <20230801131549.323733-1-bruce.richardson@intel.com> (raw)
In-Reply-To: <20230731103858.1491751-1-bruce.richardson@intel.com>

As previously announced, DPDK 23.11 will require a C11 supporting
compiler and will use the C11 standard in all builds.

Forcing use of the C standard, rather than the standard with
GNU extensions, means that some posix definitions which are not in
the C standard are unavailable by default. We fix this by ensuring
the correct defines or cflags are passed to the components that
need them.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
V4:
* pass cflags to the structure and definition checks in mlx* drivers
  to ensure posix definitions - as well as C-standard ones - are
  available.

V3:
* remove (now unneeded) use of -std=gnu99 in failsafe net driver.

V2:
* Resubmit now that 23.11-rc0 patch applied
* Add _POSIX_C_SOURCE macro to eal_common_errno.c to get POSIX
  definition of strerror_r() with c11 standard.
---
 doc/guides/linux_gsg/sys_reqs.rst      |  3 ++-
 doc/guides/rel_notes/deprecation.rst   | 18 ------------------
 doc/guides/rel_notes/release_23_11.rst | 17 +++++++++++++++++
 drivers/common/mlx5/linux/meson.build  |  5 +++--
 drivers/net/failsafe/meson.build       |  1 -
 drivers/net/mlx4/meson.build           |  4 ++--
 lib/eal/common/eal_common_errno.c      |  1 +
 meson.build                            |  1 +
 8 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/doc/guides/linux_gsg/sys_reqs.rst b/doc/guides/linux_gsg/sys_reqs.rst
index dfeaf4e1c5..13be715933 100644
--- a/doc/guides/linux_gsg/sys_reqs.rst
+++ b/doc/guides/linux_gsg/sys_reqs.rst
@@ -27,7 +27,8 @@ Compilation of the DPDK
     The setup commands and installed packages needed on various systems may be different.
     For details on Linux distributions and the versions tested, please consult the DPDK Release Notes.
 
-*   General development tools including a supported C compiler such as gcc (version 4.9+) or clang (version 3.4+),
+*   General development tools including a C compiler supporting the C11 standard,
+    including standard atomics, for example: GCC (version 5.0+) or Clang (version 3.6+),
     and ``pkg-config`` or ``pkgconf`` to be used when building end-user binaries against DPDK.
 
     * For RHEL/Fedora systems these can be installed using ``dnf groupinstall "Development Tools"``
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 494b401cda..cc939d3c67 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -17,24 +17,6 @@ Other API and ABI deprecation notices are to be posted below.
 Deprecation Notices
 -------------------
 
-* C Compiler: From DPDK 23.11 onwards,
-  building DPDK will require a C compiler which supports the C11 standard,
-  including support for C11 standard atomics.
-
-  More specifically, the requirements will be:
-
-  * Support for flag "-std=c11" (or similar)
-  * __STDC_NO_ATOMICS__ is *not defined* when using c11 flag
-
-  Please note:
-
-  * C11, including standard atomics, is supported from GCC version 5 onwards,
-    and is the default language version in that release
-    (Ref: https://gcc.gnu.org/gcc-5/changes.html)
-  * C11 is the default compilation mode in Clang from version 3.6,
-    which also added support for standard atomics
-    (Ref: https://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html)
-
 * build: Enabling deprecated libraries (``flow_classify``, ``kni``)
   won't be possible anymore through the use of the ``disable_libs`` build option.
   A new build option for deprecated libraries will be introduced instead.
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 6b4dd21fd0..c8b9ed456c 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -20,6 +20,23 @@ DPDK Release 23.11
       ninja -C build doc
       xdg-open build/doc/guides/html/rel_notes/release_23_11.html
 
+* Build Requirements: From DPDK 23.11 onwards,
+  building DPDK will require a C compiler which supports the C11 standard,
+  including support for C11 standard atomics.
+
+  More specifically, the requirements will be:
+
+  * Support for flag "-std=c11" (or similar)
+  * __STDC_NO_ATOMICS__ is *not defined* when using c11 flag
+
+  Please note:
+
+  * C11, including standard atomics, is supported from GCC version 5 onwards,
+    and is the default language version in that release
+    (Ref: https://gcc.gnu.org/gcc-5/changes.html)
+  * C11 is the default compilation mode in Clang from version 3.6,
+    which also added support for standard atomics
+    (Ref: https://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html)
 
 New Features
 ------------
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 15edc13041..b3a64547c5 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -231,11 +231,12 @@ if  libmtcr_ul_found
 endif
 
 foreach arg:has_sym_args
-    mlx5_config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], dependencies: libs))
+    mlx5_config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], dependencies: libs, args: cflags))
 endforeach
 foreach arg:has_member_args
     file_prefix = '#include <' + arg[1] + '>'
-    mlx5_config.set(arg[0], cc.has_member(arg[2], arg[3], prefix : file_prefix, dependencies: libs))
+    mlx5_config.set(arg[0],
+            cc.has_member(arg[2], arg[3], prefix : file_prefix, dependencies: libs, args: cflags))
 endforeach
 
 # Build Glue Library
diff --git a/drivers/net/failsafe/meson.build b/drivers/net/failsafe/meson.build
index 6013e13722..c1d361083b 100644
--- a/drivers/net/failsafe/meson.build
+++ b/drivers/net/failsafe/meson.build
@@ -7,7 +7,6 @@ if is_windows
     subdir_done()
 endif
 
-cflags += '-std=gnu99'
 cflags += '-D_DEFAULT_SOURCE'
 cflags += '-D_XOPEN_SOURCE=700'
 cflags += '-pedantic'
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index a038c1ec1b..3c5ee24186 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -103,12 +103,12 @@ has_sym_args = [
 config = configuration_data()
 foreach arg:has_sym_args
     config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
-        dependencies: libs))
+        dependencies: libs, args: cflags))
 endforeach
 foreach arg:has_member_args
     file_prefix = '#include <' + arg[1] + '>'
     config.set(arg[0], cc.has_member(arg[2], arg[3],
-        prefix: file_prefix, dependencies: libs))
+        prefix: file_prefix, dependencies: libs, args: cflags))
 endforeach
 configure_file(output : 'mlx4_autoconf.h', configuration : config)
 
diff --git a/lib/eal/common/eal_common_errno.c b/lib/eal/common/eal_common_errno.c
index ef8f782abb..b30e2f0ad4 100644
--- a/lib/eal/common/eal_common_errno.c
+++ b/lib/eal/common/eal_common_errno.c
@@ -4,6 +4,7 @@
 
 /* Use XSI-compliant portable version of strerror_r() */
 #undef _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L
 
 #include <stdio.h>
 #include <string.h>
diff --git a/meson.build b/meson.build
index 39cb73846d..70b54f0c98 100644
--- a/meson.build
+++ b/meson.build
@@ -9,6 +9,7 @@ project('DPDK', 'c',
         license: 'BSD',
         default_options: [
             'buildtype=release',
+            'c_std=c11',
             'default_library=static',
             'warning_level=2',
         ],
-- 
2.39.2


  parent reply	other threads:[~2023-08-01 13:16 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31 10:38 [PATCH] " Bruce Richardson
2023-07-31 10:51 ` Morten Brørup
2023-07-31 15:58 ` [PATCH v2] " Bruce Richardson
2023-07-31 16:24   ` Tyler Retzlaff
2023-07-31 16:42   ` Tyler Retzlaff
2023-07-31 16:58 ` [PATCH v3] " Bruce Richardson
2023-07-31 17:05   ` Tyler Retzlaff
2023-08-01  0:39     ` Patrick Robb
2023-08-01  9:20       ` Bruce Richardson
2023-08-01 10:19       ` Bruce Richardson
2023-08-01 10:35         ` David Marchand
2023-08-01 10:39           ` Bruce Richardson
2023-08-01 10:50             ` Bruce Richardson
2023-08-01 12:42               ` Ali Alnubani
2023-08-01 13:03                 ` Bruce Richardson
2023-08-01 13:22                 ` Bruce Richardson
2023-08-01 13:47                   ` Ali Alnubani
2023-08-01 14:00                     ` Bruce Richardson
2023-08-02 10:10                       ` Bruce Richardson
2023-08-01 10:37         ` Thomas Monjalon
2023-08-01 14:00           ` Ali Alnubani
2023-08-01 13:15 ` Bruce Richardson [this message]
2023-08-01 13:24   ` [PATCH v4] " David Marchand
2023-08-01 13:29     ` Bruce Richardson
2023-08-01 13:34       ` David Marchand
2023-08-01 15:47   ` Ali Alnubani
2023-08-01 15:50     ` Bruce Richardson
2023-08-01 16:20       ` Tyler Retzlaff
2023-08-01 20:12         ` Patrick Robb
2023-08-02  6:32           ` David Marchand
2023-08-02 13:40             ` Patrick Robb
2023-08-03  9:21               ` David Marchand
2023-08-02 12:31 ` [PATCH v5] " Bruce Richardson
2023-08-02 12:35   ` Bruce Richardson
2023-08-03 12:38   ` Ali Alnubani
2023-08-03 13:36   ` David Marchand
2023-08-10 13:34     ` Thomas Monjalon
2023-08-10 14:48       ` Stephen Hemminger
2023-08-10 16:35         ` Bruce Richardson
2023-08-10 16:49           ` Thomas Monjalon
2023-08-10 17:02             ` Stephen Hemminger
2023-08-10 18:17               ` Morten Brørup
2023-08-10 22:34                 ` Tyler Retzlaff
2023-08-11  8:52                   ` Bruce Richardson
2023-08-11 10:12                     ` Morten Brørup

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=20230801131549.323733-1-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=roretzla@linux.microsoft.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).