Skip to content

bpo-42268: Fail the configure step if the selected compiler doesn't support memory sanitizer #29806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fail the configure step if the selected compiler doesn't support memory
sanitizer. Patch by Pablo Galindo
43 changes: 39 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -9910,8 +9910,44 @@ if test "${with_memory_sanitizer+set}" = set; then :
withval=$with_memory_sanitizer;
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5
$as_echo "$withval" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fsanitize=memory" >&5
$as_echo_n "checking whether C compiler accepts -fsanitize=memory... " >&6; }
if ${ax_cv_check_cflags___fsanitize_memory+:} false; then :
$as_echo_n "(cached) " >&6
else

ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -fsanitize=memory"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ax_cv_check_cflags___fsanitize_memory=yes
else
ax_cv_check_cflags___fsanitize_memory=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fsanitize_memory" >&5
$as_echo "$ax_cv_check_cflags___fsanitize_memory" >&6; }
if test "x$ax_cv_check_cflags___fsanitize_memory" = xyes; then :

BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"

else
as_fn_error $? "The selected compiler doesn't support memory sanitizer" "$LINENO" 5
fi

# MSan works by controlling memory allocation, our own malloc interferes.
with_pymalloc="no"

Expand Down Expand Up @@ -10382,6 +10418,9 @@ fi
# Dynamic linking for HP-UX





have_uuid=missing

for ac_header in uuid.h
Expand Down Expand Up @@ -10414,10 +10453,6 @@ fi
done






if test "x$have_uuid" = xmissing; then :


Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2556,8 +2556,10 @@ AC_ARG_WITH(memory_sanitizer,
[enable MemorySanitizer allocation error detector, 'msan' (default is no)]),
[
AC_MSG_RESULT($withval)
AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
# MSan works by controlling memory allocation, our own malloc interferes.
with_pymalloc="no"
],
Expand Down