-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Add *Platform.is*
predicates and alias stdenv.is*
to hostPlatform
's
#25976
Conversation
Looks like probably the right thing. My big concern is that in a lot of places where I've used Another case that happens a lot is when you have inputs like |
I wonder if it's worth to avoid the mass replace for now, assigning the |
else if stdenv.isGlibc then glibcIconv stdenv.cc.libc | ||
else if stdenv.isDarwin then darwin.libiconv | ||
# GNU libc provides libiconv so systems with glibc don't need to build | ||
# libiconv separately. Additionally, Apple forked/repackaged libiconv so we |
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.
Glibc also lets you leave out -liconv
altogether leading to special cases like here:
NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-liconv"; |
Perhaps we can always have ```-liconv```` added to NIX_LDFLAGS in the hostPlatform.isDarwin case? Not sure how to do that though, probably a setup hook.
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.
Hmm a few things
-
The newish
glibcIconv
is just some copped headers, so it's safe and simplest to depend on libiconv unconditionally. -
As far as
-l
goes it reminds me of needing to link pthread or not. Maybe something to be done for both. Alternatively, maybeglibcIconv
can include a dummy static lib or something, so we can unconditionally link it. -
This PR preserves the existing native behavior, so it would be best to do setup hooks in a follow-up PR.
then libcCross | ||
else stdenv.cc.libc) | ||
else if hostPlatform.isDarwin | ||
then darwin.libiconv |
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.
I guess this check has been here for a while but if you want to do mass changes to Nixpkgs, it might be useful to get rid of the ++ stdenv.lib.optional stdenv.isDarwin libiconv
since this logic should handle it correctly. I can make a PR for it if that makes sense to you. Here's a list of some:
https://github.com/NixOS/nixpkgs/search?utf8=✓&q=stdenv.isdarwin+libiconv&type=
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.
A very similar case to this is libintlOrEmpty
where on glibc gettext/libintl is included but everywhere else it isn't. I really dislike the OrEmpty
part, maybe we should give it the same treatment as this? See:
I am now noticing that here are no references to |
@vcunat I do think it's important to change it cause most ideoms spread via immitation, but let's save that for a follow-up PR—this one has some interesting things I wouldn't want lost in the noise of the sed anyways, while that can be big and boring. |
stdenv.is*
platform predicates*Platform.is*
predicates and alias stdenv.is*
to hostPlatform
's
@matthewbauer I believe you mean build and host platforms. If they both need to be darwin--in your example is it because impurities?---then requiring |
`hostPlatform.isDarwin` instead of `lib.system.parse.isDarwin hostPlatform.parsed`
This is especially useful when not cross compiling. It means we can remove the `stdenv.isGlibc` predicate too. Additionally, use this to simplify the logic to choose the appropriate libiconv derivation.
This is a saner default until stdenv's are removed altogether
*Platform.is*
predicates and alias stdenv.is*
to hostPlatform
's*Platform.is*
predicates and alias stdenv.is*
to hostPlatform
's
Ok I think it's good for now. libiconv stuff and actual |
I think this is ready to merge? |
Hmm so hah this will still be the build platform with cross, but at least the predicates are being defined less redundantly. I think doing the sed in the follow-up commit will be easier than fixing that here. |
Sorry to not wait for confirmation on the merge, but I want some other follow-up stuff to be unblocked by this. Since |
As long as there is no breakage, I say go for it. There are so few people in Nix community focussing on cross-compilation, I guess you are the one to confirm whether to merge :-) |
@bjornfor that's sort of where I've arrived at, but better to hear it from others :). Thanks. |
@Ericson2314 Is there a good writeup on the |
One more thing: maybe you can send an email to the mailing list explaining what's going on? There's probably a lot of PRs in the works with |
@matthewbauer: build/host/target is a GNU thing (autotools, binutils, gcc). |
...and a general cross-compilation thing. |
Okay, forgive my ignorance on this. For those out of the loop here's from the GCC manual:
|
@Ericson2314: Are you exposing the full GNU build/host/target semantics to be used in package files? Or the simpler host/target variant? (Sorry, I haven't quite caught up with your changes, and the nixpkgs stdenv code has always been very confusing to me.) |
@bjornfor Yes I am fully exposing them in all their glory to the terror and confusion of everyone :). I wrote some documentation of my own within http://nixos.org/nixpkgs/manual/#chap-cross which I hope is a bit more honest about the confusion and gotchas than GCC's or Autoconf's. More generally with that doc, I want to have three sections basically corresponding to "how to package supporting cross" "how to build for cross" and "how does it work". The last would hopefully answer the bootstrapping questions...but I have yet to write it yet (in part because I am not yet happy done with it, e.g. #26004). I bet in part what you're wondering is answered by the middle section: while packages see all three, nixpkgs itself is configured with just 2, taking care to define build host and target properly behind the scenes. @matthewbauer Yes, a mailing list post on all this stuff is vastly overdue. I've been sort of punting on that cause...more emails :). Certainly a breaking change like |
For now, I make sure to tag everything with https://github.com/NixOS/nixpkgs/labels/6.topic%3A%20cross-compilation so people can follow that. Next up is #26007 |
Motivation for this change
As discussed in #14965, The old notation is vague on which platform is being inspected. Worse, users probably mean the host platform, but in fact are inspecting the build platform.
This PR doesn't actually replace the old notation, but sets everything up so a simple/stupid replace can be done as a follow-up:
*Platform.is*
shorthand is now definedstdenv.is*
is just taken fromhostPlatform.is*
Also infer
{build,host,target}.libc
, which is a first step for the ideas in #6221CC @vcunat @copumpkin
[@kmicklas Your branch we paired on the other day should be rebased on this one, once it's merged. (Otherwise will be lots of merge conflicts.)]
Things done
No hashes should be changed; need to check that.I assume cause travis completed there was no-mass rebuild.