Skip to content

Commit 3ee7830

Browse files
committed
gh-109575: Don't export -fsanitize compiler options
When Python is configured to use ASAN, MSAN or UBSAN sanitizer, with "./configure --with-address-sanitizer" for example, compiler and linker flags for sanitizers are no longer exported to third party C extensions. Add flags to CFLAGS_NODIST and LDFLAGS_NODIST, instead of BASECFLAGS and LDFLAGS.
1 parent 67d9363 commit 3ee7830

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
When Python is configured to use ASAN, MSAN or UBSAN sanitizer, with
2+
``./configure --with-address-sanitizer`` for example, compiler and linker
3+
flags for sanitizers are no longer exported to third party C extensions. Add
4+
flags to ``CFLAGS_NODIST`` and ``LDFLAGS_NODIST``, instead of ``BASECFLAGS``
5+
and ``LDFLAGS``. Patch by Victor Stinner.

configure

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

configure.ac

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,8 +2997,8 @@ AC_ARG_WITH([address_sanitizer],
29972997
[enable AddressSanitizer memory error detector, 'asan' (default is no)]),
29982998
[
29992999
AC_MSG_RESULT([$withval])
3000-
BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
3001-
LDFLAGS="-fsanitize=address $LDFLAGS"
3000+
CFLAGS_NODIST="$CFLAGS_NODIST -fsanitize=address -fno-omit-frame-pointer"
3001+
LDFLAGS_NODIST="$LDFLAGS_NODIST -fsanitize=address"
30023002
# ASan works by controlling memory allocation, our own malloc interferes.
30033003
with_pymalloc="no"
30043004
],
@@ -3014,8 +3014,8 @@ AC_ARG_WITH(
30143014
[
30153015
AC_MSG_RESULT([$withval])
30163016
AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
3017-
BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
3018-
LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
3017+
CFLAGS_NODIST="$CFLAGS_NODIST -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer"
3018+
LDFLAGS_NODIST="$LDFLAGS_NODIST -fsanitize=memory -fsanitize-memory-track-origins=2"
30193019
],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
30203020
# MSan works by controlling memory allocation, our own malloc interferes.
30213021
with_pymalloc="no"
@@ -3031,8 +3031,8 @@ AC_ARG_WITH(
30313031
)],
30323032
[
30333033
AC_MSG_RESULT([$withval])
3034-
BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
3035-
LDFLAGS="-fsanitize=undefined $LDFLAGS"
3034+
CFLAGS_NODIST="$CFLAGS_NODIST -fsanitize=undefined"
3035+
LDFLAGS_NODIST="$LDFLAGS_NODIST -fsanitize=undefined"
30363036
with_ubsan="yes"
30373037
],
30383038
[

0 commit comments

Comments
 (0)