Skip to content

Commit

Permalink
llvmPackages_15.libcxx: specify `LIBCXX_CXX_ABI_{LIBRARY_PATH,INCLUDE…
Browse files Browse the repository at this point in the history
…_PATHS}` for all cxxabis

Previously we only specified `LIBCXX_CXX_ABI_INCLUDE_PATHS` for
`libcxxabi` and not for `libcxxrt` which causes `libcxx`'s build to
fall back to looking in `/usr/include/c++/v1`: https://github.com/llvm/llvm-project/blob/aa656f6c2dec73faceeed21e15401d8f0c743c8b/libcxx/cmake/Modules/HandleLibCXXABI.cmake#L148-L151

We didn't set `LIBCXX_CXX_ABI_LIBRARY_PATH` (and this did not seem to be
a problem; I think this gets defaulted elsewhere in the `libcxx` build)
but it doesn't hurt to.
  • Loading branch information
rrbutani authored and Artturin committed Sep 8, 2023
1 parent d177ad9 commit 906d39b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkgs/development/compilers/llvm/15/libcxx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ stdenv.mkDerivation rec {

cmakeFlags = let
# See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
libcxx_cxx_abi_opt = {
"c++abi" = "system-libcxxabi";
"cxxrt" = "libcxxrt";
# And: https://github.com/llvm/llvm-project/blob/aa656f6c2dec73faceeed21e15401d8f0c743c8b/libcxx/cmake/Modules/HandleLibCXXABI.cmake#L82-L180
libcxx_cxx_abi_options = {
"c++abi" = { name = "system-libcxxabi"; headers = "${cxxabi.dev}/include/c++/v1"; };
"cxxrt" = { name = "libcxxrt"; headers = "${cxxabi}/include"; };
}.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
in [
"-DLLVM_ENABLE_RUNTIMES=libcxx"
"-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
"-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_options.name}"
] ++ lib.optional (!headersOnly) "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${libcxx_cxx_abi_options.headers}"
++ lib.optional (!headersOnly) "-DLIBCXX_CXX_ABI_LIBRARY_PATH=${cxxabi}/lib"
++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBCXX_USE_COMPILER_RT=ON"
Expand Down

0 comments on commit 906d39b

Please sign in to comment.