Build: Only use -Werror on debug builds.
What changed, and why it matters
This commit changes the build system so that compiler warnings no longer stop the build by default. It only enforces that strict rule ('-Werror') for debug builds and for developers/CI. This is a build-configuration change, not a fix for a software vulnerability.
No security action required. Treat as a normal build-system improvement. Review downstream packaging to confirm expected compiler warning behavior for release builds.
Security signals we found
No security-relevant code change
Build-system-only modification
No memory safety, cryptographic, or protocol changes
No vulnerability fix or mitigation
Evidence from the diff
The patch removes ‘-Werror’ from BASE_WARNFLAGS and appends it only when DEBUGBUILD=1 in default_cwarnflags(). It also adds ‘-Werror’ explicitly to a linker feature-test compilation in have_function_sections() because that test intentionally wants warnings to fail. The change prevents release builds from breaking when newer compilers introduce warnings, while keeping strict warning-as-error behavior for debug/CI builds.
Changed components
configure scriptbuild flags (CWARNFLAGS / BASE_WARNFLAGS)Inspect captured patch +11 / −5
diff --git a/configure b/configure
index bee8ab19..0aa1669a 100755
--- a/configure
+++ b/configure
@@ -6,7 +6,7 @@ set -e
CONFIGURATOR=ccan/tools/configurator/configurator
CONFIG_VAR_FILE=config.vars
CONFIG_HEADER=ccan/config.h
-BASE_WARNFLAGS="-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror"
+BASE_WARNFLAGS="-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition"
OS=$(uname -s)
ARCH=$(uname -m)
@@ -51,7 +51,7 @@ default_coptflags()
fi
}
-# Given COPTFLAGS, HAVE_GCC and HAVE_MODERN_GCC, what CWARNFLAGS to default to?
+# Given COPTFLAGS, HAVE_GCC, HAVE_MODERN_GCC and DEBUGBUILD, what CWARNFLAGS to default to?
default_cwarnflags()
{
F=$BASE_WARNFLAGS
@@ -66,6 +66,10 @@ default_cwarnflags()
# this gcc-only.
F="$F -Wshadow=local"
fi
+ # Debug builds get -Werror (great for CI!)
+ if [ "$4" = 1 ]; then
+ F="$F -Werror"
+ fi
echo "$F"
}
@@ -220,7 +224,8 @@ have_function_sections()
TMPOBJFILE=$CONFIG_VAR_FILE.$$.o
echo "int foo(void); int foo(void) { return 0; }" > $TMPCFILE
- $1 $2 -ffunction-sections -Wl,--gc-sections -c $TMPCFILE -o $TMPOBJFILE
+ # We *want* this to fail if we get a warning, hence use -Werror.
+ $1 $2 -Werror -ffunction-sections -Wl,--gc-sections -c $TMPCFILE -o $TMPOBJFILE
}
usage()
@@ -231,7 +236,7 @@ usage()
set_defaults
DEFAULT_COPTFLAGS="$(default_coptflags $DEBUGBUILD)"
# We assume we have a modern gcc.
- DEFAULT_CWARNFLAGS="$(default_cwarnflags ""$DEFAULT_COPTFLAGS"" 1 1)"
+ DEFAULT_CWARNFLAGS="$(default_cwarnflags ""$DEFAULT_COPTFLAGS"" 1 1 ""$DEBUGBUILD"")"
usage_with_default "CC" "$CC"
usage_with_default "CWARNFLAGS" "$DEFAULT_CWARNFLAGS"
usage_with_default "COPTFLAGS" "$DEFAULT_COPTFLAGS"
@@ -601,7 +606,8 @@ fi
if [ -z ${CWARNFLAGS+x} ]; then
CWARNFLAGS=$(default_cwarnflags "$COPTFLAGS" \
$(sed -n 's/^HAVE_GCC=//p' < $CONFIG_VAR_FILE.$$) \
- $(sed -n 's/^HAVE_MODERN_GCC=//p' < $CONFIG_VAR_FILE.$$) )
+ $(sed -n 's/^HAVE_MODERN_GCC=//p' < $CONFIG_VAR_FILE.$$) \
+ "$DEBUGBUILD")
fi
add_var PREFIX "$PREFIX"
Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.