From abc77c22a8896de4724efdfdfd46114d6c37da4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 22 Mar 2026 12:33:20 +0200 Subject: [PATCH] build-compiler-rt: Stop providing asan in msvcrt builds See 0b296aefc0ce1dad3abd0351768c8edfebfc43a8 for context, where we stopped testing asan in msvcrt builds - see discussion at https://github.com/llvm/llvm-project/pull/120397, https://github.com/mstorsjo/llvm-mingw/issues/224 and https://github.com/mstorsjo/llvm-mingw/issues/552. This should make it clearer that asan isn't supported in msvcrt builds, instead of silently just providing files that are known not to work. See 4718b814193493f45f5c64df1df7dfd6d51d669f for earlier context for where we remove the asan runtimes in armv7/aarch64 builds, where the files do get built, but they don't work properly yet (even on UCRT). --- build-compiler-rt.sh | 45 +++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/build-compiler-rt.sh b/build-compiler-rt.sh index 3e61eeb..98b424c 100755 --- a/build-compiler-rt.sh +++ b/build-compiler-rt.sh @@ -82,6 +82,18 @@ else esac fi +cat< is-ucrt.c +#include +#if !defined(_UCRT) +#error not ucrt +#endif +EOF +ANY_ARCH=$(echo $ARCHS | awk '{print $1}') +if $ANY_ARCH-w64-mingw32-gcc$TOOLEXT -E is-ucrt.c > /dev/null 2>&1; then + IS_UCRT=1 +fi +rm -f is-ucrt.c + cd llvm-project/compiler-rt INSTALL_PREFIX="$CLANG_RESOURCE_DIR" @@ -162,19 +174,26 @@ for arch in $ARCHS; do cmake --install . --prefix "$INSTALL_PREFIX" mkdir -p "$PREFIX/$arch-w64-mingw32/bin" if [ -n "$SANITIZERS" ]; then - case $arch in - aarch64) - # asan doesn't work on aarch64 or armv7; make this clear by omitting - # the installed files altogether. - rm -f "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"*aarch64* - ;; - armv7) - rm -f "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"*arm* - ;; - *) - mv "$INSTALL_PREFIX/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin" - ;; - esac + if [ -z "$IS_UCRT" ]; then + # For msvcrt builds, remove the asan files; asan doesn't work + # properly on top of msvcrt, only on top of UCRT. Make this clear + # by omitting the installed files altogether. + rm -f "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"* + else + case $arch in + aarch64) + # asan doesn't work on aarch64 or armv7; make this clear by omitting + # the installed files altogether. + rm -f "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"*aarch64* + ;; + armv7) + rm -f "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"*arm* + ;; + *) + mv "$INSTALL_PREFIX/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin" + ;; + esac + fi fi cd .. done