-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
treewide: Introduce stdenv.cc.bintools #30549
Conversation
[@peti thanks for super-quickly reviewing the other; all the GHC changes are now in this one but exactly the same.] |
562e1dd
to
1751bff
Compare
What is |
Answered in person, but I'll copy here for anyone else that's curious.
|
Poll:
|
One should do this when needed executables at build time. It is more honest and cross-friendly than refering to binutils directly.
…tils directly One should do this when needed executables at run time. It is more honest and cross-friendly than refering to binutils directly, if one neeeds the default binary tools for the target platform, rather than binutils in particular.
First, I'd like to recap the structure of cross compilation, more like I imagine that than what it realy is. (Please correct me if I'm wrong.) Then I'd comment on your proposal. To support usage of binutils and gcc with their notions of build, host and target platforms, the function that returns all packages is parametrized with these three variables. Let's mean exactly this when we say that each derivation is configured with the platform on which it should be built (PB), the platform on which it can run (PH), and the platform for which it should generate code when it runs (TP). (Certainly a derivation may in fact be independent from the value of one of these variables.) Let
The bootstrap is downloaded and unpacked using Nix primitives, so its builder does not run any programs (at least from the perspective of Nixpkgs) which makes it independent from the build platform. However, we don't trust the bootstrap compiler to build programs during the native compilation, and we won't trust it to build the build tools for the cross compilation. We will introduce another stage, and build the build tools with the native compiler:
(Note that stage 1 tools and stage 2 tools that don't depend on TP — almost everything besides To be safe, the builder of a derivation of each stage should run programs only from the previous stage and link to libraries (or save references to programs for use at the run time) only from the current stage, with a few exceptions:
We can model this pipeline in Nix with nested sets:
To make a derivation for a certain stage, we call its function with
@Ericson2314 Overall I'm in favor of option 1. If I understand the situation correctly, the overhead from using the target |
@orivej Fantastic recap. That's almost entirely exactly correct [1], in as much detail as I've seen anyone else write.
I think me too, it's better to get those run-time deps correct while we're not sure whether it matters.
That's true that if we're building stage 4 with a non-standard stdenv, we'll be rebuilding the world anyways, good point. I guess the case I was thinking is stage 3 caching: e.g. if stage 4 is has a Linux host platform, but uses clang, should we rebuild stage 3 compilers that depend on CC to (run-time) use clang instead of gcc, or can we rely on wrapper scripts etc to force them to run-time use
Hehehe. So first of all, I don't really like our notion of It doesn't belong in the previous stage because for the same reason we don't like earlier stages depending on later stages: we don't like earlier stages determining later stages. Think with a GC'd heap and immutable linked lists, many link lists could share the same tail, and the tail has no idea its any linked list's tail, as it's a full-fledged linked list in its own right. Likewise, with a bootstrapping sequence, the goal is any subsequence from 0 should be just as valid--stages 0-1 really is the native chain, in addition to being part of the 0-4 cross chain. Now yes, since we are effectively doing a doubly-linked chain with So since as you point out, it doesn't belong in the current stage, and as I point out it doesn't belong in the previous stage, my parameter-only idea is just concluding it doesn't involve in any stage! It would just exist as an "ephemeral" parameter in order to select the right derivations without having to override anything (as that's anti-modular / bad for sharing and thus expensive, depending on how one looks at it). Now again, that ignores the reality of these backwards dependencies and what-not, but that's the aspiration. tl;dr is yes we can be better, but that's out of scope of this PR :). [1]: Well, except for the tiny quibble that its |
@orivej Thanks from me too for this cc recap. The text is good candidate for an intro/motivation section on CC in the docs. |
Looks good to me. |
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.
LGTM, thanks!
The travis failure is real, but due some other PR or darwin version impurity. gtikgnutella built fine on this machine on this branch w/o merge. Thanks, for the final reviews! |
👏 🎉 |
Motivation for this change
Rather than refer to
gcc
orclang
directly, we refer tostdenv.cc
. But instead of doing the same thing for binutils, we fakebinutils
on Darwin, and exposebinutils-raw
. This introducesstdenv.cc.bintools
for consistency.Also, to be correct for cross, tools like compilers that use binutils/cctools at run time should depend on
__targetPackages.stdenv.cc.bintools
. This sort of weird, effectively referring to the same stage as the "next stage's previous stage", but I can't think of a better way.This was made from #30484, which now depends on this. It just adds the
stdenv.cc.binutils
for now. Then down the road (along with other changes),binutils-raw
can becomebinutils
without changing anything.Things done
Almost no hashes are changed by this PR.
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)CC @bgamari