8000 pythongh-121045: Use link test to check -fstack-protector-strong flag · python/cpython@89fa135 · GitHub
[go: up one dir, main page]

Skip to content

Commit 89fa135

Browse files
committed
gh-121045: Use link test to check -fstack-protector-strong flag
1 parent b157e09 commit 89fa135

File tree

2 files changed

+40
-36
lines changed

2 files changed

+40
-36
lines changed

configure

Lines changed: 23 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,24 +2492,30 @@ AC_DEFUN([PY_CHECK_CC_WARNING], [
24922492
AS_VAR_POPDEF([py_var])
24932493
])
24942494

2495+
dnl PY_CHECK_CC_CFLAG(ENABLE, CFLAG, [MSG])
2496+
AC_DEFUN([PY_CHECK_CC_CFLAG], [
2497+
AS_VAR_PUSHDEF([py_var], [ac_cv_$1_]m4_normalize($2)[_flag])
2498+
AC_CACHE_CHECK([m4_ifblank([$3], [if we can $1 $CC $2 flag], [$3])], [py_var], [
2499+
AS_VAR_COPY([py_cflags], [CFLAGS])
2500+
AS_VAR_APPEND([CFLAGS], [" -f$2 -Werror"])
2501+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
2502+
[AS_VAR_SET([py_var], [yes])],
2503+
[AS_VAR_SET([py_var], [no])])
2504+
AS_VAR_COPY([CFLAGS], [py_cflags])
2505+
])
2506+
AS_VAR_POPDEF([py_var])
2507+
])
2508+
24952509
# tweak BASECFLAGS based on compiler and platform
24962510
AS_VAR_IF([with_strict_overflow], [yes],
24972511
[BASECFLAGS="$BASECFLAGS $STRICT_OVERFLOW_CFLAGS"],
24982512
[BASECFLAGS="$BASECFLAGS $NO_STRICT_OVERFLOW_CFLAGS"])
24992513

25002514
# Enable flags that warn and protect for potential security vulnerabilities.
25012515
# These flags should be enabled by default for all builds.
2502-
case $ac_sys_system/$CC in
2503-
AIX*/gcc*)
2504-
# In AIX with GCC, the compile check passes with -fstack-protector-strong
2505-
# even though it is not supported and is exposed only by a run/link check.
2506-
# So disable it.
2507-
AC_MSG_WARN([-fstack-protector-strong not supported in AIX with gcc])
2508-
;;
2509-
*)
2510-
AX_CHECK_COMPILE_FLAG([-fstack-protector-strong], [BASECFLAGS="$BASECFLAGS -fstack-protector-strong"], [AC_MSG_WARN([-fstack-protector-strong not supported])], [-Werror])
2511-
;;
2512-
esac
2516+
PY_CHECK_CC_CFLAG([enable], [stack-protector-strong], [if we can add -fstack-protector-strong])
2517+
AS_VAR_IF([ac_cv_enable_stack_protector_strong_flag], [yes],
2518+
[BASECFLAGS="$BASECFLAGS -fstack-protector-strong"], AC_MSG_WARN([-fstack-protector-strong not supported]))
25132519
AX_CHECK_COMPILE_FLAG([-Wtrampolines], [BASECFLAGS="$BASECFLAGS -Wtrampolines"], [AC_MSG_WARN([-Wtrampolines not supported])], [-Werror])
25142520
AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=3], [BASECFLAGS="$BASECFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"], [AC_MSG_WARN([-D_FORTIFY_SOURCE=3 not supported])])
25152521

0 commit comments

Comments
 (0)
0