-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
buildPackages should not know about the top-level targetPlatform #35543
Comments
Erm, generally the check for "is cross-compiling" is `hostPlatform != buildPlatform'. The Nixpkgs manual helps explain these, although even so they're a bit hard to follow 😇. However, from the manual,
So, for building perl that runs on RISC-V (host=riscv, build=x86_64), nativeBuildInputs will give you packages that are: So the fact that What is surprising is that
Actually, would Anyway I think this is clearly a source of confusion and we should try to sort this out. Hopefully @Ericson2314 will be by soon :). |
Hi @shlevy. @dtzWill has it it right. Cross compilation adds not one but two extra stages: https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/cross/default.nix, giving us in total
You've a few times told me that I'm too trepid about extra rebuilds, but maybe this a good reason why :). By making as few packages as possible know about the target platform, I make stage 3 very small. (Vanilla final stage, crucially, is its own
Yeah it should work; if it doesn't that's a bug. One needs the |
In my testing (before the patch for |
Elaborating on what I said above, this is actually not a hack.
|
@dtzWill sounds like it is working, then? |
OK, this makes a lot more sense now. I've also been reading from the 17.09 manual, not the unstable manual, which made things even more confusing 😀 So yes, things are all working as expected and this is fine. A few things that I think might be better than the status quo:
Proposal: |
Mmmm there is some symmetry / other logic in the existing names I want to lay out first before thinking about improvements:
|
It's "packages that run on your target. |
Agreed, I hate splicing. I just didn't know an easier way to be backwards compatible. But also, to be clear, we still need to distinguish the inputs for reasons other than splicing, namely env hooks and similar deps-processing-other-deps stuff. The only good thing about splicing besides back compat is it makes it sorta avoids using the wrong package set for the wrong dep since its (lamely) automatic. |
Ah so this would be like |
To be clear, |
These seem like pathological cases to me. Can you show real examples? I'm fine with keeping support for them under the hood just in case, but it seems odd to change the normal interface based on their theoretical possibility. So, in my nomenclature,
I disagree that the old semantics was
Yes, but I still maintain the terminology is confusing. When you say "your target" in this context, I think "the place this build will run", not "the place the things this build will build will run".
I'm talking about working toward the future now. I think the system you've built so far has validated itself beyond imagination, you've literally revolutionized cross-compilation IMO. Now let's make a transition path and clean up.
No, this seems more complicated than it needs to be. Someday in the future I'd like Nix to be able to do things like "satisfy this input with either a native or cross-compiled variant of this package, whichever is easier for you", and in that hypothetical world this might make sense, but I agree on choosing a default.
I just disagree that this is the right one. |
Btw I used to |
|
Err I dunno about guile, but to build a |
I agree the autoconf names suck. I kept them because the the concept of a "target platform" also sucks, and I wanted to use just one name for this lousy concept. I guess what I'm getting at is lets figure out if the naming scheme you want is isomorphic to what we have and then bikeshed the exact identifiers :). |
Thanks :). May the revolution continue then! The plan I originally had was change GCC, GHC, and other libraries so
|
Btw, |
I'll grant you since I only use |
IMO these are all "internal" cases that justify knowing more about the system. They don't really seem like things most people making their packages cross-compilable should think about. But yes, these are real, and these systems are horrifying 😀
The stdenv.cc case is an implementation detail, it could just as well work by making it a defaultCrossBuildInput. I'm not sure what you mean by "use a tool the normal way".
Sorry, I was treating my baseline as the normal non-cross set. What I meant is, Putting it another way: As a maintainer of packages I want to cross-build, empirically speaking the vast majority of the time I want to think about |
Ok so I talked to @shlevy a bit on IRC, and here is me-written and perhaps jointly-editted (woo super perms!) summary:
|
Thanks for this summary! I think there are two action items here:
Thoughts? Do you have a clear vision for 1? I can take a look at 2. |
I definitely think we should use the |
That sounds good. I have a clear vision for 1, and some WIP work for Haskell you may be interested. I'd also like to brainstorm about how to do |
@Ericson2314 Can you outline your vision somewhere so we can start looking at 2 in parallel? |
For 1:
|
@Ericson2314 Why do we need 4 if we're going to a new interface? |
@shlevy Internally I've largely done the long-term implementation. 4 is sort of an anti-revert; I first rewrote stdenv/setup how it ought to be, more or less, and then added in some native-only hacks to avoid widespread breakage. 4 removes the stop gap hacks, bringing us closer to the ideal design. Also important to know is the type of hacks in that commit I did can't readily be done with a legacy desugaring on top. If we rip the bandaid off I think we also need to fix a bunch of packages. |
@Ericson2314 Can't the legacy wrapper just have a phase where it sets PATH etc.? |
@shlevy Sure (though nix-shell would annoy people). But deciding what deps go on the PATH seems like an orthogonal question to when the PATH is built? |
Right, but I mean the legacy wrapper can add extra things to PATH on top of what the core thing does. So we don't need to break things on the old setup. |
@shlevy Well as I said above, I am a bit skeptical of being able to desugar. The PATH part is easy, for sure. The env hooks though.... I dunno. Not always sure if env hooks are effectively ideompotent if we end up running them on deps twice. |
Ah, OK. |
I've only seen the breakage in conjunction with other WIP cross stuff. Maybe if we set up a hydra job with just the rebuild it would be less bad than I fear. At the very least, it would be interesting to open a hydra job and then reevaluate the situation. |
Currently when cross-compiling, the
buildPackages
set sees the top-leveltargetPlatform
and thus cross-compiling-aware toolchain components are built to targettargetPlatform
instead ofbuildPlatform
. To get access to abuildPlatform
-targeted version of the tool, you need to accessbuildPackages.buildPackages
or, in the special case of cc, we have a hack to makebuildPackages.stdenv.cc
do the right thing.Also, anything that checks
targetPlatform != buildPlatform
(which is now aliased tostdenv.isCross
) will get the wrong answer insidebuildPackages
.Semantically, it seems like
buildPackages
should be exactly the same package set you'd get if you weren't cross-compiling at all. Ideally we'd live in a world where all tools were like clang and didn't need specific advance target awareness, but for tools that do isn't this exactly whattargetPackages
is for? That is, shouldn't I take my build-native compiler frombuildPackages
, my cross-compiler fromtargetPackages
, and my cross-compiled target-native compiler fromhostPackages
?As an aside, those names are really unclear even though they are conventional. I'd expect
targetPackages
to be "packages that run on the target" and something likecrossPackages
to be the source of cross-compiling tools.The text was updated successfully, but these errors were encountered: