From 4bde5a3a68d8d7095017f57c831b6f9540848e16 Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Mon, 24 Jan 2022 03:20:51 -0800 Subject: [PATCH] libredirect: fix build for aarch64-darwin (PR #156460) --- pkgs/build-support/libredirect/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/libredirect/default.nix b/pkgs/build-support/libredirect/default.nix index 5545c93c19e1..9ed00c8a8f63 100644 --- a/pkgs/build-support/libredirect/default.nix +++ b/pkgs/build-support/libredirect/default.nix @@ -44,7 +44,7 @@ else stdenv.mkDerivation rec { -isystem ${llvmPackages_13.clang.libc}/include \ -isystem ${llvmPackages_13.libclang.lib}/lib/clang/*/include \ -L${llvmPackages_13.clang.libc}/lib \ - -Wl,-install_name,$out/lib/$libName \ + -Wl,-install_name,$libName \ -Wall -std=c99 -O3 -fPIC libredirect.c \ -ldl -shared -o "$libName" '' else if stdenv.isDarwin then '' @@ -73,6 +73,12 @@ else stdenv.mkDerivation rec { install -vD "$libName" "$out/lib/$libName" + '' + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) '' + # dylib will be rejected unless dylib rpath gets explictly set + install_name_tool \ + -change $libName $out/lib/$libName \ + $out/lib/$libName + '' + '' # Provide a setup hook that injects our library into every process. mkdir -p "$hook/nix-support" cat < "$hook/nix-support/setup-hook"