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

Change default panic strategy to abort for wasm32-unknown-emscripten #89762

Closed
wants to merge 1 commit into from

Conversation

nedv-eu
Copy link

@nedv-eu nedv-eu commented Oct 11, 2021

Emscripten v2.0.10 removed __gxx_personality_v0 function stub that panic-unwind in wam32-unknown-emscripten target depends on. This causes linker error when using newer versions of emscripten compiler. As mentioned in #85821 (comment) the __gxx_personality_v0 function was just a stub in emscripten for several years and therefor the panic-unwind strategy was broken all the time. Changing default to abort fixes builds (issue 85821) with recent version of emscripten yet we are not loosing any functionality as the panic-unwind was broken anyway. Fixes #85821

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @michaelwoerister (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive
Copy link
Collaborator

⚠️ Warning ⚠️

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 11, 2021
@michaelwoerister
Copy link
Member

Thanks for the PR, @nedv-eu!

I don't feel qualified to review this. Does anyone in @rust-lang/compiler-contributors know more about this topic?

@tmandry
Copy link
Member

tmandry commented Oct 12, 2021

The change makes sense to me, but I'm not familiar with emscripten specifically. Do we have a maintainer for that target?

@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 14, 2021
@michaelwoerister
Copy link
Member

r? @pnkfelix for re-assignment -- maybe we should discuss in the triage meeting?

@nikic
Copy link
Contributor

nikic commented Oct 18, 2021

Based on

if sess.target.is_like_emscripten {
cmd.arg("-s");
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
"DISABLE_EXCEPTION_CATCHING=1"
} else {
"DISABLE_EXCEPTION_CATCHING=0"
});
}

and https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/library/panic_unwind/src/emcc.rs
it looks like we do try to support exceptions with emscripten.

@nedv-eu
Copy link
Author

nedv-eu commented Oct 18, 2021

Yes, seems like there was an attempt to support this. However since it is broken and the fact that enabling exceptions involves a lot of overhead (see https://emscripten.org/docs/porting/exceptions.html) I believe it is the better option to use abort panic strategy by default - as is the case for other wasm targets.

@pnkfelix
Copy link
Member

nominating for discussion in T-compiler meeting about whether we should just adopt approach given here, or if we should expend effort figuring out the exception situation for emscripten.

@pnkfelix pnkfelix added I-compiler-nominated Nominated for discussion during a compiler team meeting. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2021
@wesleywiser
Copy link
Member

Waiting on @pnkfelix for review and approval per last weeks' compiler team meeting.

@wesleywiser wesleywiser added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). I-compiler-nominated Nominated for discussion during a compiler team meeting. labels Nov 11, 2021
@tmarkovski
Copy link

Alternatively, if team doesn't feel the default strategy can be changed, this can be fixed by allowing the emscripten arguments to be passed to the linker, instead overriden. Related bug - #41750
That should fix most of the bugs related to undefined symbol __gxx_personality_v0

@nedv-eu
Copy link
Author

nedv-eu commented Nov 16, 2021

The problem is that __gxx_personality_v0 symbol actually is undefined and panic unwind code is using it. Disabling errors on undefined symbols only masks the problem. Panic unwind at runtime will still crash on undefined symbol. And not only this one but any other undefined symbol error will be caught not during link time but at runtime. That is unacceptable as per fail early rule.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 5, 2021
@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 13, 2021

📌 Commit 8b8bbf0 has been approved by pnkfelix

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 13, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 13, 2021
Change default panic strategy to abort for wasm32-unknown-emscripten

Emscripten v2.0.10 removed __gxx_personality_v0 function stub that panic-unwind in wam32-unknown-emscripten target depends on. This causes linker error when using newer versions of emscripten compiler. As mentioned in rust-lang#85821 (comment) the __gxx_personality_v0 function was just a stub in emscripten for several years and therefor the panic-unwind strategy was broken all the time. Changing default to abort fixes builds  (issue 85821) with recent version of emscripten yet we are not loosing any functionality as the panic-unwind was broken anyway. Fixes  rust-lang#85821
@matthiaskrgr
Copy link
Member

@bors r-
failed in a rollup: #91862 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 13, 2021
@matthiaskrgr
Copy link
Member

@bors rollup=iffy

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 30, 2022
@Dylan-DPC
Copy link
Member

@nedv-eu any updates on the rollup failure?

@nedv-eu
Copy link
Author

nedv-eu commented Feb 24, 2022

Sorry for delay. For some reason I missed previous notifications in this topic.

I went through the failing tests and it seems they are not supposed to be run in this case. There is always a comment "ignore-wasm32-bare compiled with panic=abort by default"

@bjorn3
Copy link
Member

bjorn3 commented Feb 24, 2022

I suspect ignore-wasm32-bare only applies to wasm32-unknown-unknown and not -emscripten. Try ignore-wasm32 without -bare.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 20, 2022
@Dylan-DPC
Copy link
Member

@nedv-eu any updates on this?

@nedv-eu
Copy link
Author

nedv-eu commented Apr 8, 2022

In the end I based my project on wasm32-unknown-unknown. Unfortunately I cannot invest more effort in fixing emscripten target. Feel free to close this unless there is someone else interested in using wasm32-unknown-emscripten target. Since it is broken for quite a along time (at least with recent version of emcc) maybe it is worth considering removing the target from Tier 2?

@Dylan-DPC
Copy link
Member

Closing this based on the last comment

@Dylan-DPC Dylan-DPC closed this Apr 29, 2022
@Dylan-DPC Dylan-DPC removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emscripten wasm32 compilation broken