From 8c5afad60774551467aec77da317be7517ae9590 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Mon, 17 Jul 2023 00:21:20 -0400 Subject: [PATCH] tell build script about llvm version this will be needed to support compiler-rt build + installation later. --- Containerfile.llvm | 17 +++++++++-------- README.md | 2 +- scripts/build_llvm.sh | 13 +++++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Containerfile.llvm b/Containerfile.llvm index e72a448..a4ca865 100644 --- a/Containerfile.llvm +++ b/Containerfile.llvm @@ -1,22 +1,21 @@ - - +# global arguments +ARG LLVM_SOURCE_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/llvm-project-16.0.0.src.tar.xz" +ARG LLVM_VERSION="16" # the base layer. FROM debian:oldstable AS base ENV DEBIAN_FRONTEND="noninteractive" RUN apt-get update -# base layer for building +# base layer for building anything FROM base AS build-base WORKDIR /build ARG BUILD_DEPS="curl ca-certificates build-essential python3 cmake ninja-build pkg-config git zlib1g-dev" RUN apt-get install -y --no-install-recommends $BUILD_DEPS - -# This comes with the LLVM source code extracted to /build/llvm +# This layer extracts the LLVM source code extracted to /build/llvm FROM build-base as llvm-base -ARG LLVM_SOURCE_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/llvm-project-16.0.0.src.tar.xz" -ARG LLVM_VERSION="16" +ARG LLVM_SOURCE_URL RUN mkdir llvm && \ cd llvm && \ curl -L $LLVM_SOURCE_URL | tar --strip-components=1 -xJf - @@ -26,5 +25,7 @@ RUN mkdir llvm && \ # /build/llvm-bin is expected to be mounted to a host directory. FROM llvm-base as llvm-build COPY scripts/build_llvm.sh . -ENTRYPOINT ["/bin/bash", "-xeuo", "pipefail", "-O", "globstar", "-O", "dotglob"] +ARG LLVM_VERSION +ENV LLVM_VERSION=$LLVM_VERSION +ENTRYPOINT [ "/bin/bash" ] CMD [ "/build/build_llvm.sh" ] diff --git a/README.md b/README.md index 7e6548b..246e9a0 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 --cpus 16 -m 8G --mount type=bind,source=$PWD/llvm_build,destination=/build/llvm-bin localhost/llvm-build +podman run --cpus 16 -m 8G --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 6968102..d1d4184 100755 --- a/scripts/build_llvm.sh +++ b/scripts/build_llvm.sh @@ -1,25 +1,26 @@ #!/bin/bash # 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 +# This is run in a debian container to try and keep everything ABI stable. JOBS=$(nproc) # Configure LLVM. THis is a mouthful, but it's only a mouthful because we specialize things we don't # want in our minimal build of the LLVM project/clang. -cmake -GNinja -S /build/llvm/llvm -B /build/llvm-bin/build \ +cmake -Wno-dev -GNinja -S /build/llvm/llvm -B /build/llvm-build/build \ -DCMAKE_BUILD_TYPE=MinSizeRel \ - -DCMAKE_INSTALL_PREFIX="/build/llvm-bin/install" \ + -DCMAKE_INSTALL_PREFIX="/build/llvm-build/install" \ -DLLVM_INCLUDE_TESTS=OFF \ -DLLVM_ENABLE_PROJECTS="clang;lld" \ -DLLVM_TARGETS_TO_BUILD="RISCV" \ -DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-none-gnu" - ninja -C /build/llvm-bin/build -j $JOBS -# TODO: Configure and build compiler-rt with our toolchain. -#cmake -GNinja -S llvm_src/compiler-rt \ +# 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 \