-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rust should have an optional dependency on C++ #10469
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
Unwinding is implemented in |
Nominating. For embeddability of rust I believe that this is very important. |
Oh, I should also mention that our usage of the corresponding |
We need to ultimately completely rid ourselves of the C++ dependency, and I would rather achieve that than add a new build mode. Can we not unwind by using libunwind directly? |
Looking at libunwind's api, it looks like it's "really easy" to unwind the stack, but I don't think that it parses all the information to run destructors. I may be missing something, but that's the only piece for libunwind that I know of. |
Important long-term goal to get rid of C++ dependency, but does not block 1.0. P-low. |
This PR removes Rust's dependency on C++ for exception handling. Instead, it will use the unwind library API directly. closes #10469
Right now, any compilation of any rust library will have a dependency on
libstdc++
. If one views Rust as a targeted replacement for C++, then it seems weird to depend on it!There are currently four reasons why rust depends on C++
new
operator which I believe throws on OOMI have successfully extracted the dependency on C++ as part of alexcrichton@4b2bb6f. That patch is nowhere near a landable form, however.
I'm coming to believe that this is a fairly important dependency that we should be able to rid ourselves of (with strings attached). I propose the following plan of attack.
new
operatorrust_try
to just callingf
, andrust_begin_unwind
would be equivalent toassert(false)
. This newlibrustrt
would be distributed along the rust standard libraries aslibrustrt_no_landing_pads
or something like that.-Z no-landing-pads
, link tolibrustrt_no_landing_pads
instead oflibrustrt
As the strategy implies, the only way to drop the C++ dependency would be to forgo unwinding entirely. For now this is our best option of dropping the C++ dependency, and perhaps in the future if we ever implement unwinding without C++ exceptions we won't even need this business of a separate compilation profile.
How do others feel about this?
The text was updated successfully, but these errors were encountered: