[v2] build: update DPDK to use C11 standard

Message ID 20230731155802.2732981-1-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] build: update DPDK to use C11 standard |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Bruce Richardson July 31, 2023, 3:58 p.m. UTC
  As previously announced, DPDK 23.11 will require a C11 supporting
compiler and will use the C11 standard in all builds.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>

---
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 +++++++++++++++++
 lib/eal/common/eal_common_errno.c      |  1 +
 meson.build                            |  1 +
 5 files changed, 21 insertions(+), 19 deletions(-)
  

Comments

Tyler Retzlaff July 31, 2023, 4:24 p.m. UTC | #1
On Mon, Jul 31, 2023 at 04:58:02PM +0100, Bruce Richardson wrote:
> As previously announced, DPDK 23.11 will require a C11 supporting
> compiler and will use the C11 standard in all builds.
> 
> 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>
  
Tyler Retzlaff July 31, 2023, 4:42 p.m. UTC | #2
On Mon, Jul 31, 2023 at 04:58:02PM +0100, Bruce Richardson wrote:
> As previously announced, DPDK 23.11 will require a C11 supporting
> compiler and will use the C11 standard in all builds.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
> 
> ---
> 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 +++++++++++++++++
>  lib/eal/common/eal_common_errno.c      |  1 +
>  meson.build                            |  1 +
>  5 files changed, 21 insertions(+), 19 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/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',
>          ],
> -- 

oh I acked v2 (and you can maintain that ack) but one additional removal
of forced -std=gnu99 is maybe necessary?

drivers/net/failsafe/meson.build
    probably should remove cflags += '-std=gnu99'

if we remove it we inherit the -std=c11 from meson project configuration
and define a _POSIX_C_SOURCE narrowly where necessary (if it is needed).
  

Patch

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/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',
         ],