-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
Sane cross-compiling through bootstrapping #21268
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
…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 {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax
else if name == "libSystem" then darwin.xcode | ||
else throw "Unknown libc"; | ||
libc = | ||
if crossSystem != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
*Cross
packages and other hacks: "native dependencies" are actually stage n-1 dependencieshost
andtarget
in 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