From 4718b814193493f45f5c64df1df7dfd6d51d669f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 1 Aug 2024 00:23:03 +0300 Subject: [PATCH] build-compiler-rt: Build all runtimes for aarch64 and armv7 too Since 0c391133c9201ef29273554a1505ef855ce17668 in llvm-project (LLVM 17), the sanitizers can be built for aarch64, and since 5ea9dd8c7076270695a1d90b9c73718e7d95e0bf (backported to LLVM 19.1.0 RC 4), they can be built for armv7 too. While they can be built, address sanitizer doesn't work for the non-x86 architecture, so omit those files from the install, to make it clear that they aren't expected to work. Thus, in practice, this builds the ubsan and profile runtimes for aarch64 and armv7. --- README.md | 2 +- build-compiler-rt.sh | 32 +++++++++++++------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d26d0de..c234572 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ normal GCC/binutils based MinGW. variables. - The runtime libraries libunwind, libcxxabi and libcxx also assume that the target is Windows 7 or newer. -- The sanitizers are only supported on x86. +- Address sanitizer is only supported on x86. - LLD doesn't support linker script (in the COFF part of LLD). Linker script can be used for reprogramming how the linker lays out the output, but is in most cases in MinGW setups only used for passing lists of object files to link. diff --git a/build-compiler-rt.sh b/build-compiler-rt.sh index 9aaaabc..f80272c 100755 --- a/build-compiler-rt.sh +++ b/build-compiler-rt.sh @@ -93,17 +93,6 @@ fi for arch in $ARCHS; do - if [ -n "$SANITIZERS" ]; then - case $arch in - i686|x86_64) - # Sanitizers on windows only support x86. - ;; - *) - continue - ;; - esac - fi - [ -z "$CLEAN" ] || rm -rf build-$arch$BUILD_SUFFIX mkdir -p build-$arch$BUILD_SUFFIX cd build-$arch$BUILD_SUFFIX @@ -136,19 +125,24 @@ for arch in $ARCHS; do cmake --install . --prefix "$INSTALL_PREFIX" mkdir -p "$PREFIX/$arch-w64-mingw32/bin" if [ -n "$SANITIZERS" ]; then - mv "$INSTALL_PREFIX/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin" + case $arch in + aarch64) + # asan doesn't work on aarch64 or armv7; make this clear by omitting + # the installed files altogether. + rm "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"*aarch64* + ;; + armv7) + rm "$INSTALL_PREFIX/lib/windows/libclang_rt.asan"*arm* + ;; + *) + mv "$INSTALL_PREFIX/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin" + ;; + esac fi - INSTALLED=1 cd .. done if [ "$INSTALL_PREFIX" != "$CLANG_RESOURCE_DIR" ]; then - if [ -z "$INSTALLED" ]; then - # Don't try to move the installed files in place, if nothing was - # installed (e.g. if building with --build-sanitizers but not for x86). - exit 0 - fi - # symlink to system headers - skip copy rm -rf "$INSTALL_PREFIX/include"