-
Notifications
You must be signed in to change notification settings - Fork 14k
Fix armv4t- and armv5te- bare metal targets #149241
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: main
Are you sure you want to change the base?
Conversation
Also rationalise the settings, and copy in the thumb base defaults, rather than just import them, because these aren't M-profile microcontrollers and may not want to always have the same settings.
|
Some changes occurred in src/doc/rustc/src/platform-support cc @Noratrieb These commits modify compiler targets. |
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
This comment has been minimized.
This comment has been minimized.
bed4a73 to
dbcb048
Compare
|
If you don't want to pass Footnotes
|
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'm leaving a formal comment of approval to this general idea as the armv4t maintainer, and I'll leave the exact details of the implementation up to the rest of you.
Oh! Yes, I see now that relaxed loads do work. Do we want to support I guess we have two options:
|
|
Sorry, I must have missed your request earlier. Similar to Lokathor, I haven't been using atomics on armv5te. Either way, the docs for |
Where do we document that? |
|
https://doc.rust-lang.org/core/sync/atomic/, under the "Portability" section:
|
|
Edit: Nope. |
|
Oh, no. @taiki-e - the load/store is only lowered to a plain
#![no_std]
use core::sync::atomic;
pub static VALUE: atomic::AtomicU32 = atomic::AtomicU32::new(0);
pub fn example() -> u32 {
VALUE.load(atomic::Ordering::Relaxed)
}
pub fn example2() -> u32 {
VALUE.load(atomic::Ordering::Acquire)
}
|
These two targets currently force on the LLVM feature
+atomics-32. LLVM doesn't appear to actually be able to emit 32-bit load/store atomics for these targets despite this feature, and emits calls to a shim function called__sync_lock_test_and_set_4, which nothing in the Rust standard library supplies.See #t-compiler/arm > __sync_lock_test_and_set_4 on Armv5TE for more details.
Experimenting with clang and gcc (as logged in that zulip thread) shows that C code cannot do atomic load/stores on that architecture either (at least, not without a library call inserted).
So, the safest thing to do is probably turn off
+atomics-32for these two Tier 3 targets.I asked @Lokathor and he said he didn't even use atomics on the
armv4t-none-eabi/thumbv4t-none-eabitarget he maintains.I was unable to reach @QuinnPainter for comment for
armv5te-none-eabi/thumbv5te-none-eabi.The second commit renames the base target spec
spec::base::thumbtospec::base::arm_noneand changesarmv4t-none-eabi/thumbv4t-none-eabiandarmv5te-none-eabi/thumbv5te-none-eabito use it. This harmonises the frame-pointer and linker options across the bare-metal Arm EABI and EABIHF targets.You could make an argument for harmonising
armv7a-none-*,armv7r-none*andarmv8r-none-*as well, but that can be another PR.