emcc can remove invoke instructions during final translation. So when compiling with -C panic-runtime=abort, in order to strip the unwinding code out of std, we should pass the appropriate flags to emcc. This can probably be done be setting the link_args from the panic_abort crate.
The text was updated successfully, but these errors were encountered:
This can probably be done be setting the link_args from the panic_abort crate.
If you mean #[link_args], that doesn't carry over from dependency to the top crate so it wouldn't work. And, Cargo can only inject the -l and -L variety of linker arguments. So, I think, this approach would require adding a feature to (Cargo) build scripts that lets them inject arbitrary linker arguments. (I've wanted this feature before but I've heard second-hand that @alexcrichton doesn't like the idea of injecting arbitrary linker arguments and there are some very valid resons to not do allow them but one can't deny it's an useful feature)
I think a, perhaps, more feasible alternative would be special casing this target to have rustc pass the extra, needed flags to emcc when the panic=abort profile is selected. At least this trick can be kept private to rustc.
It seems like we can't do @japaric's approach but need to teach the compiler how to add the arguments without #[link_args].
It looks like the logic belongs in rustc_trans::back::link::link_natively. From existing precedent I'd say that target specs should get an is_like_emscripten flag. and link_natively should do some logic when that is set and the panic strategy is abort.