Skip to content

Commit

Permalink
build-compiler-rt: Build all runtimes for aarch64 and armv7 too
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mstorsjo committed Sep 10, 2024
1 parent b6b58d9 commit 4718b81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 13 additions & 19 deletions build-compiler-rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 4718b81

Please sign in to comment.