-
Notifications
You must be signed in to change notification settings - Fork 98
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
Discussion issue for customizable targets #792
Comments
I personally would like to explore an alternative approach to "one target per configuration". In RISC-V, the number of possible combinations is huge. For instance, the new ratified Zaamo and Zalrsc extensions introduce different degrees of atomic operations support. |
Do these extensions affect the ABI? If not, |
@bjorn3 there are cases where it's not required to use a new target, but cases where it's extremely useful to have core/alloc/std using the selected features as well, for example cases where instructions (or knowledge of things like additional registers) are available that can significantly improve performance for memcpy, string/byte comparisons, or other intrinsics defined in the standard library. I don't have a good answer of what extensions or target customizations are certainly ABI breaking, but I think there are reasonable uses "extremely nice to have" use cases here too. |
For those cases either an entirely new target or using |
I think that's the general thing we're discussing. For example today, I agree that the "how we impl this" is probably "change some flags and use build-std", but IMO it doesn't make sense to ONLY have this capability for ABI relevant config. In both cases, you want your application AND the stdlib to have consistent feature enablement, and it would be nice if it didn't require use of nightly/unstable features. Totally aware this would require RFCs/decisions from the compiler/libs/cargo teams, it was my intent to start that discussion in this issue, as there was at least some support for "propose what you want stabilized and we'll discuss it" from team members at RustNL. |
In the kernel, we have several places where this kind of flag would be useful. The flag that we have discussed the most is the Some other cases:
I think these all have ABI concerns if mixed, but I could be wrong. I imagine that
I could list way more flags if we include such things. Note that we don't have std in our build, so we don't use |
On riscv I believe F extension (or lack thereof) is the only extension that changes ABI. [edit] [2nd edit] |
The |
Ok, first up, I'd like to make a point of order and ask that we name the Arm architectures correctly.
Edit: I'm a microcontroller person and these are the M-Profile targets. There are obviously R-profile and A-profile targets as well. As far as I can recall:
I think it's also worth noting that 'EABI' is sort of hand waving over a bunch of Arm standards and specifications: Perhaps it would help to introduce the idea of interior target features and exterior target features. An interior feature affects only the interior of a function, and does not affect its ABI - that is, how it is called and how it returns. An exterior target feature, conversely, does affect the ABI. The only exterior feature I know of is whether the FPU is used as part of the ABI - what we call There are many interior features, which vary according to which revision of the Arm Architecture you are looking at, and which particular processor you are using (e.g. the Cortex-M7) and how it implements those features, or doesn't, or optionally implements them depending on how the silicon vendor chooses to implement that Arm IP in their SoC. I have tried to outline all of these, and their corresponding I agree with notes above that many of these interior features are related to performance, and it is advantageous to have libcore pre-compiled with them - but only because we don't let users (easily) compile the standard library from source. In particular, it's likely that M-Profile Vector Extensions (MVE, aka Helium) would be pretty useful for some of the Unicode text handling functions. I final point I want to make is that currently |
A good source for what GCC supports on bare-metal Arm is: https://wiki.segger.com/GCC_floating-point_options Also interesting to see what Arm's own compiler does: https://developer.arm.com/documentation/dui0741/f/Overview-of-the-ARM-Compiler-6-Toolchain/ARM-architectures-supported-by-the-toolchain?lang=en They seem to have a single |
I was under the impression that this was the appropriate way to locally override your CPU variant. For instance, I used If the concern is getting |
@cr1901 there are some cases where target features could potentially change the ABI (mentioned above). These are the cases where it would not just work, as compared to just "missing optimization from core/alloc/std components". |
Noting that this was discussed in the meeting today, chat logs here: https://libera.irclog.whitequark.org/rust-embedded/2024-09-03#1725387483-1725389567; Also CC rust-lang/rust#129893, which is what kicked this whole discussion off today. |
As discussed in: https://lore.kernel.org/linux-mips/CANiq72mvTTgyTjDCWBz_kOdY1f4gopAtWxyC4P4c+Lr0YVkzLA@mail.gmail.com/ MIPS also needs such facility: Options are:
Each of these needs a soft float and hard float target. We probably needs triples for microMIPS as well. |
Being able to have all of |
Up to now, we've handled targets with differing capabilities and ABI details by defining separate targets, such as
thumbv7m-none-eabi
andthumbv7em-none-eabihf
. For Arm v6m and v7m targets (Cortex-M0 to Cortex-M7), this has worked okay, as the number of options is relatively low.However, newer v8m targets, as well as architectures like RISC-V, have a much larger volume of potential options.
It is often necessary (or strongly preferrable) for targets to have consistent compilation options for
core
/alloc
/std
and the main application, either for ABI reasons (e.g. not mixing hard and soft float ABIs), or for performance reasons (more efficient intrinsics for bit operations, memcpy, etc.)At RustNL, it was informally discussed whether we could explore options outside of "one target per configuration", including potentially using
build-std
to recompile the standard library to match selected features for "customizable" targets.On a Zulip thread regarding ABI-relevant flags, it was also discussed that Rust for Linux may also have uses where the Kernel can be configured with options that affect the ABI (and necessitate building a consistent standard library), such as
-Zfixed-x18
.It is not clear yet exactly how this would be specified, what guarantees would be given for stability, etc. This discussion issue is aimed at:
rustc
orcargo
to enable these options.It's likely this will need to be discussed with a wider group of Rust teams, but I wanted to start a tracking/discussion issue for now as it has become relevant.
The text was updated successfully, but these errors were encountered: