From 01e07d559cd235667cfcc87dc92dc7e857e9d65a Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 6 Sep 2023 14:14:40 +0200 Subject: [PATCH] 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. --- bsc/llvm-ompss2/clang.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bsc/llvm-ompss2/clang.nix b/bsc/llvm-ompss2/clang.nix index ce1a585..f38bfea 100644 --- a/bsc/llvm-ompss2/clang.nix +++ b/bsc/llvm-ompss2/clang.nix @@ -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" )