-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add support for a no-unwind compiler flag #471
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
Comments
👍 |
Huge plus one for me. I wanted to propose the same already but I believe we need to find a good way to make rust code less panic'y. I will volunteer for bringing up an RFC in any case once I feel confident we have a good plan for error handling. |
For distributing libraries as source, I can easily see cargo handling whether or not to enable unwinding. For distributing libraries as binaries, perhaps we could look into distributing fat binaries with both versions compiled in. |
IIRC @pcwalton has been planing to write this RFC for some time. |
CC @thestinger |
Note that the question of whether the flag should be enabled by default can be deferred to later, what's most important here is getting the flag in the first place. |
Huge +1 from me as well. Lots of people/projects/companies turn off exception support in C++ (with This is one of those features that rustc will without a doubt have sooner or later. It's just inevitable; if rustc won't have it officially, we'll see unofficial forks that provide this (and probably more than one). This feature is that necessary. |
A hypothetical question: if instead of unwinding stack and executing handlers at each frame, we linked all objects with destructors into a list (per-thread), would people feel better about panics? |
That would be quite a bit more expensive than the scheme we have today. I think that people are exaggerating the cost of the unwinding scheme we have today: I'm not opposed to allowing it to be turned off, but I think the cost of the unwinding info is exaggerated a lot. "Zero-cost exception handling" is a bit of a lie, but it's not far from the truth. |
Well, I would concede the point to unwind-haters that currently landing pads look pretty bad. It's basically a second copy of all the scope exit code, that unfortunately cannot be shared with the "normal" control flow. To add insult to the injury, I've seen LLVM inlining drop glue into the landing pads :( |
I don't think any language or (public) library-level changes are required. It's just a compiler optimization and doesn't need an RFC. I filed an issue about this a while ago: rust-lang/rust#18511 |
@pcwalton: It hamstring's our ability to optimize library code along and does hurt LLVM's ability to perform transformations on the code by adding lots of flow control it has to preserve. It also makes it much harder to write correct |
This isn't the place to argue whether Rust should or should not support unwinding. We're all in agreement that unwinding should not be mandatory. |
If you don't want an argument, don't claim that the other side is exaggerating the costs. |
My comment was in reference to "if instead of unwinding stack and executing handlers at each frame, we linked all objects with destructors into a list (per-thread), would people feel better about panics?" This would have enormous overhead relative to unwinding and the fact that it's being brought up shows that the costs of unwinding are being exaggerated in some people's minds. |
What is the state of this? |
We have |
@nagisa I thought that that didn't affect dependencies? |
@ticki you cannot affect dependencies whose code is already generated anyway, can you? i.e. implementing that sort of feature would require some runtime panic impl switching. |
Triage: Fixed by #1513 |
This would reinterpret all
panics
asaborts
. This has the potential to reduce compilation time, reduce binary size, improve runtime performance, and increase programmer reasoning capacity (an unwind can't smash through this careful unsafe code).The precise technical details are a bit hairy, though. All libraries/binaries involved would likely need to have the same setting for this flag, which would imply two
std
builds per platform. Presumably Cargo will need to support metadata for unwind/no-unwind compatibility of the codebase.Regardless there seems to be a lot of support for doing this eventually, so here's a formal issue to track this. Maybe someone will be brave enough to write a proper RFC.
The text was updated successfully, but these errors were encountered: