From b93c74e787282d826a5331965856ba05afc87151 Mon Sep 17 00:00:00 2001 From: Lucas Colley Date: Sun, 9 Aug 2026 12:25:22 +0100 Subject: [PATCH 1/2] gh-155375: `-shared-libsan` for linux sanitizer builds [skip ci] Co-authored-by: Isuru Fernando --- Tools/pixi-packages/build.sh | 20 ++++++++++++++------ Tools/pixi-packages/recipe.yaml | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Tools/pixi-packages/build.sh b/Tools/pixi-packages/build.sh index b13e26d688e46a..4fb4d52a988aac 100644 --- a/Tools/pixi-packages/build.sh +++ b/Tools/pixi-packages/build.sh @@ -4,12 +4,20 @@ echo "PYTHON_VARIANT: ${PYTHON_VARIANT}" if [[ "${PYTHON_VARIANT}" == "freethreading" ]]; then CONFIGURE_EXTRA="--disable-gil" -elif [[ "${PYTHON_VARIANT}" == "asan" ]]; then - CONFIGURE_EXTRA="--with-address-sanitizer" - export ASAN_OPTIONS="strict_init_order=true" -elif [[ "${PYTHON_VARIANT}" == "tsan_freethreading" ]]; then - CONFIGURE_EXTRA="--disable-gil --with-thread-sanitizer" - export TSAN_OPTIONS="suppressions=${SRC_DIR}/Tools/tsan/suppressions_free_threading.txt" +elif [[ "${PYTHON_VARIANT}" == *san* ]]; then + if [[ "${PYTHON_VARIANT}" == "asan" ]]; then + CONFIGURE_EXTRA="--with-address-sanitizer" + export ASAN_OPTIONS="strict_init_order=true" + elif [[ "${PYTHON_VARIANT}" == "tsan_freethreading" ]]; then + CONFIGURE_EXTRA="--disable-gil --with-thread-sanitizer" + export TSAN_OPTIONS="suppressions=${SRC_DIR}/Tools/tsan/suppressions_free_threading.txt" + else + echo "Unknown PYTHON_VARIANT: ${PYTHON_VARIANT}" + exit 1 + fi + if [[ "$target_platform" == linux-* && "$c_compiler" == "clang" ]]; then + export LDFLAGS="-shared-libsan $LDFLAGS" + fi elif [[ "${PYTHON_VARIANT}" == "default" ]]; then CONFIGURE_EXTRA="" else diff --git a/Tools/pixi-packages/recipe.yaml b/Tools/pixi-packages/recipe.yaml index c40fe2ad2e0c79..3ec0c51d347aab 100644 --- a/Tools/pixi-packages/recipe.yaml +++ b/Tools/pixi-packages/recipe.yaml @@ -72,7 +72,7 @@ outputs: - libuuid - libmpdec-devel - expat - - if: osx and "san" in variant + - if: '"san" in variant' then: - libcompiler-rt From 8f706cf707c6015acd05d830efdfe714c54260cf Mon Sep 17 00:00:00 2001 From: Lucas Colley Date: Wed, 16 Sep 2026 17:27:05 +0100 Subject: [PATCH 2/2] gh-155375: pin libcompiler-rt to the active compiler version, bump to clang 22 `libcompiler-rt` was previously unpinned, so the solver could pick a runtime whose major version doesn't match the clang used to build the interpreter and extension modules, causing an ASan runtime/build mismatch. Pin it to the active `c_compiler_version`. Also, move the ASan toolchain default from clang 21 to clang 22, due to https://github.com/python/cpython/issues/145199. --- Tools/pixi-packages/recipe.yaml | 6 +++++- Tools/pixi-packages/variants.yaml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tools/pixi-packages/recipe.yaml b/Tools/pixi-packages/recipe.yaml index 3ec0c51d347aab..a75a66dc352d2e 100644 --- a/Tools/pixi-packages/recipe.yaml +++ b/Tools/pixi-packages/recipe.yaml @@ -2,6 +2,7 @@ context: freethreading_tag: ${{ "t" if "freethreading" in variant else "" }} abi_prefix: ${{ (variant | split("_"))[0] + "_" if "san" in variant else "" }} abi_tag: ${{ abi_prefix }}cp${{ (version | split('.'))[:2] | join('') }}${{ freethreading_tag }} + c_compiler_version: ${{ c_compiler_version }} recipe: name: python @@ -74,7 +75,7 @@ outputs: - expat - if: '"san" in variant' then: - - libcompiler-rt + - libcompiler-rt ${{ c_compiler_version }}.* ignore_run_exports: from_package: @@ -87,6 +88,9 @@ outputs: weak: - python_abi ${{ version }}.* *_${{ abi_tag }} + run_constraints: + - libcompiler-rt ${{ c_compiler_version }}.* + about: homepage: https://www.python.org/ license: Python-2.0 diff --git a/Tools/pixi-packages/variants.yaml b/Tools/pixi-packages/variants.yaml index 2519ec5ea0d6d6..028170825e2028 100644 --- a/Tools/pixi-packages/variants.yaml +++ b/Tools/pixi-packages/variants.yaml @@ -8,8 +8,8 @@ openssl: c_compiler: - clang c_compiler_version: - - 21 + - 22 cxx_compiler: - clangxx cxx_compiler_version: - - 21 + - 22