From ee2ec246b26080a0041bbaaa15e7f7f809b45448 Mon Sep 17 00:00:00 2001 From: Parker Timmerman Date: Sun, 8 Sep 2024 15:58:09 -0400 Subject: [PATCH] update Linux clang toolchain * build in Docker image with Ubuntu 24.04 base * include sanitizer libraries --- clang/Dockerfile | 2 +- clang/bin.txt | 7 ++++++- clang/clang_build.sh | 24 ++++-------------------- clang/clang_package.sh | 7 +++++++ 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/clang/Dockerfile b/clang/Dockerfile index 27a8ae8..0e44198 100644 --- a/clang/Dockerfile +++ b/clang/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 as base_image +FROM ubuntu:24.04 as base_image # Tools needed to install bootsrap clang. RUN apt-get update && apt-get install -y \ diff --git a/clang/bin.txt b/clang/bin.txt index 9e7f15c..307cc60 100644 --- a/clang/bin.txt +++ b/clang/bin.txt @@ -1,4 +1,9 @@ -clang* +clang +clang-$clang_major +clang-cl +clang-cpp +clang++ +clang-tblgen lld ld.lld ld64.lld diff --git a/clang/clang_build.sh b/clang/clang_build.sh index b26f496..0f30409 100755 --- a/clang/clang_build.sh +++ b/clang/clang_build.sh @@ -65,8 +65,9 @@ clang_major_minor_version=$(echo "$clang_version" | cut -d. -f1-2) cmake -G Ninja -S llvm -B build \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_FLAGS="$target_cpu_arg $target_arch_arg -flto=thin -pthread -fPIC -O3 -DNDEBUG" \ - -DCMAKE_CXX_FLAGS="$target_cpu_arg $target_arch_arg -flto=thin -pthread -fPIC -O3 -DNDEBUG" \ + -DCMAKE_C_FLAGS="-flto=thin -pthread -fPIC -O3 -DNDEBUG $target_cpu_arg $target_arch_arg" \ + -DCMAKE_CXX_FLAGS="-flto=thin -pthread -fPIC -O3 -DNDEBUG $target_cpu_arg $target_arch_arg" \ + -DCMAKE_SHARED_LINKER_FLAGS="-fPIC" \ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION="on" \ -DLLVM_ENABLE_PROJECTS="clang;lld" \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt" \ @@ -99,21 +100,4 @@ cmake -G Ninja -S llvm -B build \ # Actually build Clang and friends. -CC="$c_binary" CXX="$cxx_binary" LD="$lld_binary" cmake --build build --target \ - clang \ - lld \ - llvm-ar \ - llvm-as \ - llvm-cov \ - llvm-dwp \ - llvm-libtool-darwin \ - llvm-nm \ - llvm-objcopy \ - llvm-objdump \ - llvm-profdata \ - llvm-strip \ - llvm-ranlib \ - cxx \ - cxxabi \ - unwind \ - builtins +cmake --build build --target all diff --git a/clang/clang_package.sh b/clang/clang_package.sh index 8b6df15..03ba64f 100644 --- a/clang/clang_package.sh +++ b/clang/clang_package.sh @@ -34,7 +34,10 @@ case $build_arch in exit 1 ;; esac + +# These values are used in the `.txt` files that define what we package. clang_target="$clang_arch-unknown-linux-gnu" +clang_major=$(echo "$clang_version" | cut -d '.' -f 1) # Package the toolchain by copying everything listed from the following files: # @@ -51,6 +54,10 @@ mkdir package mv llvm-project/build/include/$clang_target/c++/v1/__config_site llvm-project/build/include/c++/v1/__config_site # Copy all of the files into the 'package' dir. +# +# TODO(parkmycar): The `lib` directory is a bit heavy and we could strip out a +# few unused `libcompiler_rt` libraries, but for now it's easier to just +# include them all. for dir in bin include lib; do mkdir package/$dir