Cause developer builds to fail for any use of a VLA.
VLAs (variable length arrays) limit portability.

Discussed for other GNU packages in:
https://lists.gnu.org/r/coreutils/2019-01/msg00058.html

* [PATCH 1/2] gnulib: update to the latest
* [PATCH 2/2] build: ensure no VLA is used

Have a nice day,
Berny
>From 64b802e568213506c672eb9e197a1b9c71eb1273 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Tue, 22 Jan 2019 08:43:04 +0100
Subject: [PATCH 1/2] gnulib: update to the latest

Run 'make update-gnulib-to-latest'.

* gnulib: Update to a version supporting GNULIB_NO_VLA.
---
 gnulib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnulib b/gnulib
index 7561e64e..5ddb2f9d 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 7561e64ee35bc557815e918c80dd7f89d2ad41a7
+Subproject commit 5ddb2f9d460a85a56f1c47c57c48395ccdc4ea12
-- 
2.20.1

>From 8ff1a199f32ae631f543f52b9edaffd0cf7a4014 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Tue, 22 Jan 2019 08:38:20 +0100
Subject: [PATCH 2/2] build: ensure no VLA is used

Cause developer builds to fail for any use of a VLA.
VLAs (variable length arrays) limit portability.

* configure.ac (findutils_gnulib_noise_warnings): Remove as the only
suppressed warning for gnulib was -Wvla, thus enabling the warning
when configured with --enable-compiler-warnings.
(compiler-warnings-are-errors): Likewise.
(GNULIB_NO_VLA) Define, disabling use of VLAs in gnulib.  This commit
is functionally equivalent to coreutils' v8.30-44-gd26dece5d

Discussed for other GNU packages in:
https://lists.gnu.org/r/coreutils/2019-01/msg00058.html
---
 configure.ac | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8fbfc446..de651d7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,10 @@ AC_ARG_ENABLE(compiler-warnings,
   dnl Enable various GCC warnings.
   gl_MANYWARN_ALL_GCC([warnings])
 
+  # Ensure VLAs are not used.
+  # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
+  AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
+
   # Set up the list of the pointless, undesired warnings.
   findutils_nw=
   findutils_nw="$findutils_nw -Wsystem-headers"	 # Don't let system headers trigger warnings
@@ -120,9 +124,6 @@ AC_ARG_ENABLE(compiler-warnings,
   findutils_nw="$findutils_nw -Wsign-conversion" # Likewise.
   findutils_nw="$findutils_nw -Wc++-compat"      # malloc returns void* and a cast would be ugly.
   findutils_nw="$findutils_nw -Wswitch-default"  # A switch on an enum value needs no default.
-  # gettext.h and gnulib use variable length arrays and we don't want warnings for that.
-  findutils_gnulib_noise_warnings=
-  findutils_gnulib_noise_warnings="$findutils_gnulib_noise_warnings -Wvla"
 
   # Warnings we might enable in the future, but not yet (because they generate a
   # lot of noise).
@@ -146,7 +147,7 @@ AC_ARG_ENABLE(compiler-warnings,
   # Enable all GCC warnings not in our list of excluded warnings.
   gl_MANYWARN_COMPLEMENT(
 	[warnings], [$warnings],
-	[$findutils_nw $findutils_marginal $findutils_tmp_nowarning $findutils_gnulib_noise_warnings])
+	[$findutils_nw $findutils_marginal $findutils_tmp_nowarning])
   for w in $warnings
   do
     gl_WARN_ADD([$w])
@@ -174,13 +175,6 @@ AC_ARG_ENABLE(compiler-warnings-are-errors,
     if test -n "$GCC"; then
       CFLAGS="$CFLAGS -Werror"
       AC_MSG_RESULT([yes])
-      # Turn off warnings that would fire for code in gnulib, which we still want to be able
-      # to compile without error.
-      unwanted="vla"
-      AC_MSG_NOTICE([Turning off otherwise-fatal warnings in order to compile gnulib successfully: $unwanted])
-      for w in $unwanted; do
-        WARN_CFLAGS="${WARN_CFLAGS} -Wno-${w}"
-      done
     else
       AC_MSG_RESULT([no, because $CC is not GCC])
     fi
-- 
2.20.1

Reply via email to