Skip to content

Commit 89582e8

Browse files
committed
Pass +atomics-32 feature for thumbv6m target
https://reviews.llvm.org/D120026 changed atomics on thumbv6m to use libatomic, to ensure that atomic load/store are compatible with atomic RMW/CAS. However, Rust wants to expose only load/store without libcalls. https://reviews.llvm.org/D130480 added support for this behind the +atomics-32 target feature, so enable that feature.
1 parent 9d97606 commit 89582e8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: compiler/rustc_codegen_llvm/src/llvm_util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
440440
.features
441441
.split(',')
442442
.filter(|v| !v.is_empty() && backend_feature_name(v).is_some())
443+
// Drop +atomics-32 feature introduced in LLVM 15.
444+
.filter(|v| *v != "+atomics-32" || get_version() >= (15, 0, 0))
443445
.map(String::from),
444446
);
445447

Diff for: compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ pub fn target() -> Target {
1313
abi: "eabi".into(),
1414
// The ARMv6-M architecture doesn't support unaligned loads/stores so we disable them
1515
// with +strict-align.
16-
features: "+strict-align".into(),
16+
// Also force-enable 32-bit atomics, which allows the use of atomic load/store only.
17+
// The resulting atomics are ABI incompatible with atomics backed by libatomic.
18+
features: "+strict-align,+atomics-32".into(),
1719
// There are no atomic CAS instructions available in the instruction set of the ARMv6-M
1820
// architecture
1921
atomic_cas: false,

0 commit comments

Comments
 (0)