Description
The built-in thumbv6m-none-eabi
has max_atomic_width
set to 0
because LLVM doesn't know how to lower atomic operations to actual instructions instead it lowers atomic operations to intrinsics like __sync_fetch_and_add_4
. The result is that core
doesn't expose the Atomic*
structs so the alloc
crate and any other crate that depends on it can't be compiled for this target.
I propose we implement those intrinsics in this crate (libcompiler-rt.a
provides these intrinsics on other architectures) and then change the definition of the thumbv6m target (max_atomic_width = 32
) to provide atomics in core
; that way alloc
, collections
and other crates would become compilable for this target.
This is the (incomplete) list of intrinsics that would need to be implemented:
__sync_fetch_and_add_4
__sync_lock_test_and_set_4
Their implementation would likely use locking by temporarily disabling the interrupts.
The alternative is to do the change in the target definition without implement the intrinsics. This pushes the task of implementing the intrinsics to the downstream users.