From ec40b0453730d7555bccccbd94c8dab9e36f3dd6 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 2 Sep 2024 10:07:54 -0400 Subject: [PATCH] darwin.libunwind: improve compatibility with libunwind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Darwin uses the system unwinder, which is based on the LLVM unwinder. While it’s mostly API-compatible with libunwind, some packages expect to find it using `pkg-config`. This package provides a compatible file to allow those packages to use the system unwinder on Darwin. --- pkgs/os-specific/darwin/libunwind/default.nix | 28 +++++++++++++++++++ pkgs/top-level/darwin-packages.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/os-specific/darwin/libunwind/default.nix diff --git a/pkgs/os-specific/darwin/libunwind/default.nix b/pkgs/os-specific/darwin/libunwind/default.nix new file mode 100644 index 000000000000..a19bfc6864e3 --- /dev/null +++ b/pkgs/os-specific/darwin/libunwind/default.nix @@ -0,0 +1,28 @@ +{ + lib, + apple-sdk, + stdenvNoCC, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "libunwind"; + inherit (apple-sdk) version; + + # No `-lunwind` is provided becuase you get it automatically from linking with libSystem. + # It’s also not possible to link libunwind directly, otherwise. Darwin requires going through libSystem. + buildCommand = '' + mkdir -p "$out/lib/pkgconfig" + cat < "$out/lib/pkgconfig/libunwind.pc" + Name: libunwind + Description: An implementation of the HP libunwind interface + Version: ${finalAttrs.version} + EOF + ''; + + meta = { + description = "Compatibility package for libunwind on Darwin"; + maintainers = lib.teams.darwin.members; + platforms = lib.platforms.darwin; + pkgConfigModules = [ "libunwind" ]; + }; +}) diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index 693742fd952f..3725ae98324e 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -169,6 +169,8 @@ impure-cmds // appleSourcePackages // stubs // { propagatedBuildInputs = [ pkgs.darwin.print-reexports ]; } ../os-specific/darwin/print-reexports/setup-hook.sh; + libunwind = callPackage ../os-specific/darwin/libunwind { }; + sigtool = callPackage ../os-specific/darwin/sigtool { }; signingUtils = callPackage ../os-specific/darwin/signing-utils { };