1#!/usr/bin/env bash 2 3set -ex 4 5source shared.sh 6 7LLVM=llvmorg-16.0.0 8 9mkdir llvm-project 10cd llvm-project 11 12curl -L https://github.com/llvm/llvm-project/archive/$LLVM.tar.gz | \ 13 tar xzf - --strip-components=1 14 15mkdir clang-build 16cd clang-build 17 18# For whatever reason the default set of include paths for clang is different 19# than that of gcc. As a result we need to manually include our sysroot's 20# include path, /rustroot/include, to clang's default include path. 21INC="/rustroot/include:/usr/include" 22 23# We need compiler-rt for the profile runtime (used later to PGO the LLVM build) 24# but sanitizers aren't currently building. Since we don't need those, just 25# disable them. BOLT is used for optimizing LLVM. 26hide_output \ 27 cmake ../llvm \ 28 -DCMAKE_C_COMPILER=/rustroot/bin/gcc \ 29 -DCMAKE_CXX_COMPILER=/rustroot/bin/g++ \ 30 -DCMAKE_BUILD_TYPE=Release \ 31 -DCMAKE_INSTALL_PREFIX=/rustroot \ 32 -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ 33 -DCOMPILER_RT_BUILD_XRAY=OFF \ 34 -DCOMPILER_RT_BUILD_MEMPROF=OFF \ 35 -DLLVM_TARGETS_TO_BUILD=X86 \ 36 -DLLVM_INCLUDE_BENCHMARKS=OFF \ 37 -DLLVM_INCLUDE_TESTS=OFF \ 38 -DLLVM_INCLUDE_EXAMPLES=OFF \ 39 -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \ 40 -DC_INCLUDE_DIRS="$INC" 41 42hide_output make -j$(nproc) 43hide_output make install 44 45cd ../.. 46rm -rf llvm-project 47