changeset 1849:d34f50b7b9fd

Add configure --enable-werror argument This should be used instead of putting -Werror in CFLAGS before configure, as -Werror interferes with conftests. Update github actions to use that.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 19 Oct 2021 12:16:20 +0800
parents 84b664071c7d
children d99b167994b5
files .github/workflows/build.yml configure configure.ac
diffstat 3 files changed, 45 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/.github/workflows/build.yml	Tue Oct 19 11:50:12 2021 +0800
+++ b/.github/workflows/build.yml	Tue Oct 19 12:16:20 2021 +0800
@@ -15,6 +15,8 @@
         #   runcheck: 'no'
         # Otherwise GH expressions will make a None var
         # compare with False. We want an undefined default of True.
+
+        # MULTI and NOWRITEV are passed as integers to the build
         include:
           - name: plain linux
 
@@ -24,10 +26,10 @@
           - name: bundled libtom, bionic , no writev()
             # test can use an older distro with bundled libtommath
             os: ubuntu-18.04
-            configure_flags: --enable-bundled-libtom
+            configure_flags: --enable-bundled-libtom --enable-werror
             # NOWRITEV is unrelated, test here to save a job
             nowritev: 1
-            # pytest relies on python3.7
+            # our tests expect >= python3.7
             runcheck: 'no'
 
           - name: linux clang
@@ -37,7 +39,7 @@
             os: macos-10.15
             cc: clang
             # OS X says daemon() and utmp are deprecated
-            wextraflags: -Wno-deprecated-declarations -Werror
+            extracflags: -Wno-deprecated-declarations
             runcheck: 'no'
             apt: 'no'
             # fails with:
@@ -47,7 +49,7 @@
           - name: macos 11
             os: macos-11
             cc: clang
-            wextraflags: -Wno-deprecated-declarations -Werror
+            extracflags: -Wno-deprecated-declarations
             runcheck: 'no'
             apt: 'no'
             ranlib: ranlib -no_warning_for_no_symbols
@@ -55,7 +57,7 @@
           # # Fuzzers run standalone. A bit superfluous with cifuzz, but
           # # good to run the whole corpus to keep it working.
           # - name: fuzzing with address sanitizer
-          #   configure_flags: --enable-fuzz --disable-harden --enable-bundled-libtom
+          #   configure_flags: --enable-fuzz --disable-harden --enable-bundled-libtom --enable-werror
           #   ldflags: -fsanitize=address
           #   extracflags: -fsanitize=address
           #   fuzz: True
@@ -63,7 +65,7 @@
 
           # # Undefined Behaviour sanitizer
           # - name: fuzzing with undefined behaviour sanitizer
-          #   configure_flags: --enable-fuzz --disable-harden --enable-bundled-libtom
+          #   configure_flags: --enable-fuzz --disable-harden --enable-bundled-libtom --enable-werror
           #   ldflags: -fsanitize=undefined
           #   # don't fail with alignment due to https://github.com/libtom/libtomcrypt/issues/549
           #   extracflags: -fsanitize=undefined -fno-sanitize-recover=undefined -fsanitize-recover=alignment
@@ -72,11 +74,10 @@
 
     env:
       MULTI: ${{ matrix.multi }}
-      WEXTRAFLAGS: ${{ matrix.wextraflags || '-Werror' }}
       CC: ${{ matrix.cc || 'gcc' }}
       LDFLAGS: ${{ matrix.ldflags }}
       EXTRACFLAGS: ${{ matrix.extracflags }}
-      CONFIGURE_FLAGS: ${{ matrix.configure_flags }}
+      CONFIGURE_FLAGS: ${{ matrix.configure_flags || '--enable-werror' }}
       # for fuzzing
       CXX: clang++
       RANLIB: ${{ matrix.ranlib || 'ranlib' }}
@@ -106,7 +107,7 @@
           key: "hg.ucc/fuzzcorpus"
 
       - name: configure
-        run: ./configure $CONFIGURE_FLAGS CFLAGS="-O2 -Wall -Wno-pointer-sign $WEXTRAFLAGS $EXTRACFLAGS" --prefix="$HOME/inst" || (cat config.log; exit 1)
+        run: ./configure $CONFIGURE_FLAGS CFLAGS="-O2 -Wall -Wno-pointer-sign $EXTRACFLAGS" --prefix="$HOME/inst" || (cat config.log; exit 1)
 
       - name: nowritev
         if: ${{ matrix.nowritev }}
--- a/configure	Tue Oct 19 11:50:12 2021 +0800
+++ b/configure	Tue Oct 19 12:16:20 2021 +0800
@@ -697,6 +697,7 @@
 enable_option_checking
 enable_static
 enable_harden
+enable_werror
 enable_largefile
 with_zlib
 enable_zlib
@@ -1354,6 +1355,7 @@
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-static         Build static binaries
   --disable-harden        Don't set hardened build flags
+  --enable-werror         Set -Werror when building
   --disable-largefile     omit support for large files
   --disable-zlib          Don't include zlib support
   --enable-pam            Try to include PAM support
@@ -2378,6 +2380,7 @@
 fi
 
 ORIGCFLAGS="$CFLAGS"
+LATE_CFLAGS=""
 # Checks for programs.
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -3506,6 +3509,20 @@
 
 fi
 
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+  enableval=$enable_werror;
+		if test "x$enableval" = "xyes"; then
+			# -Werror shouldn't be set when configure runs tests.
+			# We add it to the Makefile's CFLAGS
+			LATE_CFLAGS+="$LATE_CFLAGS -Werror"
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: Enabling -Werror" >&5
+$as_echo "$as_me: Enabling -Werror" >&6;}
+		fi
+
+fi
+
+
 # large file support is useful for scp
 # Check whether --enable-largefile was given.
 if test "${enable_largefile+set}" = set; then :
@@ -7440,6 +7457,9 @@
 LIBTOM_FILES="libtomcrypt/Makefile libtommath/Makefile"
 fi
 
+# flags that should be set in Makefile but not for configure tests
+CFLAGS="$CFLAGS $LATE_CFLAGS"
+
 ac_config_headers="$ac_config_headers config.h"
 
 ac_config_files="$ac_config_files Makefile $LIBTOM_FILES test/Makefile"
--- a/configure.ac	Tue Oct 19 11:50:12 2021 +0800
+++ b/configure.ac	Tue Oct 19 12:16:20 2021 +0800
@@ -16,6 +16,7 @@
 fi
 
 ORIGCFLAGS="$CFLAGS"
+LATE_CFLAGS=""
 # Checks for programs.
 AC_PROG_CC
 
@@ -127,6 +128,17 @@
 
 fi
 
+AC_ARG_ENABLE(werror,
+	[  --enable-werror         Set -Werror when building],
+	[
+		if test "x$enableval" = "xyes"; then
+			# -Werror shouldn't be set when configure runs tests.
+			# We add it to the Makefile's CFLAGS
+			LATE_CFLAGS+="$LATE_CFLAGS -Werror"
+			AC_MSG_NOTICE(Enabling -Werror)
+		fi
+	], [])
+
 # large file support is useful for scp
 AC_SYS_LARGEFILE
 
@@ -861,6 +873,9 @@
 LIBTOM_FILES="libtomcrypt/Makefile libtommath/Makefile"
 fi
 
+# flags that should be set in Makefile but not for configure tests
+CFLAGS="$CFLAGS $LATE_CFLAGS"
+
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES(Makefile $LIBTOM_FILES test/Makefile)
 AC_OUTPUT