From 0e724f285f9569a9b4b2d05235fb67fe21f5144a Mon Sep 17 00:00:00 2001 From: Frances Wingerter Date: Fri, 18 Oct 2024 17:32:08 -0400 Subject: [PATCH] build other runtime components to avoid any system code in our runtime dependencies --- ...ild-compiler-rt.sh => cross-build-rtlibs.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) rename cross-build-compiler-rt.sh => cross-build-rtlibs.sh (56%) diff --git a/cross-build-compiler-rt.sh b/cross-build-rtlibs.sh similarity index 56% rename from cross-build-compiler-rt.sh rename to cross-build-rtlibs.sh index 1e76c1131730..26a29034b902 100755 --- a/cross-build-compiler-rt.sh +++ b/cross-build-rtlibs.sh @@ -1,20 +1,22 @@ #!/bin/sh +# build compiler-rt, libcxx, libcxxabi, and libunwind with our patched clang # see https://llvm.org/docs/HowToCrossCompileBuiltinsOnArm.html -mkdir -p build-compiler-rt -cd build-compiler-rt -cross_flags="--gcc-toolchain=/usr -isystem /usr/aarch64-linux-gnu/include -march=armv8.5-a+memtag -ffixed-x18" +mkdir -p build-rtlibs +cd build-rtlibs +cross_flags="--sysroot=/usr/aarch64-linux-gnu/ --gcc-install-dir=/usr/lib/gcc/aarch64-linux-gnu/14.1.0 --rtlib=compiler-rt -march=armv8+memtag -ffixed-x18" export LDFLAGS="-L/usr/aarch64-linux-gnu/lib" cmake -GNinja -DLLVM_TARGETS_TO_BUILD="AArch64" -DLLVM_DEFAULT_TARGET_TRIPLE="aarch64-linux-gnu" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_FLAGS="$cross_flags --target=aarch64-linux-gnu" -DCMAKE_CXX_FLAGS="$cross_flags --target=aarch64-linux-gnu" \ -DCMAKE_C_COMPILER="$(pwd)/../build/bin/clang" -DCMAKE_CXX_COMPILER="$(pwd)/../build/bin/clang" \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=true \ - -DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_ORC=OFF \ - -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ - -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="aarch64-linux-gnu" \ - ../compiler-rt + -DCMAKE_EXE_LINKER_FLAGS='--rtlib=compiler-rt' \ + -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DLIBCXX_USE_COMPILER_RT=YES \ + -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;compiler-rt;libunwind' \ + ../runtimes ninja -cd lib/linux +cd compiler-rt/lib/linux # rename CRT files to expected filenames cp -a clang_rt.crtend-aarch64.o crtendS.o cp -a clang_rt.crtbegin-aarch64.o crtbeginS.o