Skip to content

Commit 1e26094

Browse files
committed
Allow atomic operations up to 32 bits
The ARMv5te platform does not have instruction-level support for atomics, however the kernel provides [user space helpers](https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt) which can be used to perform atomic operations. When linked with `libc`, the atomic symbols needed by Rust will be provided, rather than CPU level intrinsics. As this target is specifically `linux` and `gnueabi`, it is reasonable to assume the Linux Kernel and libc will be available for the target. There is a large performance penalty, as we are not using CPU level intrinsics, however this penalty is likely preferable to not having the target at all. I have used this change in a custom target (along with `xargo`) to build `std`, as well as a number of higher level crates.
1 parent 9ae6ed7 commit 1e26094

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc_back/target/armv5te_unknown_linux_gnueabi.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ pub fn target() -> TargetResult {
2727

2828
options: TargetOptions {
2929
features: "+soft-float,+strict-align".to_string(),
30-
// No atomic instructions on ARMv5
31-
max_atomic_width: Some(0),
30+
31+
// Atomic operations provided when linked with libgcc.
32+
// FIXME: If the following PR is merged, the atomic operations would be
33+
// provided by compiler-builtins instead with no change of behavior:
34+
// https://github.com/rust-lang-nursery/compiler-builtins/pull/115/files
35+
max_atomic_width: Some(32),
3236
abi_blacklist: super::arm_base::abi_blacklist(),
3337
.. base
3438
}

0 commit comments

Comments
 (0)