Skip to content

Commit 8d1a580

Browse files
authored
[3.10] bpo-42268: Fail the configure step if the selected compiler doesn't support memory sanitizer (GH-29806) (GH-29815)
(cherry picked from commit e71c12e) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
1 parent 2c398a5 commit 8d1a580

File tree

4 files changed

+63
-43
lines changed

4 files changed

+63
-43
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: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9605,8 +9605,44 @@ if test "${with_memory_sanitizer+set}" = set; then :
96059605
withval=$with_memory_sanitizer;
96069606
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5
96079607
$as_echo "$withval" >&6; }
9608+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fsanitize=memory" >&5
9609+
$as_echo_n "checking whether C compiler accepts -fsanitize=memory... " >&6; }
9610+
if ${ax_cv_check_cflags___fsanitize_memory+:} false; then :
9611+
$as_echo_n "(cached) " >&6
9612+
else
9613+
9614+
ax_check_save_flags=$CFLAGS
9615+
CFLAGS="$CFLAGS -fsanitize=memory"
9616+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9617+
/* end confdefs.h. */
9618+
9619+
int
9620+
main ()
9621+
{
9622+
9623+
;
9624+
return 0;
9625+
}
9626+
_ACEOF
9627+
if ac_fn_c_try_compile "$LINENO"; then :
9628+
ax_cv_check_cflags___fsanitize_memory=yes
9629+
else
9630+
ax_cv_check_cflags___fsanitize_memory=no
9631+
fi
9632+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9633+
CFLAGS=$ax_check_save_flags
9634+
fi
9635+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fsanitize_memory" >&5
9636+
$as_echo "$ax_cv_check_cflags___fsanitize_memory" >&6; }
9637+
if test "x$ax_cv_check_cflags___fsanitize_memory" = xyes; then :
9638+
96089639
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
96099640
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
9641+
9642+
else
9643+
as_fn_error $? "The selected compiler doesn't support memory sanitizer" "$LINENO" 5
9644+
fi
9645+
96109646
# MSan works by controlling memory allocation, our own malloc interferes.
96119647
with_pymalloc="no"
96129648

@@ -10120,13 +10156,15 @@ $as_echo "no" >&6; }
1012010156
fi
1012110157
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1012210158

10159+
# check for libuuid from util-linux
1012310160
save_LIBS=$LIBS
10124-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uuid_generate_time_safe" >&5
10125-
$as_echo_n "checking for library containing uuid_generate_time_safe... " >&6; }
10126-
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
10161+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5
10162+
$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; }
10163+
if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then :
1012710164
$as_echo_n "(cached) " >&6
1012810165
else
10129-
ac_func_search_save_LIBS=$LIBS
10166+
ac_check_lib_save_LIBS=$LIBS
10167+
LIBS="-luuid $LIBS"
1013010168
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1013110169
/* end confdefs.h. */
1013210170

@@ -10136,61 +10174,39 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1013610174
#ifdef __cplusplus
1013710175
extern "C"
1013810176
#endif
10139-
char uuid_generate_time_safe ();
10177+
char uuid_generate_time ();
1014010178
int
1014110179
main ()
1014210180
{
10143-
return uuid_generate_time_safe ();
10181+
return uuid_generate_time ();
1014410182
;
1014510183
return 0;
1014610184
}
1014710185
_ACEOF
10148-
for ac_lib in '' uuid; do
10149-
if test -z "$ac_lib"; then
10150-
ac_res="none required"
10151-
else
10152-
ac_res=-l$ac_lib
10153-
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
10154-
fi
10155-
if ac_fn_c_try_link "$LINENO"; then :
10156-
ac_cv_search_uuid_generate_time_safe=$ac_res
10157-
fi
10158-
rm -f core conftest.err conftest.$ac_objext \
10159-
conftest$ac_exeext
10160-
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
10161-
break
10162-
fi
10163-
done
10164-
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
10165-
10186+
if ac_fn_c_try_link "$LINENO"; then :
10187+
ac_cv_lib_uuid_uuid_generate_time=yes
1016610188
else
10167-
ac_cv_search_uuid_generate_time_safe=no
10189+
ac_cv_lib_uuid_uuid_generate_time=no
1016810190
fi
10169-
rm conftest.$ac_ext
10170-
LIBS=$ac_func_search_save_LIBS
10191+
rm -f core conftest.err conftest.$ac_objext \
10192+
conftest$ac_exeext conftest.$ac_ext
10193+
LIBS=$ac_check_lib_save_LIBS
1017110194
fi
10172-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uuid_generate_time_safe" >&5
10173-
$as_echo "$ac_cv_search_uuid_generate_time_safe" >&6; }
10174-
ac_res=$ac_cv_search_uuid_generate_time_safe
10175-
if test "$ac_res" != no; then :
10176-
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
10177-
10178-
10179-
$as_echo "#define HAVE_LIBUUID 1" >>confdefs.h
10180-
,
10181-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10182-
$as_echo "yes" >&6; }
10195+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5
10196+
$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; }
10197+
if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then :
10198+
cat >>confdefs.h <<_ACEOF
10199+
#define HAVE_LIBUUID 1
10200+
_ACEOF
1018310201

10184-
else
10185-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10186-
$as_echo "no" >&6; }
10202+
LIBS="-luuid $LIBS"
1018710203

1018810204
fi
1018910205

1019010206
LIBS=$save_LIBS
1019110207

1019210208
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
10193-
# FreeBSD and OpenBSD provides support as well
10209+
# FreeBSD and OpenBSD provides support in libc as well.
1019410210
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_create" >&5
1019510211
$as_echo_n "checking for uuid_create... " >&6; }
1019610212
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,8 +2583,10 @@ AC_ARG_WITH(memory_sanitizer,
25832583
[enable MemorySanitizer allocation error detector, 'msan' (default is no)]),
25842584
[
25852585
AC_MSG_RESULT($withval)
2586+
AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
25862587
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
25872588
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
2589+
],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
25882590
# MSan works by controlling memory allocation, our own malloc interferes.
25892591
with_pymalloc="no"
25902592
],

pyconfig.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@
628628
/* Define to 1 if you have the <libutil.h> header file. */
629629
#undef HAVE_LIBUTIL_H
630630

631-
/* Define you have libuuid. */
631+
/* Define to 1 if you have the `uuid' library (-luuid). */
632632
#undef HAVE_LIBUUID
633633

634634
/* Define if you have the 'link' function. */

0 commit comments

Comments
 (0)