Skip to content

Commit b4bdc80

Browse files
committed
Auto merge of #114499 - taiki-e:riscv-forced-atomics, r=Amanieu
Pass +forced-atomics feature for riscv32{i,im,imc}-unknown-none-elf As said in #98333 (comment), `forced-atomics` target feature is also needed to enable atomic load/store on these targets (otherwise, libcalls are generated): https://godbolt.org/z/433qeG7vd ~~This PR is currently marked as a draft because:~~ - ~~`forced-atomics` target feature is currently broken (#114153 EDIT: Fixed - ~~`forced-atomics` target feature has been added in LLVM 16 (llvm/llvm-project@f5ed0cb), but the current minimum LLVM version [is 15](https://github.com/rust-lang/rust/blob/90f0b24ad3e7fc0dc0e419c9da30d74629cd5736/src/bootstrap/llvm.rs#L557). In LLVM 15, the atomic load/store of these targets generates libcalls anyway.~~ EDIT: LLVM 15 has been dropped Depending on the policy on the minimum LLVM version for these targets, this may be blocked until the minimum LLVM version is increased to 16. r? `@Amanieu`
2 parents abe34e9 + b25fa9a commit b4bdc80

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ pub fn target() -> Target {
1111
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1212
linker: Some("rust-lld".into()),
1313
cpu: "generic-rv32".into(),
14-
max_atomic_width: Some(0),
14+
max_atomic_width: Some(32),
1515
atomic_cas: false,
16+
features: "+forced-atomics".into(),
1617
panic_strategy: PanicStrategy::Abort,
1718
relocation_model: RelocModel::Static,
1819
emit_debug_gdb_scripts: false,

compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub fn target() -> Target {
1111
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1212
linker: Some("rust-lld".into()),
1313
cpu: "generic-rv32".into(),
14-
max_atomic_width: Some(0),
14+
max_atomic_width: Some(32),
1515
atomic_cas: false,
16-
features: "+m".into(),
16+
features: "+m,+forced-atomics".into(),
1717
panic_strategy: PanicStrategy::Abort,
1818
relocation_model: RelocModel::Static,
1919
emit_debug_gdb_scripts: false,

compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub fn target() -> Target {
1111
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1212
linker: Some("rust-lld".into()),
1313
cpu: "generic-rv32".into(),
14-
max_atomic_width: Some(0),
14+
max_atomic_width: Some(32),
1515
atomic_cas: false,
16-
features: "+m,+c".into(),
16+
features: "+m,+c,+forced-atomics".into(),
1717
panic_strategy: PanicStrategy::Abort,
1818
relocation_model: RelocModel::Static,
1919
emit_debug_gdb_scripts: false,

0 commit comments

Comments
 (0)