Fix clang build adding rpath to libstdc++

The binaries generated during the build process of clang are missing the
RPATH of the libstdc++.so library, which is provided by gcc libs.
Similarly, the clang binary itself also needs the rpath to the
libstdc++.so library path.

Reviewed-by: Aleix Roca Nonell <aleix.rocanonell@bsc.es>
This commit is contained in:
Rodrigo Arias 2023-11-21 16:58:57 +01:00
parent 501a92376b
commit 3f17a489ef

View File

@ -12,6 +12,7 @@
, zlib
, nosv
, pkg-config
, gcc # needed to set the rpath of libstdc++ for clang-tblgen
, enableDebug ? false
, enableNosv ? false
, useGit ? false
@ -71,6 +72,7 @@ in stdenv.mkDerivation rec {
libffi
pkg-config
zlib
gcc.cc.lib # Required for libstdc++.so.6
] ++ lib.optionals enableNosv [
nosv
];
@ -100,7 +102,7 @@ in stdenv.mkDerivation rec {
"-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"
"-DCMAKE_BUILD_RPATH=$PWD/lib:${zlib}/lib:${gcc.cc.lib}/lib"
"-DLLVM_ENABLE_LLD=ON"
"-DCMAKE_CXX_FLAGS_DEBUG=-g -ggnu-pubnames"
"-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-Wl,--gdb-index"
@ -117,7 +119,7 @@ in stdenv.mkDerivation rec {
# Set the rpath to include external libraries (zlib) both on build and
# install
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON"
"-DCMAKE_INSTALL_RPATH=${zlib}/lib"
"-DCMAKE_INSTALL_RPATH=${zlib}/lib:${gcc.cc.lib}/lib"
)
'';