Skip to content

Commit 7fb32e0

Browse files
authored
gh-112301: Enable compiler flags with low performance impact and no warnings (gh-120975)
1 parent a905721 commit 7fb32e0

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add default compiler options to improve security. Enable
2+
-Wimplicit-fallthrough, -fstack-protector-strong, -Wtrampolines.

configure

+124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+10
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,16 @@ AS_VAR_IF([with_strict_overflow], [yes],
24512451
[BASECFLAGS="$BASECFLAGS $STRICT_OVERFLOW_CFLAGS"],
24522452
[BASECFLAGS="$BASECFLAGS $NO_STRICT_OVERFLOW_CFLAGS"])
24532453

2454+
# Enable flags that warn and protect for potential security vulnerabilities.
2455+
# These flags should be enabled by default for all builds.
2456+
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [BASECFLAGS="$BASECFLAGS -Wimplicit-fallthrough"], [AC_MSG_WARN([-Wimplicit-fallthrough not supported])])
2457+
AX_CHECK_COMPILE_FLAG([-fstack-protector-strong], [BASECFLAGS="$BASECFLAGS -fstack-protector-strong"], [AC_MSG_WARN([-fstack-protector-strong not supported])])
2458+
case $CC in
2459+
*gcc*)
2460+
# Add GCC-specific compiler flags
2461+
AX_CHECK_COMPILE_FLAG([-Wtrampolines], [BASECFLAGS="$BASECFLAGS -Wtrampolines"], [AC_MSG_WARN([-Wtrampolines not supported])])
2462+
esac
2463+
24542464
case $GCC in
24552465
yes)
24562466
CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"

0 commit comments

Comments
 (0)