Skip to content

Commit

Permalink
Merge pull request #27598 from LnL7/darwin-cf-rpath
Browse files Browse the repository at this point in the history
CoreFoundation: use rpath to fix issues when using frameworks
  • Loading branch information
LnL7 authored Aug 29, 2017
2 parents 8f713e8 + 5a28fd6 commit adca58c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkgs/build-support/cc-wrapper/ld-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then
fi
done
done

if [ -n "${NIX_COREFOUNDATION_RPATH:-}" ]; then
extraAfter+=(-rpath $NIX_COREFOUNDATION_RPATH)
fi
fi


Expand Down
2 changes: 1 addition & 1 deletion pkgs/os-specific/darwin/apple-sdk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ let
propagatedBuildInputs = deps;

# don't use pure CF for dylibs that depend on frameworks
setupHook = ../../../build-support/setup-hooks/fix-darwin-frameworks.sh;
setupHook = ./framework-setup-hook.sh;

# allows building the symlink tree
__impureHostDeps = [ "/System/Library/Frameworks/${name}.framework" ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ 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
}

envHooks+=(useSystemCoreFoundationFramework)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ appleDerivation {
--replace "/usr/sbin/" "" \
--replace "/bin/" "" \
--replace "INSTALLNAME=/System" "INSTALLNAME=$out" \
--replace "install_name_tool -id /System" "install_name_tool -id $out" \
--replace "install_name_tool -id /System/Library/Frameworks" "install_name_tool -id @rpath" \
--replace 'chown -RH -f root:wheel $(DSTBASE)/CoreFoundation.framework' "" \
--replace 'chmod -RH' 'chmod -R'
Expand Down
1 change: 1 addition & 0 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ in rec {
targetPlatform = localSystem;

preHook = commonPreHook + ''
export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
'';

Expand Down
2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ with pkgs;

fixDarwinDylibNames = makeSetupHook { } ../build-support/setup-hooks/fix-darwin-dylib-names.sh;

fixDarwinFrameworks = makeSetupHook { } ../build-support/setup-hooks/fix-darwin-frameworks.sh;

keepBuildTree = makeSetupHook { } ../build-support/setup-hooks/keep-build-tree.sh;

enableGCOVInstrumentation = makeSetupHook { } ../build-support/setup-hooks/enable-coverage-instrumentation.sh;
Expand Down

0 comments on commit adca58c

Please sign in to comment.