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

Make the unwinding dependency conditional on panic = "unwind". #153

Merged
merged 3 commits into from
Oct 20, 2024

Conversation

sunfishcode
Copy link
Owner

Similar to sunfishcode/origin#149, make the unwinding dependency conditional on panic = "unwind".

Similar to sunfishcode/origin#149, make the unwinding dependency
conditional on `panic = "unwind"`.
@sunfishcode sunfishcode force-pushed the sunfishcode/unwinding branch from b3ed6e7 to be1cdad Compare October 20, 2024 14:55
@bjorn3
Copy link
Contributor

bjorn3 commented Oct 20, 2024

For eyra the unwinding dependency will need to be unconditional as libstd has a hard dependency on it. C-gull should probably also have it unconditionally as it pulls in libstd.

@sunfishcode
Copy link
Owner Author

This appears to be one of those situations where cargo automatically provides us with an unwind library. I've now added a c-gull-unwinding example to test using c-gull and std::panic::catch_unwind to catch a panic.

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 20, 2024

This appears to be one of those situations where cargo automatically provides us with an unwind library.

libstd by default links against libgcc_s or libunwind depending on the target. Did you check that the example doesn't link against any external dylibs?

@sunfishcode
Copy link
Owner Author

Yes:

$ nm -u ./example-crates/c-gull-unwinding/target/debug/c-gull-unwinding
$

and

$ nm -C ./example-crates/c-gull-unwinding/target/debug/c-gull-unwinding | grep unwinding
00000000000bc4c0 T <unwinding::unwinder::find_fde::GlobalFinder as unwinding::unwinder::find_fde::FDEFinder>::find_fde
00000000000bb9f0 T <unwinding::unwinder::find_fde::phdr::PhdrFinder as unwinding::unwinder::find_fde::FDEFinder>::find_fde
0000000000098f50 T <unwinding::unwinder::find_fde::registry::Registry as unwinding::unwinder::find_fde::FDEFinder>::find_fde
...

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 20, 2024

Does it also not link against libgcc_s or libunwind when using panic=abort?

@sunfishcode
Copy link
Owner Author

sunfishcode commented Oct 20, 2024

It does not; I've now added an example-crate for that.

@sunfishcode
Copy link
Owner Author

I mean, it does automatically link in libunwind even with panic = "abort".

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 20, 2024

Yeah, that is what I meant. libstd needs an unwinder even with panic=abort.

@sunfishcode sunfishcode merged commit 55f285f into main Oct 20, 2024
5 checks passed
@sunfishcode sunfishcode deleted the sunfishcode/unwinding branch October 20, 2024 16:08
@sunfishcode
Copy link
Owner Author

sunfishcode commented Oct 20, 2024

As an update here, cfg(panic = "abort")` did not work in Cargo.toml after all, so unless there are better options, we may need to go back to making unwinding optional and just asking users to figure out when to enable it.

sunfishcode added a commit that referenced this pull request Nov 27, 2024
And revert #153, since cfg(panic = "unwind")` doesn't work in
Cargo.toml.
sunfishcode added a commit that referenced this pull request Nov 27, 2024
And revert #153, since cfg(panic = "unwind")` doesn't work in
Cargo.toml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants