Link clang with the dynamic llvm library

It dramatically reduces the size of the installation to 250 MiB. We also
need to inject the rpath of the libraries during the build phase with
CMAKE_BUILD_RPATH as well as zlib. The CMAKE_BUILD_WITH_INSTALL_PATH
option is disabled, as it contradicts the former.
This commit is contained in:
Rodrigo Arias 2023-09-06 14:14:40 +02:00
parent 4b06175b42
commit 01e07d559c

View File

@ -71,6 +71,10 @@ stdenv.mkDerivation rec {
cmakeFlagsArray=(
"-DLLVM_HOST_TRIPLE=${stdenv.targetPlatform.config}"
"-DLLVM_TARGETS_TO_BUILD=host"
"-DLLVM_BUILD_LLVM_DYLIB=ON"
"-DLLVM_LINK_LLVM_DYLIB=ON"
# Required to run clang-ast-dump and clang-tblgen during build
"-DCMAKE_BUILD_RPATH=$PWD/lib:${zlib}/lib"
"-DLLVM_ENABLE_LLD=ON"
"-DCMAKE_CXX_FLAGS_DEBUG=-g -ggnu-pubnames"
"-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-Wl,-gdb-index"
@ -83,7 +87,6 @@ stdenv.mkDerivation rec {
"-DLLVM_ENABLE_LIBXML2=OFF"
# Set the rpath to include external libraries (zlib) both on build and
# install
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON"
"-DCMAKE_INSTALL_RPATH=${zlib}/lib"
)