@@ -7,6 +7,13 @@ if [[ "${PYTHON_VARIANT}" == "freethreading" ]]; then
77elif [[ " ${PYTHON_VARIANT} " == " asan" ]]; then
88 CONFIGURE_EXTRA=" --with-address-sanitizer"
99 export ASAN_OPTIONS=" strict_init_order=true"
10+ if [[ " $target_platform " == linux-* && " $c_compiler " == " clang" ]]; then
11+ export LDFLAGS=" -shared-libsan $LDFLAGS "
12+ # with -shared-libsan, conftest/python binaries link the ASan runtime
13+ # dynamically; it lives under $BUILD_PREFIX (from the clang build
14+ # dependency), not $PREFIX, so the loader can't find it without this.
15+ export LD_LIBRARY_PATH=" ${BUILD_PREFIX} /lib:${LD_LIBRARY_PATH} "
16+ fi
1017elif [[ " ${PYTHON_VARIANT} " == " tsan_freethreading" ]]; then
1118 CONFIGURE_EXTRA=" --disable-gil --with-thread-sanitizer"
1219 export TSAN_OPTIONS=" suppressions=${SRC_DIR} /Tools/tsan/suppressions_free_threading.txt"
@@ -58,3 +65,12 @@ touch configure-done
5865
5966make -j" ${CPU_COUNT} " install
6067ln -sf " ${PREFIX} /bin/python3" " ${PREFIX} /bin/python"
68+
69+ if [[ " ${PYTHON_VARIANT} " == " asan" && " $target_platform " == linux-* && " $c_compiler " == " clang" ]]; then
70+ # python is linked with -shared-libsan, so it (and anything invoking it,
71+ # e.g. numpy's build) needs the ASan runtime findable at load time.
72+ # Ship it in $PREFIX/lib: python's own rpath already points there, and
73+ # that rpath gets relocated to wherever this package is installed, so no
74+ # LD_LIBRARY_PATH is needed downstream.
75+ cp " ${BUILD_PREFIX} " /lib/libclang_rt.asan-* .so " ${PREFIX} /lib/"
76+ fi
0 commit comments