about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix')
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix21
1 files changed, 17 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
index 94374c8a312d..f267b753b24a 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
@@ -2,7 +2,7 @@
 , monorepoSrc, runCommand
 , cmake, ninja, python3, fixDarwinDylibNames, version
 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt
+, libcxxabi, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
 
 # If headersOnly is true, the resulting package would only include the headers.
@@ -62,7 +62,10 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake ninja python3 ]
     ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
-  buildInputs = lib.optionals (!headersOnly) [ cxxabi ];
+  buildInputs =
+    lib.optionals (!headersOnly) [ cxxabi ]
+    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ];
+
 
   cmakeFlags = let
     # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
@@ -75,8 +78,18 @@ stdenv.mkDerivation rec {
     "-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"
     ++ 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 [
+    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+      "-DLIBCXX_USE_COMPILER_RT=ON"
+      # (Backport fix from 16, which has LIBCXX_ADDITIONAL_LIBRARIES, but 15
+      # does not appear to)
+      # There's precedent for this in llvm-project/libcxx/cmake/caches.
+      # In a monorepo build you might do the following in the libcxxabi build:
+      #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
+      #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
+      # libcxx appears to require unwind and doesn't pull it in via other means.
+      # "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
+      "-DCMAKE_SHARED_LINKER_FLAGS=-lunwind"
+    ] ++ lib.optionals stdenv.hostPlatform.isWasm [
       "-DLIBCXX_ENABLE_THREADS=OFF"
       "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
       "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"