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

Use the C-unwind ABI instead of C when mocking extern C functions #585

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

asomers
Copy link
Owner

@asomers asomers commented Jun 22, 2024

Begining within Rust 1.81
(rust-lang/rust#74990) Rust will abort when attempting to unwind a panic across an "extern C" boundary. Previously it was technically UB, but it worked and Mockall relied on it. Now, unwinding across such a boundary requires the "extern C-unwind" ABI. Use that ABI in the generated code.

However, don't use that ABI when mocking a C variadic function. That doesn't work, due to rust-lang/rust#126836 .

Fixes #584

@asomers
Copy link
Owner Author

asomers commented Jun 22, 2024

@Enes1313 since you are the one who first requested the extern "C" linkage, could you please test your project with this PR branch?

Begining within Rust 1.81
(rust-lang/rust#74990) Rust will abort when
attempting to unwind a panic across an "extern C" boundary.  Previously
it was technically UB, but it worked and Mockall relied on it.  Now,
unwinding across such a boundary requires the "extern C-unwind" ABI.
Use that ABI in the generated code.

However, don't use that ABI when mocking a C variadic function.  That
doesn't work, due to rust-lang/rust#126836 .

Fixes #584
@asomers
Copy link
Owner Author

asomers commented Jun 24, 2024

@Enes1313 I'm going to go ahead and merge this since CI on the master branch is broken . But I'd still appreciate any post-merge feedback you can provide.

@asomers asomers merged commit bcb4a88 into master Jun 24, 2024
3 checks passed
@asomers asomers deleted the C-unwind branch June 24, 2024 01:12
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.

extern C functions need to be C-unwind in Rust 1.81.0
1 participant