summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-11-27 18:04:06 (GMT)
committerGitHub <noreply@github.com>2021-11-27 18:04:06 (GMT)
commite71c12efcddc1076d5367461a5b416092267aa77 (patch)
tree72abdf06c22880b0ea1f093fd6bbad63426d81ce
parentaf9ee57b96cb872df6574e36027cc753417605f9 (diff)
downloadcpython-e71c12efcddc1076d5367461a5b416092267aa77.zip
cpython-e71c12efcddc1076d5367461a5b416092267aa77.tar.gz
cpython-e71c12efcddc1076d5367461a5b416092267aa77.tar.bz2
bpo-42268: Fail the configure step if the selected compiler doesn't support memory sanitizer (GH-29806)
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2021-11-26-22-31-22.bpo-42268.3wl-09.rst2
-rwxr-xr-xconfigure36
-rw-r--r--configure.ac2
3 files changed, 40 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-11-26-22-31-22.bpo-42268.3wl-09.rst b/Misc/NEWS.d/next/Core and Builtins/2021-11-26-22-31-22.bpo-42268.3wl-09.rst
new file mode 100644
index 0000000..615bbb2
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-11-26-22-31-22.bpo-42268.3wl-09.rst
@@ -0,0 +1,2 @@
+Fail the configure step if the selected compiler doesn't support memory
+sanitizer. Patch by Pablo Galindo
diff --git a/configure b/configure
index 1c39892..9580072 100755
--- a/configure
+++ b/configure
@@ -9920,8 +9920,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"
diff --git a/configure.ac b/configure.ac
index e96d88f..0fce3f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2565,8 +2565,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"
],