From 7f82d7ce9726bb87a7550c4c9f61b787b41f9dec Mon Sep 17 00:00:00 2001 From: modeco80 Date: Mon, 17 Jul 2023 01:47:51 -0400 Subject: [PATCH] build compiler-rt --- README.md | 2 +- scripts/build_llvm.sh | 33 ++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f012dfa..c65fd78 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ LLVM is built using a podman container (see Containerfile). The steps for replic ``` mkdir llvm_build podman build -t llvm-build -f Containerfile.llvm -podman run --rm --cpus 16 -m 12G --mount type=bind,source=$PWD/llvm_build,destination=/build/llvm-build localhost/llvm-build +podman run --rm --cpus 24 -m 32G --mount type=bind,source=$PWD/llvm_build,destination=/build/llvm-build localhost/llvm-build ``` diff --git a/scripts/build_llvm.sh b/scripts/build_llvm.sh index d1d4184..c7d5891 100755 --- a/scripts/build_llvm.sh +++ b/scripts/build_llvm.sh @@ -3,6 +3,9 @@ # This script builds the llvm components used by the LCPU addon. # This is run in a debian container to try and keep everything ABI stable. +# Act like make, sort of, and fail the whole script if some part fails +set -e + JOBS=$(nproc) # Configure LLVM. THis is a mouthful, but it's only a mouthful because we specialize things we don't @@ -15,15 +18,23 @@ cmake -Wno-dev -GNinja -S /build/llvm/llvm -B /build/llvm-build/build \ -DLLVM_TARGETS_TO_BUILD="RISCV" \ -DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-none-gnu" -ninja -C /build/llvm-bin/build -j $JOBS +ninja -C /build/llvm-build/build -j $JOBS +ninja -C /build/llvm-build install -# TODO: Build compiler-rt with our toolchain. -# This currently does not work as a single build (why would it), we instead -# need to stage things (the first building clang + lld), and this being the last stage currently -#cmake -Wno-dev -GNinja -S llvm_src/compiler-rt \ -# -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ -# -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ -# -DCOMPILER_RT_BUILD_PROFILE=OFF \ -# -DCOMPILER_RT_BUILD_MEMPROF=OFF \ -# -DCOMPILER_RT_BUILD_ORC=OFF \ -# -DCOMPILER_RT_BAREMETAL_BUILD=ON +# Build compiler-rt with our toolchain. +cmake -Wno-dev -GNinja -S /build/llvm/compiler-rt -B /build/llvm-build/build-compiler-rt \ + -DCMAKE_C_COMPILER="/build/llvm-build/install/bin/clang" \ + -DCMAKE_CXX_COMPILER="/build/llvm-build/install/bin/clang++" \ + -DCMAKE_C_FLAGS="-target riscv32-none-gnu" \ + -DCMAKE_CXX_FLAGS="-target riscv32-none-gnu" \ + -DCMAKE_INSTALL_PREFIX="/build/llvm-build/install/lib/clang/${LLVM_VERSION}" \ + -DLLVM_CONFIG_PATH="/build/llvm-build/install/bin/llvm-config" \ + -DCOMPILER_RT_BAREMETAL_BUILD=ON \ + -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ + -DCOMPILER_RT_BUILD_PROFILE=OFF \ + -DCOMPILER_RT_BUILD_MEMPROF=OFF \ + -DCOMPILER_RT_BUILD_ORC=OFF + +ninja -C /build/llvm-build/build-compiler-rt -j $JOBS +ninja -C /build/llvm-build/build-compiler-rt install