Closed
Description
I'm not sure why, but when I try building with cortex-ar = {version = "0.1.0", features = ["critical-section-single-core"]}
I get errors such as "rust-lld: error: undefined symbol: _critical_section_1_0_acquire".
I can confirm that the critical section code is being built, but it's not present in the final binary.
I've managed to work around the issue by reimplementing it in my main
, but from what I understand it should already work.
There's no LTO going on. I'm building for armebv7r-none-eabi
with Rust 1.85.1.
Workaround:
#[no_mangle]
pub fn _critical_section_1_0_acquire() -> bool {
use core::sync::atomic;
// the i bit means "masked"
let was_active = !cortex_ar::register::Cpsr::read().i();
cortex_ar::interrupt::disable();
atomic::compiler_fence(atomic::Ordering::SeqCst);
was_active
}
#[no_mangle]
pub fn _critical_section_1_0_release(was_active: bool) {
use core::sync::atomic;
// Only re-enable interrupts if they were enabled before the critical section.
if was_active {
atomic::compiler_fence(atomic::Ordering::SeqCst);
// Safety: This is OK because we're releasing a lock that was
// entered with interrupts enabled
unsafe {
cortex_ar::interrupt::enable();
}
}
}
Metadata
Metadata
Assignees
Labels
No labels