Skip to content

Commit fff8ae1

Browse files
authored
Rollup merge of #66548 - lenary:riscv/disable-atomics-non-a, r=alexcrichton
[RISCV] Disable Atomics on all Non-A RISC-V targets In a `TargetOptions` configuration, `max_atomic_width: None` causes `max_atomic_width()` to return `Some(target_pointer_width)`. So, contrary to assumptions, `max_atomic_width: None` means you do have atomic support! RISC-V's rv32i and rv32imc do not have architectural support for atomic memory accesses of any size, because they do not include the `A` architecture extension. This means the values in the target definition should be `Some(0)`. This bug has been observed via a build failure with oreboot/oreboot#191, where LLVM was still generating libcalls for atomic operations. According to rust-lang/compiler-builtins, "Rust only exposes atomic types on platforms that support them, and therefore does not need to fall back to software implementations." - so this PR tries to bring rustc inline with this decision. This commit also removes the outdated bug link, which references a now irrelevant GCC bug. I will likely also have to revisit the `min_atomic_width` of all the RISC-V targets so they are correct and match what the hardware is capable of (which is more restricted than one might imagine). r? @alexcrichton
2 parents 4997604 + ca42c25 commit fff8ae1

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/librustc_target/spec/riscv32i_unknown_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn target() -> TargetResult {
1717
options: TargetOptions {
1818
linker: Some("rust-lld".to_string()),
1919
cpu: "generic-rv32".to_string(),
20-
max_atomic_width: None,
20+
max_atomic_width: Some(0),
2121
atomic_cas: false,
2222
features: String::new(),
2323
executables: true,

src/librustc_target/spec/riscv32imc_unknown_none_elf.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ pub fn target() -> TargetResult {
1717
options: TargetOptions {
1818
linker: Some("rust-lld".to_string()),
1919
cpu: "generic-rv32".to_string(),
20-
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86005
21-
max_atomic_width: None, //Some(32),
20+
max_atomic_width: Some(0),
2221
atomic_cas: false,
2322
features: "+m,+c".to_string(),
2423
executables: true,

0 commit comments

Comments
 (0)