Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoreFoundation: use rpath to fix issues when using frameworks #27598

Merged
merged 3 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed this before, but this should have probably done the @infixSalt@ thing, to support darwin->darwin cross compilation where the path may not be the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this before the salts where added. Not sure if it really matters since it will only point to /System/Library/Frameworks, similar to the dyld path with LD_DYLD_PATH.

Copy link
Member

@Ericson2314 Ericson2314 Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad @LnL7. I thought this was from the PR you just merged in the last 24 hours, and never double checked!

That it's analogous to LD_DYLD_PATH makes perfect sense :)

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