From 2f0ae7f9df8aaaadd4e22cbe7dda02351bbc9376 Mon Sep 17 00:00:00 2001 From: Rahul Butani Date: Fri, 27 Jan 2023 12:23:54 -0800 Subject: [PATCH] llvmPackages_git: apply #211230 to llvmPackages_git See the comments here for context: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r1089389188 Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com> --- .../compilers/llvm/git/libcxx/default.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index af4bd85a1b6df..cd023b3535284 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -17,7 +17,7 @@ let basename = "libcxx"; in -assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi"; +assert stdenv.isDarwin -> cxxabi.libName == "c++abi"; stdenv.mkDerivation rec { pname = basename + lib.optionalString headersOnly "-headers"; @@ -64,10 +64,16 @@ stdenv.mkDerivation rec { buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; - cmakeFlags = [ + 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"; + }.${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.pname == "libcxxabi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" + ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" ++ lib.optionals stdenv.hostPlatform.isWasm [