diff --git a/pkgs/build-support/bintools-wrapper/ld-wrapper.sh b/pkgs/build-support/bintools-wrapper/ld-wrapper.sh index 3bd9c68f2336..7e00d02b0374 100644 --- a/pkgs/build-support/bintools-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/bintools-wrapper/ld-wrapper.sh @@ -226,12 +226,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 96a08178637d..b57312e63a2d 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -41,9 +41,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/default.nix b/pkgs/os-specific/darwin/apple-sdk/default.nix index 30081c824378..1cd5afe19301 100644 --- a/pkgs/os-specific/darwin/apple-sdk/default.nix +++ b/pkgs/os-specific/darwin/apple-sdk/default.nix @@ -163,17 +163,6 @@ let propagatedBuildInputs = builtins.attrValues deps; - # don't use pure CF for dylibs that depend on frameworks - setupHook = ./framework-setup-hook.sh; - - # Not going to be more specific than this for now - __propagatedImpureHostDeps = lib.optionals (name != "Kernel") [ - # The setup-hook ensures that everyone uses the impure CoreFoundation who uses these SDK frameworks, so let's expose it - "/System/Library/Frameworks/CoreFoundation.framework" - "/System/Library/Frameworks/${name}.framework" - "/System/Library/Frameworks/${name}.framework/${name}" - ]; - meta = with lib; { description = "Apple SDK framework ${name}"; maintainers = with maintainers; [ copumpkin ]; diff --git a/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh b/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh deleted file mode 100644 index b0d5915fc1fc..000000000000 --- a/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh +++ /dev/null @@ -1,42 +0,0 @@ -# On macOS, frameworks are linked to the system CoreFoundation but -# dynamic libraries built with nix use a pure version of CF this -# causes segfaults for binaries that depend on it at runtime. This -# can be solved in two ways. -# 1. Rewrite references to the pure CF using this setup hook, this -# works for the simple case but this can still cause problems if other -# dependencies (eg. python) use the pure CF. -# 2. Create a wrapper for the binary that sets DYLD_FRAMEWORK_PATH to -# /System/Library/Frameworks. This will make everything load the -# system's CoreFoundation framework while still keeping the -# dependencies pure for other packages. - -fixupOutputHooks+=('fixDarwinFrameworksIn $prefix') - -fixDarwinFrameworks() { - local systemPrefix='/System/Library/Frameworks' - - for fn in "$@"; do - if [ -L "$fn" ]; then continue; fi - echo "$fn: fixing dylib" - - for framework in $(otool -L "$fn" | awk '/CoreFoundation\.framework/ {print $1}'); do - install_name_tool -change "$framework" "$systemPrefix/CoreFoundation.framework/Versions/A/CoreFoundation" "$fn" >&2 - done - done -} - -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/os-specific/darwin/swift-corelibs/corefoundation.nix b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix index 5c593b1488e2..0b7c85b588f2 100644 --- a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix +++ b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix @@ -86,6 +86,5 @@ stdenv.mkDerivation { "$out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation" mkdir -p "$out/nix-support" - substituteAll ${./pure-corefoundation-hook.sh} "$out/nix-support/setup-hook" ''; } diff --git a/pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh b/pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh deleted file mode 100644 index d5539f50861a..000000000000 --- a/pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh +++ /dev/null @@ -1,7 +0,0 @@ -usePureCoreFoundation() { -# Avoid overriding value set by the impure CF - if [ -z "${NIX_COREFOUNDATION_RPATH:-}" ]; then - export NIX_COREFOUNDATION_RPATH=@out@/Library/Frameworks - fi -} -addEnvHooks "$hostOffset" usePureCoreFoundation