From 3a35ad600404f85d1d4e7b6fce0d180df4fb3165 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 30 Dec 2021 08:33:39 -0800 Subject: configure: detect warning opts missing in older compilers. * configure (diag_flags): Remove -Wvla and -Werror=declaration-after-statement. (diag_flags_given): New variable. New test: if diag_flags_given indicates that diag_flags were not specified by the user, then we try to add additional flags, subject to them being available, which we test by compiling the hello-world program with those flags. We rely on the hello-world program being left over by the previous compiler sanity check. --- configure | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 561976e6..68ceb513 100755 --- a/configure +++ b/configure @@ -167,8 +167,9 @@ nm='$(cross)$(tool_prefix)nm' opt_flags='-O2 -fno-stack-protector' lang_flags='-D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE' diag_flags="-Wall -Wextra -Werror=implicit-function-declaration \ - -Werror=missing-prototypes -Werror=strict-prototypes -Werror=vla \ - -Werror=old-style-definition -Werror=declaration-after-statement" + -Werror=missing-prototypes -Werror=strict-prototypes \ + -Werror=old-style-definition" +diag_flags_given= debug_flags=-g debug_only_flags=-DTXR_DEBUG debug_also= @@ -1055,6 +1056,19 @@ else printf "okay\n" fi +if ! [ $diag_flags_given ] ; then + for opt in -Werror=vla -Werror=declaration-after-statement ; do + printf "Checking for %s ... " $opt + + if conftest EXTRA_FLAGS="-Werror $opt" ; then + printf "yes\n" + diag_flags="$diag_flags $opt" + else + printf "no\n" + fi + done +fi + printf "Checking compiler version for various workarounds ... " output=$($make conftest.ccver) -- cgit v1.2.3