$ rustc -O --target=wasm32-unknown-unknown <a href="http://main.rs" rel="ugc">main.rs</a> -o main.wasm
error: `#[panic_handler]` function required, but not found
error: aborting due to 1 previous error
@subtype what I'm trying to say is that the language specification (pretend rust has one) requires a panic handler to always be present, just like it requires the type system and lifetime checker to pass, even tho that doesn't appear in the binary
@subtype sure, but i think requiring a panic handler on a spec level and then stripping it out is better than not caring about having one and then failing with obscure linking errors like some gopher languages do
@Ukko okay fine. it could defer the same exact error to the time when the panic handler is actually needed, though? maybe that would pointlessly increase the complexity of the compiler.
@subtype yes and with it always required it's easy to just look and see "oh ok, this is the base minimum i need" instead of "ah i can't use this language construct because then i'll need to implement more builtins". I actually don't hate golang it's just a perfect example of deferring the error but also they have way more such magic builtins to care about.
Why limit ourselves to just panic, why not have the entire std compiled only when needed like zig does it
@Ukko okay but panic handler is the only thing that’s required with no_std. there’s also eh_personality that’s required on some targets, but I guess rustc forgave me that I don’t have one.
@Ukko okay fine, if I actually use a panic in the code it does get compiled. still a bit weird that it's always compiled and then conditionally stripped.
Add comment