5 ms·
The startup/shutdown code is for the C runtime. If you avoid the C runtime you don't need it.
by ectopod 5y ago
The startup/shutdown code is for the C runtime. If you avoid the C runtime you don't need it.
- ChrisSD 5y agoAt 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.
- steveklabnik 5y agohttps://crates.io/crates/r0 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.)
- pjmlp 5y agoSEH 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/vectored-exception-handling 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.
- ChrisSD 5y agoSure. 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.