Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell emscripten to remove exception handling code when the panic runtime is used #36900

Closed
brson opened this issue Oct 1, 2016 · 6 comments
Closed
Labels
A-codegen Area: Code generation E-help-wanted Call for participation: Help is requested to fix this issue. O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@brson
Copy link
Contributor

brson commented Oct 1, 2016

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.

@brson brson added A-codegen Area: Code generation E-help-wanted Call for participation: Help is requested to fix this issue. labels Oct 1, 2016
@japaric
Copy link
Member

japaric commented Oct 1, 2016

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.

@alexcrichton
Copy link
Member

Agreed with @japaric, I don't think #[link_args] is what we want here. I'd be fine adding special knowledge for emscripten in the compiler, however.

@aidanhs
Copy link
Member

aidanhs commented Oct 13, 2016

As I mentioned in the discuss thread, it'd also be nice to consider the possibility of making abort the default for emscripten.

@DemiMarie
Copy link
Contributor

I think abort SHOULD be the default for emscripten! Exceptions in emscripten absolutely trash performance, even if no exception is ever thrown.

@geppy
Copy link

geppy commented Nov 20, 2016

I'd be interested in contributing a PR for this, using @japaric's approach. This'd be my first Rust PR, so should I look for an -E-easy issue instead?

@brson
Copy link
Contributor Author

brson commented Dec 31, 2016

@geppy sorry for not getting back to you earlier.

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.

@brson brson added O-asmjs Target: asm.js - http://asmjs.org/ O-wasm Target: WASM (WebAssembly), http://webassembly.org/ labels Dec 31, 2016
frewsxcv added a commit to frewsxcv/rust that referenced this issue Feb 5, 2017
…xcrichton

Tell emscripten to remove exception handling code when panic=abort

Fixes rust-lang#36900
@workingjubilee workingjubilee added O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! and removed O-asmjs Target: asm.js - http://asmjs.org/ labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation E-help-wanted Call for participation: Help is requested to fix this issue. O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

No branches or pull requests

7 participants