Sane cross-compiling through bootstrapping#21268
Sane cross-compiling through bootstrapping#21268Ericson2314 wants to merge 5 commits intoNixOS:masterfrom
Conversation
|
@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @errge, @gridaphobe, @LnL7 and @copumpkin to be potential reviewers. |
|
Hey, I'm trying out commit ab9eebbba565932ff92acbcb0a1a541119d95468 on my computer right now and it says:
|
|
@DavidEGrayson yeah almost* every *I am (for now) keeping |
|
@DavidEGrayson yes everything is broken. I'm making the WIP now to get the basic idea out there. Fixing things is tedious but fairly easy. |
|
@DavidEGrayson Working on GCC 5 now (also where did your comment go, did I delete it by accident or something?!?). How exactly do |
|
I deleted my comment. In my pull request (#18386) I introduced targetCrossSystem and hostCrossSystem variables in the GCC recipe. For a native compiler they are both null. For a cross-compiler, targetCrossSystem will be equal to crossSystem. For a cross-built native compiler, targetCrossSystem and hostCrossSystem will both be equal to crossSystem. There is no support for other combinations yet. |
|
Thanks! that helps a lot |
|
Hey, I don't know if your pull request does this yet, but the |
|
@DavidEGrayson I think I am doing that? IIRC the idea is if you traverse enough build-time deps from a crossDrv, one gets back to "build = host = target" (or target doesn't matter) first, and those should be overridden just like when not cross compiling and that's the top bootstrap stage. |
|
On interesting complication is currently we like to build libc in the same faux-stage as gcc/clang. But that's wrong as its a runtime dep. Just as we have |
|
libc is a build-time dependency because the gcc/clang compiler needs to know where it is so it can compile programs without the user having to specify a libc. I don't understand what is wrong. |
|
@DavidEGrayson so I'm trying to to make "build time dep" ==> "drawn from stage n-1", but naively doign what you say with libc creates a gaping exception because libc must be built for the cross platform. I could have an additional bootstrapping stage for Similarly, while many packages can meaningfully be built with differently-booted regular compilers, packages either do or don't need libc, so if I did crate another bootstrapping stage it ought to be a completely disjoint set of packages---just those which don't need libc. Again, sort of weird. Finally, I think it's kind of a smell that libc needs to be treated differently than other libraries---in Rust myself and others have been working to try to make the rust standard library built and used as normally as possible. I'd love to ditch the wrapper script and just make libc a default |
|
I don't understand how the n-1 thing is a good principle; it seems like it would cause you to rebuild some dependencies unnecessarily (e.g. having a zlib at stage k and another one at k+1). My earlier comment is an example where you want to have several dependencies that come from stage n-2. And if we're talking about a normal library and normal program they both would come from the same (final) stage. Also, libc needs to be special because it is part of stdenv. |
3f3203a to
6eb71f5
Compare
|
Ok, I scaled things back leaving the actual |
19e5bc5 to
c29e7ec
Compare
|
OK this is ready to be reviewed! I haven't tested cross-compiling as much---it ought to have a much better foundation than before, but not necessarily be less broken. I have however tested that linux hashes are unchanged and the travis script passes locally. Once this is reviewed and merged, I'll do the big |
c29e7ec to
1b98554
Compare
This effectively reverts commit d27403b.
For the wrapper script changes, see the big comment at the top of `pkgs/top-level/build-wrappers.nix`, which explains that file's motivation. Most of the churn in this commit is because those wrappers are now only available in `buildPackages`. As to the removal of the `*Cross` derivations, the basic idea is further utilizing proper bootstrapping stages. We can simply always pass `crossSystem` or `stdenv.cross or null` and rely on those expressions being null for native packages. Furthermore, we have enough bootstrapping stages so that every variant of a package we need can be found in some current or previous stage. Essentially, the `*Cross` derivations were a poor attempt at squashing multiple stages together. gccCross* alone among the *Cross derivations remains for now to be dealt with in a later commit. Also, the unwrapped GCCs should not be passed a libc even when cross compiling. That too remains to be dealt with.
…iling Previously, all overrides from the final native stage were chucked. This is sound but caused unnecessary rebuilds. It would be tempting to just keep all overrides, but then pkgs like gcc and binutils would not target the correct platform--they would still target the (native) build platform. Now, each native final stage responsibly just overrides such packages of the target platform is that used to build the overriding packages.
5bd3168 to
e63cd62
Compare
|
Heads up, in https://github.com/obsidiansystems/nixpkgs/tree/ghc-android I have a huge number of hash-breaking, but tested improvements. The git history is unclean however. I'm thinking I clean that up and combine it with the few parts of this I haven't already incorporated into this. After that, I can make a staging which will really clean things up. This will be big, but actually quite simple mainly making most |
|
@Ericson2314 what should happen with this PR? It hasn't been touched in a long while, and it for sure won't make 19.03. |
|
@FRidh I've basically been keeping it open as a TODO to triage everything in it has either been done or shouldn't be done. Removed the milestone. |
| # catch improperly *using* wrappers from `pkgs` instead of `buildPackages`. | ||
| buildWrappers = self: super: | ||
| if targetPackages == {} | ||
| then {}; |
| else if name == "libSystem" then darwin.xcode | ||
| else throw "Unknown libc"; | ||
| libc = | ||
| if crossSystem != null |
There was a problem hiding this comment.
We shouldn't need crossSystem here. Why not just use stdenv.hostPlatform.libc? libc should come from pkgsTargetTarget right?
|
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
|
Everything in here I think is done or won't be done. In particular the "wrappers in next stage" idea isn't being done---better to just keep on using |
Ok, this is it, my final and biggest top-level refactor for 2016!
I've factored things into separate PRs, so this builds on #21415 to provide a consistent idiom for bootstrapping which I extend and further utilize for cross compiling, and #21414 which cleans up the cross-compiling tests.
It should also eventually subsume #21388, but I am still getting things unbroken.
This isn't ready to merge (need to unbreak cross compiling completely) but is ready to review---only uninteresting bug fixes should be left.
OP
The first commit introduces a new abstraction for dealing with stdenv bootstrapping. It doesn't really make anything shorter, but at least it enforces a consistent ideom across all of them. This commit works, but I'd love advice on how to make linux and darwin better utilize it. @copumpkin I'm especially curious about your feedback, and whether this will help with your goal of automatically solving for bootstrapping stages (I hope it will! but not sure).
The second commit is just the bare-bones of what I want cross-compiling to look like. The big ideas are
*Crosspackages and other hacks: "native dependencies" are actually stage n-1 dependencieshostandtargetin the autotools sense.I'll probably end up splitting this into two PRs to get the first part merged sooner, but wanted to include the second part for now in order to better motivate the first.
Probably closes #14965
Takes a big stab at closing #10874
I shamelessly stole things from #18386 and will steal more!
CC @DavidEGrayson @nbp @shlevy @copumpkin @vcunat