summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorNate Ohlson <nateohlson@gmail.com>2024-06-26 03:11:05 (GMT)
committerGitHub <noreply@github.com>2024-06-26 03:11:05 (GMT)
commit7fb32e02092922b0256d7be91bbf80767eb2ca46 (patch)
tree4bb0c6815e6c1a0bf1b7924acb53ed67fb9732f8 /configure.ac
parenta905721b9c5c15279e67c2f7785034b7356b2d46 (diff)
downloadcpython-7fb32e02092922b0256d7be91bbf80767eb2ca46.zip
cpython-7fb32e02092922b0256d7be91bbf80767eb2ca46.tar.gz
cpython-7fb32e02092922b0256d7be91bbf80767eb2ca46.tar.bz2
gh-112301: Enable compiler flags with low performance impact and no warnings (gh-120975)
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac10
1 files changed, 10 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 619dad5..e5c6d6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2451,6 +2451,16 @@ AS_VAR_IF([with_strict_overflow], [yes],
[BASECFLAGS="$BASECFLAGS $STRICT_OVERFLOW_CFLAGS"],
[BASECFLAGS="$BASECFLAGS $NO_STRICT_OVERFLOW_CFLAGS"])
+# Enable flags that warn and protect for potential security vulnerabilities.
+# These flags should be enabled by default for all builds.
+AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [BASECFLAGS="$BASECFLAGS -Wimplicit-fallthrough"], [AC_MSG_WARN([-Wimplicit-fallthrough not supported])])
+AX_CHECK_COMPILE_FLAG([-fstack-protector-strong], [BASECFLAGS="$BASECFLAGS -fstack-protector-strong"], [AC_MSG_WARN([-fstack-protector-strong not supported])])
+case $CC in
+ *gcc*)
+ # Add GCC-specific compiler flags
+ AX_CHECK_COMPILE_FLAG([-Wtrampolines], [BASECFLAGS="$BASECFLAGS -Wtrampolines"], [AC_MSG_WARN([-Wtrampolines not supported])])
+esac
+
case $GCC in
yes)
CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"