-
-
Notifications
You must be signed in to change notification settings - Fork 779
Open
Labels
Description
While compiling tock with the latest nightly version of rust, nightly-2024-02-08
, I encounter 25 warnings regarding the usage of shared references of mutable static in folders such as arch/
, kernel/
, chips/
and boards/
as it can be seen bellow:
warning: shared reference of mutable static is discouraged
--> kernel/src/deferred_call.rs:145:28
|
145 | let ctr = unsafe { &CTR };
| ^^^^ shared reference of mutable static
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
= note: reference of mutable static is a hard error from 2024 edition
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
= note: `#[warn(static_mut_ref)]` on by default
help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
|
145 | let ctr = unsafe { addr_of!(CTR) };
If I understand correctly, for the moment this is just a warning, but it will soon become a compile error. We will need some workarounds for this.
Todo
- Stopgap using
addr_of
to allow us to update nightlies still - Decide on an approach for avoiding the warning or more safely handling mutable statics. kernel: add
SingleThreadValue
type for!Sync
statics, using atomics for synchronization #4551 - Fix deferred call DeferredCall: Port to
SingleThreadValue
#4566 - Fix debug writer static mut: Convert DEBUG_WRITER to SingleThreadValue, rename
type Chip
totype ChipHw
in boards #4624 - Fix debug gpio static mut: Use STV for debug_gpios #4635
- Handle
PROCESSES
,CHIP
, etc. in boards. Board Panic Handlerstatic mut
s: Port toSingleThreadValue
#4519 - Fix chips
- chips/nrf5x/src/aes.rs chips: nrf5x: forbid unsafe #4626
- chips/nrf5x/src/pinmux.rs chips: nrf5x: forbid unsafe #4626
- chips/e310x/src/plic.rs
- chips/earlgrey/src/plic.rs
- chips/esp32-c3/src/chip.rs
- chips/nrf52/src/acomp.rs chips: nrf52: acomp: remove static mut #4625
- chips/nrf52/src/ficr.rs
- chips/qemu_rv32_virt_chip/src/plic.rs
- chips/stm32f303xc/src/exti.rs
- chips/stm32f4xx/src/exti.rs
- chips/veer_el2/src/chip.rs
- chips/apollo3/src/ble.rs
- chips/arty_e21_chip/src/chip.rs
- chips/e310x/src/chip.rs
- chips/earlgrey/src/chip.rs
- chips/esp32-c3/src/chip.rs
- chips/litex_vexriscv/src/chip.rs
- chips/nrf52/src/adc.rs
- chips/nrf52/src/ble_radio.rs
- chips/nrf52/src/pwm.rs
- chips/nrf52/src/uart.rs
- chips/qemu_rv32_virt_chip/src/chip.rs
- chips/veer_el2/src/chip.rs