Skip to content

Commit 76b7f04

Browse files
committed
gh-157354 : Honor disabled sanitizer configure options
1 parent 051b168 commit 76b7f04

3 files changed

Lines changed: 75 additions & 52 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Honor ``=no`` and ``--without-...`` for the AddressSanitizer,
2+
MemorySanitizer, UndefinedBehaviorSanitizer, and ThreadSanitizer configure
3+
options without adding sanitizer flags or changing the pymalloc setting.

‎configure‎

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

‎configure.ac‎

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,14 +3519,14 @@ AC_MSG_CHECKING([for --with-address-sanitizer])
35193519
AC_ARG_WITH([address_sanitizer],
35203520
AS_HELP_STRING([--with-address-sanitizer],
35213521
[enable AddressSanitizer memory error detector, 'asan' (default is no)]),
3522-
[
3523-
AC_MSG_RESULT([$withval])
3522+
[], [with_address_sanitizer=no])
3523+
AC_MSG_RESULT([$with_address_sanitizer])
3524+
AS_VAR_IF([with_address_sanitizer], [no], [], [
35243525
BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
35253526
LDFLAGS="-fsanitize=address $LDFLAGS"
35263527
# ASan works by controlling memory allocation, our own malloc interferes.
35273528
with_pymalloc="no"
3528-
],
3529-
[AC_MSG_RESULT([no])])
3529+
])
35303530

35313531
AC_MSG_CHECKING([for --with-memory-sanitizer])
35323532
AC_ARG_WITH(
@@ -3535,16 +3535,16 @@ AC_ARG_WITH(
35353535
[--with-memory-sanitizer],
35363536
[enable MemorySanitizer allocation error detector, 'msan' (default is no)]
35373537
)],
3538-
[
3539-
AC_MSG_RESULT([$withval])
3538+
[], [with_memory_sanitizer=no])
3539+
AC_MSG_RESULT([$with_memory_sanitizer])
3540+
AS_VAR_IF([with_memory_sanitizer], [no], [], [
35403541
AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
35413542
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
35423543
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
35433544
],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
35443545
# MSan works by controlling memory allocation, our own malloc interferes.
35453546
with_pymalloc="no"
3546-
],
3547-
[AC_MSG_RESULT([no])])
3547+
])
35483548

35493549
AC_MSG_CHECKING([for --with-undefined-behavior-sanitizer])
35503550
AC_ARG_WITH(
@@ -3553,15 +3553,14 @@ AC_ARG_WITH(
35533553
[--with-undefined-behavior-sanitizer],
35543554
[enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]
35553555
)],
3556-
[
3557-
AC_MSG_RESULT([$withval])
3556+
[], [with_undefined_behavior_sanitizer=no])
3557+
AC_MSG_RESULT([$with_undefined_behavior_sanitizer])
3558+
AS_VAR_IF([with_undefined_behavior_sanitizer], [no], [
3559+
with_ubsan="no"
3560+
], [
35583561
BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
35593562
LDFLAGS="-fsanitize=undefined $LDFLAGS"
35603563
with_ubsan="yes"
3561-
],
3562-
[
3563-
AC_MSG_RESULT([no])
3564-
with_ubsan="no"
35653564
])
35663565

35673566
AC_MSG_CHECKING([for --with-thread-sanitizer])
@@ -3571,15 +3570,14 @@ AC_ARG_WITH(
35713570
[--with-thread-sanitizer],
35723571
[enable ThreadSanitizer data race detector, 'tsan' (default is no)]
35733572
)],
3574-
[
3575-
AC_MSG_RESULT([$withval])
3573+
[], [with_thread_sanitizer=no])
3574+
AC_MSG_RESULT([$with_thread_sanitizer])
3575+
AS_VAR_IF([with_thread_sanitizer], [no], [
3576+
with_tsan="no"
3577+
], [
35763578
BASECFLAGS="-fsanitize=thread $BASECFLAGS"
35773579
LDFLAGS="-fsanitize=thread $LDFLAGS"
35783580
with_tsan="yes"
3579-
],
3580-
[
3581-
AC_MSG_RESULT([no])
3582-
with_tsan="no"
35833581
])
35843582

35853583
# Set info about shared libraries.

0 commit comments

Comments
 (0)