-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
lib.systems: add various has* flags useful for embedded systems #352629
base: staging
Are you sure you want to change the base?
Conversation
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.
Should target staging
This requires two main changes: - An update to the nixpkgs patch. It is now based on this draft PR: NixOS/nixpkgs#352629 - An update to the Lean runtime, as Lean is updated to v4.10.0. The changes come from Lean commit 0a1a855ba80e51515570439f3d73d3d9414ac053.
Thank you both for the feedback. Before continuing with this, I would like some feedback from someone on the high level concept first. (E.g. the concept is fine, and we don't need to rethink and use some other approach.) If it's confirmed that this is desirable change, I can update the PR to a non-draft quality one. (Split the two linunwind cases, fix the typos, fix the formatting, rebase onto latest master.) |
I think the concept is fine. To convince more people I would suggest showing a use for each new condition. |
4729f93
to
e76ac5d
Compare
Updated, the major new change is that I now have two separate If someone is interested in somewhat of a "real world" use-case for this code, here is my example which originally motivated these changes: https://github.com/kuruczgy/lean-esp32/blob/c912a815d079cd5a3d029771c247e692f5516b71/flake.nix Notably, targeting embedded platforms using nixpkgs is still very rough, so I expect several more changes to be needed, for example support for picolibc or some saner defaults for the hardening flags (currently a lot of them can blow up code size). |
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 lot of these are policy decisions rather than facts about platforms — "You often don't want…", "is probably a rare edge-case" etc. I don't think that belongs in lib/systems — it would make more sense as a Nixpkgs config option maybe. A default for that based on the system being built for would probably be fine.
The ones that are actual platform facts, like hasSystemLibunwind
are fine.
You mean something like this? import nixpkgs {
localSystem = "x86_64-linux";
crossSystem = "riscv32-none-elf";
config = {
hasExceptions = false;
hasFilesystem = false;
...
};
} I don't quite follow, how would nixpkgs know which of the two systems (build or host) the config options apply to? Also tbh. most of these options are determined by the libc, which is part of the platform. (E.g. you want |
Hmm, yeah — maybe they should be properties of the platform that you can pass in when you instantiate Nixpkgs, like some of the other attributes here, and have a name that suggests it's a policy decision rather than a platform fact, like "enableLocalization" instead of "hasLocalization"?
That makes sense, although here you're not checking libc. Maybe that would be better? |
Yes, I would be fine renaming all of them (except for maybe the stack unwinding options) to
I don't think we have much infrastructure yet for configuring/querying facts about the libc. Even just using a different libc is non-trivial. (E.g. to use picolibc I have to set The ideal solution might be something like the linux configuration system we have so we can assert/query facts about the libc, but I feel like we are quite far away from that. |
Using e.g. musl on Linux is pretty trivial today.
Sounds like it should be added to the list then? Anyway, we certainly have the libc information in the platforms, so these checks could definitely use that. |
My issue is that one libc can be configured in many different ways. Just because you know that you have "picolibc" or "newlib" you don't know exactly what it supports. For example, in picolibc you can configure at compile time whether you want locale support: https://github.com/picolibc/picolibc/blob/e3a4f137d85c5e902ef0efb7917790518764596e/doc/build.md#internationalization-options If you turn this off, you also have to set Note that in embedded contexts "aggressively disable support for anything you aren't using" is probably a more common behavior due to the much stricter code size limits. (Whereas on desktops you probably don't care about an extra few MB of code size and usually just enable everything someone might need.) Another example is clocks. ( Now picolibc does not provide Also note that in theory it's not always necessary for all this to be decided at libc/libcxx compile time. For example, if you enable This deferred symbol resolution method could maybe work for some cases (e.g. clock and filesystem) and then we could enable these unconditionally and expect the linker to just throw the code out if it's not being used. (But not for some others, e.g. locales probably incur extra code size on printf which the linker can't just remove.) Also note that this is still somewhat theoretical, as I noted above in practice there are still some kinks. |
This requires two main changes: - An update to the nixpkgs patch. It is now based on this draft PR: NixOS/nixpkgs#352629 - An update to the Lean runtime, as Lean is updated to v4.10.0. The changes come from Lean commit 0a1a855ba80e51515570439f3d73d3d9414ac053.
Right — if these are actual properties of the libc, it's fine to have them here. |
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.