Hello everyone,
I am trying to port rust and rust std to my custom OS. (I'm sorry I can't provide the source code of my OS )
I want to implement stdio related behavior first for debugging purposes (print macros and panic).
But even after implementing both Stdout and Stderr inside sys/pal/customos/stdio.rs my test program panics when I use the print macro leading into a segfault which is itself triggered by an infinite loop of panic.
Using gdb I found that it is triggered by this portion of code in library/std/src/sync/once_lock.rs :
#[inline]
#[unstable(feature = "once_cell_try", issue = "109737")]
pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E>
where
F: FnOnce() -> Result<T, E>,
{
// Fast path check
// NOTE: We need to perform an acquire on the state in this method
// in order to correctly synchronize `LazyLock::force`. This is
// currently done by calling `self.get()`, which in turn calls
// `self.is_initialized()`, which in turn performs the acquire.
if let Some(value) = self.get() {
return Ok(value);
}
self.initialize(f)?;
debug_assert!(self.is_initialized());
// SAFETY: The inner value has been initialized
Ok(unsafe { self.get_unchecked() })
}
My question would be, is there some documention, guide or any resource that lists the mandatory work to be done before print macro works on my custom OS ? I already explored most of Rust internal docs, Compiler dev / Std dev but I didn't find any info that could help me.
Thanks in advance for your help, I wish you a good day !