Skip to content

Commit e71c12e

Browse files
authored
bpo-42268: Fail the configure step if the selected compiler doesn't support memory sanitizer (GH-29806)
1 parent af9ee57 commit e71c12e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fail the configure step if the selected compiler doesn't support memory
2+
sanitizer. Patch by Pablo Galindo

configure

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9920,8 +9920,44 @@ if test "${with_memory_sanitizer+set}" = set; then :
99209920
withval=$with_memory_sanitizer;
99219921
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5
99229922
$as_echo "$withval" >&6; }
9923+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fsanitize=memory" >&5
9924+
$as_echo_n "checking whether C compiler accepts -fsanitize=memory... " >&6; }
9925+
if ${ax_cv_check_cflags___fsanitize_memory+:} false; then :
9926+
$as_echo_n "(cached) " >&6
9927+
else
9928+
9929+
ax_check_save_flags=$CFLAGS
9930+
CFLAGS="$CFLAGS -fsanitize=memory"
9931+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9932+
/* end confdefs.h. */
9933+
9934+
int
9935+
main ()
9936+
{
9937+
9938+
;
9939+
return 0;
9940+
}
9941+
_ACEOF
9942+
if ac_fn_c_try_compile "$LINENO"; then :
9943+
ax_cv_check_cflags___fsanitize_memory=yes
9944+
else
9945+
ax_cv_check_cflags___fsanitize_memory=no
9946+
fi
9947+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9948+
CFLAGS=$ax_check_save_flags
9949+
fi
9950+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fsanitize_memory" >&5
9951+
$as_echo "$ax_cv_check_cflags___fsanitize_memory" >&6; }
9952+
if test "x$ax_cv_check_cflags___fsanitize_memory" = xyes; then :
9953+
99239954
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
99249955
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
9956+
9957+
else
9958+
as_fn_error $? "The selected compiler doesn't support memory sanitizer" "$LINENO" 5
9959+
fi
9960+
99259961
# MSan works by controlling memory allocation, our own malloc interferes.
99269962
with_pymalloc="no"
99279963

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,8 +2565,10 @@ AC_ARG_WITH(memory_sanitizer,
25652565
[enable MemorySanitizer allocation error detector, 'msan' (default is no)]),
25662566
[
25672567
AC_MSG_RESULT($withval)
2568+
AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
25682569
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
25692570
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
2571+
],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
25702572
# MSan works by controlling memory allocation, our own malloc interferes.
25712573
with_pymalloc="no"
25722574
],

0 commit comments

Comments
 (0)