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

cross-compilation: native derivations and stdenv.cross #14965

Closed
3 of 4 tasks
vcunat opened this issue Apr 25, 2016 · 8 comments
Closed
3 of 4 tasks

cross-compilation: native derivations and stdenv.cross #14965

vcunat opened this issue Apr 25, 2016 · 8 comments
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 9.needs: documentation
Milestone

Comments

@vcunat
Copy link
Member

vcunat commented Apr 25, 2016

The problem is closely related to #10874. We've developed a habit to test stdenv.cross to find if we're cross-compiling or not. However, that does not work for native build inputs, i.e. they see the same stdenv arguments as the cross derivations.

What's worse, I don't think this is easily fixable. We call stdenv.mkDerivation with some arguments, and inside this call we call the original and modified mkDerivation to produce nativeDrv and crossDrv. Those arguments have no possibility to differentiate among the two cases during evaluation time. We can still use crossAttrs, but that's rather inconvenient if we only want to slightly tweak a substring of a phase or drop a build input.

(Attributes like stdenv.isLinux also evaluate the same always, but the problem there is reversed, as discussed in #10874: it shows properties of the build system even though users typically mean the host system.)

TODO by @Ericson2314

vcunat added a commit to vcunat/nixpkgs that referenced this issue Apr 25, 2016
This doesn't fix the cross-build by itself due to
NixOS#14965
But in this case one can hack around that "easily" by:
  (html-tidy.override {
    inherit (/*non-cross nixpkgs eval*/)
      cmake;
  }).crossDrv
@vcunat vcunat mentioned this issue Apr 25, 2016
7 tasks
@vcunat
Copy link
Member Author

vcunat commented Apr 27, 2016

@Ericson2314: I pushed the current state of my WIP to vcunat/nixpkgs@kt/cross...vcunat:v/cross-native-rework The main idea is to use pkg.override to pass a different stdenv. That can't cover some edge cases, e.g. it will only work "below" callPackage and not in all-packages.nix, but I can't see any better way ATM.

@Ericson2314
Copy link
Member

@vcunat From just a quick glance, I think this will fit very nicely together with what I've got, which is now otherwise ready for PR testing?

@Ericson2314
Copy link
Member

So I already added a proper phase for computing the build-time deps in https://github.com/Ericson2314/nixpkgs/blob/cross/pkgs/stdenv/cross/default.nix, which means proper substitution of the stdenv. It's just a matter of combining your cross.nix with that, and things should work perfectly. I'll take a stab at it now.

@Ericson2314
Copy link
Member

Ericson2314 commented Apr 27, 2016

@Ericson2314
Copy link
Member

#21268 fixes the stdenv.cross aspect of this. Future work would is needed for stdenv.is*.

@Ericson2314
Copy link
Member

#24610 almost fixes all the rest of this. We just now need to deprecate stdenv.is* and remove stdenv.cross.

@Ericson2314
Copy link
Member

#26884 did the latter!

@Ericson2314
Copy link
Member

I think I'll keep stdenv.is*. It is now defined with the host platform, which is a sane default. #27069 tracks these sorts of things more broadly, and with more precision as the issue is postdates my overhauls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 9.needs: documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants