AtomicXX::swap() does not work correctly when the atomic is smaller than 32 bit (i.e. AtomicU16, AtomicBool, possibly AtomicU8 too).
I suspect the LLVM atomic generation code is wrong, as these work just fine on riscv32imc (esp32c3) and (I would assume) single-core Xtensa (esp32s2), where atomics are lowered to libcalls using critical sections (implemented in ESP-IDF).
Here's a repo that demonstrates the problem. I've only tested it on the esp32 target, but esp32s3 might be affected as well, as it is also multicore:
cargo build and then flash on esp32 - the assert_eqs commented with // This breaks?! will fail
cargo build --target riscv32imc-esp-espidf - code should complete up to println!("All done correctly!")
AtomicXX::swap()does not work correctly when the atomic is smaller than 32 bit (i.e. AtomicU16, AtomicBool, possibly AtomicU8 too).I suspect the LLVM atomic generation code is wrong, as these work just fine on riscv32imc (
esp32c3) and (I would assume) single-core Xtensa (esp32s2), where atomics are lowered to libcalls using critical sections (implemented in ESP-IDF).Here's a repo that demonstrates the problem. I've only tested it on the
esp32target, butesp32s3might be affected as well, as it is also multicore:cargo buildand then flash on esp32 - theassert_eqs commented with// This breaks?!will failcargo build --target riscv32imc-esp-espidf- code should complete up toprintln!("All done correctly!")