-
-
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
Add CPU model support to target platform #313539
Conversation
d22bb42
to
aa8c6a6
Compare
This seems close to https://github.com/NixOS/nixpkgs/blob/master/lib/systems/architectures.nix ? My thought at the time with that is that I don't really know what the difference between an instruction set architecture and a "sub instruction set architecture", except for rather arbitrary conventions about what goes in the target triple or not, which I view as sort of historical accident we shouldn't take too seriously. |
Yeah, though this mechanism is simpler. I'm not sure how that method works in Nixpkgs but this way you just add your CPU model to the end of config. It also allows for easy checking of common CPU models so marking certain packages as broken can be simpler. Adding this into the config stuff also allows for easy cross compiling via |
aa8c6a6
to
0aedb14
Compare
0aedb14
to
e91bfbc
Compare
befa041
to
34cad61
Compare
Idk what is up with |
45eb99b
to
f04dc9f
Compare
Just cleaned up the commits, fixed some of the issues found with CI. Made it so this doesn't rebuild everything if the CPU model is generic. I think this is at a state that I am happy. |
@ofborg build pkgsCross.asahi-m1.bash |
Does this allow us to get rid of architectures.nix? It's really annoying to have to extend that list with boilerplate when adding new architectures. |
@@ -634,6 +634,12 @@ stdenvNoCC.mkDerivation { | |||
+ optionalString ((targetPlatform ? gcc.cpu) && (isClang || !(targetPlatform.isDarwin && targetPlatform.isAarch64))) '' | |||
echo "-mcpu=${targetPlatform.gcc.cpu}" >> $out/nix-support/cc-cflags-before |
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.
Also does this replace this mechanism for specifying the CPU?
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.
Yes it should replace it too, ideally.
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.
Yes, I just didn't strip out the way things are done with gcc.tune
and gcc.cpu
because I didn't want to break too much. My initial goal was to just get this mechanism to work.
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.
Unlike getting rid of architecture.nix
, I am fine saving this for a follow-up PR :).
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.
Yeah, that was my plan. Maybe add a couple warnings that the file is up for removal so that we can give people a buffer
Yeah bottom line is I want a unified way of doing things. If we are doing this, then I think it's a hard requirement that is replaces |
Yes. This is a simpler alternative so we probably could deprecate it and remove it. This method only requires a couple lines to be changed and models which aren't added to the list could just have all the info specified as an attribute set instead of a string. |
f5ec368
to
5f232ec
Compare
5f232ec
to
7471dc4
Compare
lib/systems/default.nix
Outdated
@@ -25,7 +25,24 @@ let | |||
inspect = import ./inspect.nix { inherit lib; }; | |||
platforms = import ./platforms.nix { inherit lib; }; | |||
examples = import ./examples.nix { inherit lib; }; | |||
architectures = import ./architectures.nix { inherit lib; }; | |||
|
|||
architectures = throw "lib.systems.architectures was deprecated and replaced via the new cpuModel attribute"; |
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.
Deprecated has a specific meaning of "still works but we will remove in the future".
By using a throw, it no longer works.
architectures = throw "lib.systems.architectures was deprecated and replaced via the new cpuModel attribute"; | |
architectures = throw "architectures was replaced by `cpuModel` attribute"; |
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.
Alright, changed.
d567c24
to
5ac21f8
Compare
5ac21f8
to
2a5740b
Compare
2a5740b
to
ab65087
Compare
ab65087
to
ec06117
Compare
Implements the "cpuModel" attribute into system and pass it into the CC wrapper. This is meant as a multi-tool alternative to "gcc.cpu".
ec06117
to
1874d07
Compare
Closing in favor of #376197 |
Description of changes
Adds a
cpuModel
attribute totargetPlatform
and defaults the CPU model to"generic"
. Might need a lot of work but I think this is a great start. We might want to check the CPU model based on the CPU arch coming in and have a fallback of only"generic"
when we cannot match a recognized CPU arch.Fixes #313530
Things done
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.