From 4f103fbbb7aac1649ab69c621975c0171b867d63 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 12 Apr 2023 20:09:05 -0600 Subject: [PATCH] stdenv: remove the NIX_COREFOUNDATION_RPATH sledgehammer Similar to PR #223861 and the issue #221350, NIX_COREFOUNDATION_RPATH is set unconditionally in the darwin stdenv. This is wrong for cross- compiles and results in `rpaths` depending on the builder platform. This change makes another bold move and deletes the NIX_COREFOUNDATION_RPATH facility completely, in the hope it is no longer needed, or that any breakage is manageable. As an added bonus we can delete a darwin specific hack in glibc. --- pkgs/build-support/bintools-wrapper/ld-wrapper.sh | 6 ------ pkgs/development/libraries/glibc/default.nix | 3 --- .../darwin/apple-sdk/framework-setup-hook.sh | 11 ----------- pkgs/stdenv/darwin/default.nix | 1 - 4 files changed, 21 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/ld-wrapper.sh b/pkgs/build-support/bintools-wrapper/ld-wrapper.sh index 0d832bc4a67a0..7366be185f42d 100644 --- a/pkgs/build-support/bintools-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/bintools-wrapper/ld-wrapper.sh @@ -224,12 +224,6 @@ if [[ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 1 && "$linkType" != static-pie ]]; t fi -# This is outside the DONT_SET_RPATH branch because it's more targeted and we -# usually want it (on Darwin) even if DONT_SET_RPATH is set. -if [ -n "${NIX_COREFOUNDATION_RPATH:-}" ]; then - extraAfter+=(-rpath $NIX_COREFOUNDATION_RPATH) -fi - # Only add --build-id if this is a final link. FIXME: should build gcc # with --enable-linker-build-id instead? # diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix index 1c0c1b09e1542..f8b96cb3dbde6 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -40,9 +40,6 @@ in # Apparently --bindir is not respected. makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin") - '' + lib.optionalString stdenv.buildPlatform.isDarwin '' - # ld-wrapper will otherwise attempt to inject CoreFoundation into ld-linux's RUNPATH - export NIX_COREFOUNDATION_RPATH= ''; # The pie, stackprotector and fortify hardening flags are autodetected by diff --git a/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh b/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh index b0d5915fc1fcf..cf8416c0838dc 100644 --- a/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh +++ b/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh @@ -29,14 +29,3 @@ fixDarwinFrameworksIn() { local dir="$1" fixDarwinFrameworks $(find "$dir" -name "*.dylib") } - - -# This configures the stdenv to use /System/Library/Frameworks/CoreFoundation.framework -# instead of the nix version by including the system frameworks path -# as an rpath entry when creating binaries. - -useSystemCoreFoundationFramework () { - export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks -} - -addEnvHooks "$hostOffset" useSystemCoreFoundationFramework diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index ffe99da869225..08582ef76923a 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -681,7 +681,6 @@ rec { targetPlatform = localSystem; preHook = commonPreHook + '' - export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks export PATH_LOCALE=${pkgs.darwin.locale}/share/locale '';