From 4dc3227d4c4646bec09e13c11087b5f89682c0fe Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 23 Sep 2024 22:06:54 -0400 Subject: [PATCH] llvmPackages.clang: use the system libunwind on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the Darwin stdenv bootstrap sets up its own clang wrappers and doesn’t provide these wrappers in the final stdenv, it does use them indirectly via the LLVM bootstrap to build LLVM and its libraries. Note on using the system libunwind: It is possible to build and use the LLVM libunwind on Darwin, but using the system by default one ensures everything is using the same unwinder. --- .../compilers/llvm/common/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index 681e563d65a7..c863d0d8a82a 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -781,16 +781,20 @@ let bintools = bintools'; extraPackages = [ targetLlvmLibraries.compiler-rt-no-libc ] - ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ - targetLlvmLibraries.libunwind - ]; + ++ lib.optionals + ( + !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin + ) + [ + targetLlvmLibraries.libunwind + ]; extraBuildCommands = lib.optionalString (lib.versions.major metadata.release_version == "13") ( '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt-no-libc}/lib" >> $out/nix-support/cc-cflags '' - + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isDarwin) '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags '' @@ -811,7 +815,7 @@ let "-B${targetLlvmLibraries.compiler-rt-no-libc}/lib" ] ++ lib.optional ( - !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD + !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin ) "--unwindlib=libunwind" ++ lib.optional ( !stdenv.targetPlatform.isWasm @@ -820,7 +824,7 @@ let ) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; nixSupport.cc-ldflags = lib.optionals ( - !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD + !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin ) [ "-L${targetLlvmLibraries.libunwind}/lib" ]; } );