-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
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)
}
|
|
Not familiar with this, sorry.. @rustbot reroll |
Ah, that's right. I had mentioned that behavior before (#101300 (comment)), but I had forgotten. I think very few people actually use opt-level=0 in projects targeting embedded systems), I now agree that disabling atomics is the more preferred behavior for these targets. |
For the build you put on the board, sure. But I do a lot of debug profile builds for testing the code compiles in CI, and the default debug profile is opt-level=0. Also when it’s running unit tests QEMU I leave it in debug profile.
I don’t love it, but I think it’s the least worst solution |
|
r? @davidtwco I'll give this a read through and ask internally before getting back to you on the PR. |
|
@bors r+ |
|
@bors rollup=iffy |
Rollup of 8 pull requests Successful merges: - #145628 ([std][BTree] Fix behavior of `::append` to match documentation, `::insert`, and `::extend`) - #149241 (Fix armv4t- and armv5te- bare metal targets) - #149470 (compiletest: Prepare ignore/only conditions once in advance, without a macro) - #149507 (Mark windows-gnu* as lacking build with assertions) - #149508 (Prefer helper functions to identify MinGW targets) - #149516 (Stop adding MSYS2 to PATH) - #149525 (debuginfo/macro-stepping test: extend comments) - #149526 (Add myself (mati865) to the review rotation) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #149241 - thejpster:fix-armv4t-armv5te-bare-metal, r=davidtwco Fix armv4t- and armv5te- bare metal targets 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](https://rust-lang.zulipchat.com/#narrow/channel/242906-t-compiler.2Farm/topic/__sync_lock_test_and_set_4.20on.20Armv5TE/with/553724827) 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-32` for these two Tier 3 targets. I asked `@Lokathor` and he said he didn't even use atomics on the `armv4t-none-eabi`/`thumbv4t-none-eabi` target 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::thumb` to `spec::base::arm_none` and changes `armv4t-none-eabi`/`thumbv4t-none-eabi` and `armv5te-none-eabi`/`thumbv5te-none-eabi` to 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*` and `armv8r-none-*` as well, but that can be another PR.
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.