darwin.libunwind: improve compatibility with libunwind

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.
This commit is contained in:
Randy Eckenrode 2024-09-02 10:07:54 -04:00
parent 7b23be1afd
commit ec40b04537
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
2 changed files with 30 additions and 0 deletions

View File

@ -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.
# Its also not possible to link libunwind directly, otherwise. Darwin requires going through libSystem.
buildCommand = ''
mkdir -p "$out/lib/pkgconfig"
cat <<EOF > "$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" ];
};
})

View File

@ -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 { };