Open str4d opened 1 year ago
In this case you're talking about statics that are stored on the heap (from lazy_static, once_cell), rather than static data stored in the .rodata
right?
Yep. People could still use one of those crates, but I believe it would get reported as a memory leak by the FZ tooling.
We can't use once_cell
because it requires std
for Mutex
. I'm instead planning on using generic_once_cell
, which works for any mutex that implements lock_api::RawMutex
. I've implemented the latter locally, and opened #74 with an Instant
impl that I need.
We can't use
once_cell
because it requiresstd
forMutex
.
I think it's possible to use with #[no-std]
as long as you provide a critical-section
implementation. I might take a look at that today, since a number of embedded crates are based around it.
Normal Rust binaries will initialize heap statics on start, and then essentially leak the memory. This works fine because the memory is cleaned up during process exit. We can't assume the same with a FAP, so if we want to support "statics", we should provide a way in the runtime for initializing them before the user's app code runs, and freeing them after it exits.