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

stdenv, binutils: Build cctools targeting macOS on Linux without pointless rebuilds #40933

Merged
merged 2 commits into from May 23, 2018

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented May 22, 2018

Motivation for this change

Most things that used to be in here could get merged straight to master (yay!). What's left is these two ugly things. Contrary to the branch name, this does not give full linux->darwin cross, as that requires #36867, but it does allow doing:

nix-build --arg crossSystem '{ config = "x86_64-apple-darwin"; }' -A buildPackages.darwin.cctools

And not waiting far too long for pointless rebuilds.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

CC @alexfmpe @ElvishJerricco

'';
postInstall = ''
cat >$out/bin/dsymutil << EOF
#!${stdenv.shell}
Copy link
Member

Choose a reason for hiding this comment

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

Is this intended to be a noop?

# think the best solution would just be to fixup linux RPATHs so we don't
# need to set `-rpath` anywhere.
# + lib.optionalString targetPlatform.isDarwin ''
# export NIX_TARGET_DONT_SET_RPATH=1
Copy link
Member

Choose a reason for hiding this comment

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

We don't really want rpaths on darwin, can we keep this for native darwin builds?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah due to the way cc-wrapper works, mapping these to the infix salt, it will also do depsTargetTarget (intended effect of NIX_TARGET_DONT_SET_RPATH) for native builds. Yay impurities!

@Ericson2314 Ericson2314 force-pushed the linux-to-darwin branch 2 times, most recently from 9a074d3 to 752fb0a Compare May 23, 2018 03:39
Ericson2314 and others added 2 commits May 23, 2018 10:06
We want `buildPackages` to be almost the same as
`buildPackages.buildPackges`, but that is only true if most packages
don't care about the target platform. The commented code however made
them all care about whether the target platform was Darwin.
Unfortunately this is a crude hack that we use the same binutils source
everywhere in the bootstrap chain.
@@ -19,10 +19,11 @@ in
stdenv.mkDerivation rec {
name = targetPrefix + basename;

src = fetchurl {
# HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM
src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is really gross. Maybe we should just builtins.fetchurl everywhere? IMO with fetchurl, builtins.fetchurl, fetchurlBoot and <nix/fetchurl.nix>, there are too many ways to fetch in nixpkgs.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's good enough for now though. At least we avoid the mass rebuild. Any improvement can be another mass rebuild.

@Ericson2314 Ericson2314 changed the title [WIP] treewide: Linux -> Darwin cross compilation treewide: Linux -> Darwin cross compilation May 23, 2018
@Ericson2314 Ericson2314 changed the title treewide: Linux -> Darwin cross compilation stdenv, binutils: Build cctools targeting macOS on Linux without pointless rebuilds May 23, 2018
@Ericson2314 Ericson2314 merged commit ee9dc37 into NixOS:staging May 23, 2018
@Ericson2314 Ericson2314 deleted the linux-to-darwin branch May 23, 2018 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants