-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
pkgs/top-level/all-packages.nix: add cc & ccChooser #409851
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
base: master
Are you sure you want to change the base?
Conversation
316a0bb
to
3e8311b
Compare
Shouldn’t something like |
I'm not sure what you mean. |
I'm very skeptical of anything with "cross" in the name. I would need to read more, but that feels to me like a similar problem as variants. |
The difference with this is it is only the stdenv, there's a lot of packages (like Steam) which need some sort of cross environment to invoke. I'm currently working on the machinery for |
3e8311b
to
aa68505
Compare
aa68505
to
6844021
Compare
Cross is no longer in the name, this is now adding |
8d0fe78
to
2258f1b
Compare
2258f1b
to
52ac439
Compare
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.
Oh I realized we shouldn't do this as is, because cc
has the wrong host/target platform cross wise to be a tool in this package set. We should find some idiom to distinguish the tools for a package set from the packages in the package set .
What makes the host/target platforms wrong for it to be used? I see it just needing to be pulled in like |
If I see |
Ok, that's fixed. It was actually quite simple to do that. You can verify this by looking at what |
52ac439
to
5721a6f
Compare
OK now it is consistent, but we have another problem, which is that there is not supposed to be just a single next stage. We want as few things to be "target" sensitive" as possible: so it doesn't really make sense to choose We do in fact want to choose it in the next stage, but not have it be part of that stage. |
I'm not sure what you mean or how to fix that. |
https://github.com/NixOS/nixpkgs/pull/21268/files#diff-7f30042ab97e5e7b73fd0e1f2fc383f9d373f70f48e4fa52e9e348eb7db9e2fe this is not quite the same, but basically I was thinking that each bootstrapping could be not a single package set, but a pair of package sets:
The ideal goal would be for every proper package set (2) to be target-agnostic, and the only target-specific bits would be the wrappers that are in (1). At that point, we could get rid of We won't get there quite a way, so we will have to keep If we do this, I believe your idea of making more cross stdenvs boils down to making a bunch of (1) on top of the last stage without a corresponding (2). That might be possible, though building libraries without a full (2) is a challenge. As a practical matter, we might call (1) a |
5721a6f
to
8afa4cc
Compare
@@ -8227,6 +8227,43 @@ with pkgs; | |||
else | |||
null; | |||
|
|||
# We can choose: |
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.
Comment looks potentially incomplete? Or at least I don't understand what it is trying to convey beyond the rest of the code.
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.
Not incomplete, copies what libcCrossChooser
says:
nixpkgs/pkgs/top-level/all-packages.nix
Lines 8224 to 8226 in 36f6e42
# We can choose: | |
libcCrossChooser = | |
name: |
pkgs/top-level/all-packages.nix
Outdated
# NOTE: we shouldn't imply GCC, ideally we should either fallback, null, or error. | ||
pkgs.gcc or fallback; | ||
|
||
# The C compiler to use |
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.
"The C compiler to use" -- under what circumstances exactly? Is it a statement about the present or aspirational?
Do I understand that this takes precedence over what's in the standard stdenv? Does it actually do that on linux? I still see for example this (below), did it get missed?
nixpkgs/pkgs/stdenv/linux/default.nix
Line 753 in 0ef2968
cc = prevStage.gcc; |
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 will be dropping CC from the stdenv in the future so this is one of those steps. All future use of stdenv.cc
should be replaced with cc
. It is a part of the stdenv and CC wrapper redesign which has been discussed on the stdenv team Matrix.
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 understand all that prior to making my comment and have read through the plan and the matrix chat - and I'm generally in favour.
My review comment follows from my belief that ideally, the code and its comments should reflect "the present" -- how things are at the point it is merged. It is confusing if someone is trying to understand how nixpkgs is wired, and they find a comment like this, but it does not currently reflect reality.
I understand the work has to be staged, but I hold a concern that if the work gets interrupted after the merge of this, the commentary in the code remain wrong/incomplete/misleading potentially for a long time. So the commit which makes the statement in the comment true should be the one adding the comment. Before that time, the comment should try to reflect what is true 'in the present', if that can be clarified.
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.
Ok, so what should be changed 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.
I suggest either removing the comments (I don't think they're adding much as it is?) or elaborate them so that they precisely reflect the intent of the behaviour as it is currently on the master branch once this lands.
You could even include a reference to the design doc so that the intended development trajectory is clear - that would also lead to it being discoverable by those reading the sources, leading to increased collaboration/support/testing on the project.
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've updated the comment.
8afa4cc
to
2441da3
Compare
2441da3
to
7ef4495
Compare
@@ -8197,6 +8197,44 @@ with pkgs; | |||
null; | |||
|
|||
# We can choose: | |||
ccChooser = | |||
platform: pkgs: fallback: |
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.
Rename to make this more self-explanatory.
platform: pkgs: fallback: | |
targetPlatform: hostPkgs: fallback: |
pkgs.ccChooser (pkgs.stdenv.targetPlatform) pkgs null
(where pkgs is what the returned CC targets)
or
platform: pkgs: fallback: | |
hostPlatform: buildPkgs: fallback: |
pkgs.ccChooser (pkgs.stdenv.hostPlatform) pkgs.buildPackages null
(where pkgs is what the returned CC will be running on)
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.
Is all-packages.nix
really the place for this? Could there be a "Nixpkgs-specific lib
"? This function doesn't reference outside variables but takes in pkgs
so it's not really a fit for lib
.
Or don't take pkgs
as a parameter and do what libcCrossChooser
does by referencing the with pkgs;
at the top of the file.
libcCrossChooser
could be simpler, here's how I picture it:
- Currently:
hello
tobuildPackages.clang
tobuildPackages.libcCross
tobuildPackages.targetPackages.bionic
tobuildPackages.targetPackages.stdenvNoCC
- What it could be:
hello
tobuildPackages.clang
tobuildPackages.targetPackages.libc
tobuildPackages.targetPackages.bionic
tobuildPackages.targetPackages.stdenvNoCC
Can someone explain this?
Edit: I was looking at a two-month old Nixpkgs clone.. But asking on the stdenv team's Matrix channel.
Things done
Introduce
ccCross
andccCrossChooser
since #365057 will make it easier to switch elements of the toolchain out. By localizing it to a specific mechanism similar tolibcCross
andlibcCrossChooser
, it simplifies the addition of new CC's.This is necessary for working on the new
crossStdenv
s which will be added in to replace nixpkgs internally calling variants/sub nixpkgs instances.nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.