Re:Porting Rust's Std to Rustix
by ectopod on Tuesday January 04, 2022 @12:51PM
(#29797614)
The startup/shutdown code is for the C runtime. If you avoid the C runtime you don't need it.
[ Parent
| on HN ]
At a minimum Rust would have to run the C initializers as these are used even in pure Rust code. It might also make use of the security cookie but I'm uncertain about that. Also the C runtime is needed by the SEH handling code (in vcruntime) so Rust would have to replace that before it can replace the C startup/shutdown.
To be clear, this is feasible but it'll require someone knowledgable to put in the work of rewriting this in Rust.
SEH doesn't need the C runtime, they are only required when using the C language extensions for frame-based Exception Handling, with the new vectored Exception Handling, plain Win32 calls will do,
https://docs.microsoft.com/en-us/windows/win32/debug/vectore...
Granted, they are more cumbersome to use and probably not worth the effort to try to avoid them other than special cases.
Sure. I did not mean to imply that SEH itsef requires the C runtime. However, the __CxxFrameHandler3 that Rust/llvm uses would need to be rewritten.
IIRC llvm itself generates calls to __CxxFrameHandler3 when SEH is being used, making it awkward to replace with something that's not compatible.
Re:Porting Rust's Std to Rustix
by steveklabnik on Tuesday January 04, 2022 @01:56PM
(#29798525)
https://crates.io/crates/r0 exists (not everything you're talking about but like, there's some of this stuff around, in some contexts. We'll see if the whole pile of stuff needed ever gets ported or not, I'm guessing yes but on a long timeframe.)