diff options
Diffstat (limited to 'content/2022-07-07-llvm-orc-jit/build-llvm.sh')
-rw-r--r-- | content/2022-07-07-llvm-orc-jit/build-llvm.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/content/2022-07-07-llvm-orc-jit/build-llvm.sh b/content/2022-07-07-llvm-orc-jit/build-llvm.sh new file mode 100644 index 0000000..df9d6b8 --- /dev/null +++ b/content/2022-07-07-llvm-orc-jit/build-llvm.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# A small utility script to help me build specific llvm versions. +# +# ## General cmake build info +# +# See [1] for an overview of the llvm cmake build and a discussion of the most +# frequently used cmake options. +# +# ## Building on low end machines +# +# Builds with debug information can use a lot of RAM and disk space and is +# usually slower to run. You can improve RAM usage by using lld, see the +# LLVM_USE_LINKER option. +# +# LLVM_PARALLEL_{COMPILE,LINK}_JOBS:STRING [2] +# Building the llvm toolchain can use a lot of resources, particularly +# linking. These options, when you use the Ninja generator, allow you to +# restrict the parallelism. For example, to avoid OOMs or going into swap, +# permit only one link job per 15GB of RAM available on a 32GB machine, +# specify -G Ninja -DLLVM_PARALLEL_LINK_JOBS=2. +# +# [1]: https://llvm.org/docs/CMake.html +# [2]: https://llvm.org/docs/CMake.html#frequently-used-llvm-related-variables + +#TAG=llvmorg-14.0.6 +#TAG=llvmorg-15.0.0 +#TAG=llvmorg-15.0.7 +TAG=llvmorg-17.0.5 + +SRCDIR=src-$TAG + +if [[ ! -d $SRCDIR ]]; then + git clone --depth 1 --branch $TAG https://github.com/llvm/llvm-project.git $SRCDIR +fi + +cmake -S $SRCDIR/llvm -B $SRCDIR/BUILD -G Ninja \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_INSTALL_PREFIX=$PWD/install-$TAG \ + -DCMAKE_BUILD_TYPE=Debug \ + -DLLVM_ENABLE_PROJECTS='clang' \ + -DLLVM_BUILD_LLVM_DYLIB=1 \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_TARGETS_TO_BUILD='X86' \ + -DLLVM_USE_LINKER=lld \ + -DLLVM_PARALLEL_LINK_JOBS=1 + +cmake --build $SRCDIR/BUILD --target install |