-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 OS type "none" to platforms. #7560
Conversation
Will every rust toolchain that targets bare metal/no OS devices be functionally identical, or will each individual target device need a separate toolchain? I'd prefer to see projects defining their own constraint values and platforms for this to denote their own individual needs, rather than trying to add everything to a single "no-os" constraint value. So, as example, if I am following https://os.phil-opp.com/ and trying to adapt it for Bazel (I have tried!), I would want to define my own platforms:
And then I can set up my cross-compiling toolchains to also use this target constraint. |
For development on bare metal (and even when something like FreeRTOS is used) a toolchain for the I think that if you would want to build your So while I do agree that we would want people that build applications for their own OS to define their own platform, I think that we can add a built-in |
This makes sense for platforms, but I'm not clear what will happen when we add values to the OS enum. Adding @jmmv to see if he has any ideas what else would need to be updated. |
I find it quite confusing that the I am also confused about "none". I think you want to say that binaries built against the real hardware have no OS underneath, hence this value, right? In that case, maybe "standalone" would make more sense? |
@jmmv: We defined constraints matching the OS enum values because those are the OSes that Bazel supports. There's no real need to go the other way, however: every constraint value for |
Toolchains for C, C++ and Rust usually denote the no OS platform as |
@katre so if I understand you correctly this PR would not need to include the change to |
Yes, I think that's correct: adding the enum value has no effect, since nothing will ever set it anyway. |
The latest commit reverses the addition of the |
This seems fine to me now (not modifying I'd probably extend the commit message to describe why |
The `none` os constraint value remains as a standard platform. While names such as 'freestanding' or 'standalone' have been proposed, the name remains 'none' to be consistent with the naming of targets triples such as 'arm-none-eabi' that will satisfy this constaint.
c5b38cf
to
8132e00
Compare
The visibility of the "os" constraint setting is public, so you should be able to add the new ":none" constraint_values in your own project. If Bazel isn't using these, and the default cc toolchains aren't creating cc_toolchains for them, are they needed in Bazel core? |
The current design of |
Why does rules_rust require the constraint to be present in the core Bazel repo? I would expect the following to work (once cc rules use toolchain resolution, which is in progress, see #7260):
Then invoke something like:
This allows Bazel to know that
None of this needs to be defined in either Bazel core, or even in rules_rust, just in the project of whoever is configuring the compilers for the no-os compilation. |
@katre the thing is that |
After some discussion and thinking I agree with @katre that bazel core is indeed not the right place to add this. I'm closing this PR and looking into how we can adapt |
This pull request introduces the OS type "none" used in target triples for bare metal/embedded devices, so things like
rules_rust
can target freestanding hardware 😄.