declare C and C-unwind as mutually ABI-compatible - #161904
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
b5f3d53 to
ee13dce
Compare
ee13dce to
aee14eb
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rfcbot fcp merge opsem is what I meant... |
|
@RalfJung has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
I don't have any concerns with this either. For a long time |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
We talked about this briefly in the lang meeting today, and all present agreed this made sense. |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
|
@Mark-Simulacrum (or anyone reading along) this now just needs a review. :) |
|
@bors r+ rollup |
Rollup of 8 pull requests Successful merges: - #162556 (Refactor CodeGen Pipeline Setup into a Single Function) - #163254 (rustdoc: Fix where-clause placement of free const items & checked type aliases) - #163621 (core: Unstably constify `abort_immediate`) - #161904 (declare C and C-unwind as mutually ABI-compatible) - #163144 (Add Tier 3 targets for Hyperlight guests) - #163537 (remove unnecessary panic from opsem inhabitedness calculation) - #163570 (Add tests for `!` and `bool`'s size and alignment to `coretests`.) - #163606 (ignore hanging next-solver tests, remove unnecessary ignore test) Failed merges: - #163572 (Update the minimum external LLVM to 22)
Rollup merge of #161904 - RalfJung:unwind-abi-compat, r=Mark-Simulacrum declare C and C-unwind as mutually ABI-compatible We left this conservative in #115476. That means the following code is currently UB: ```rust extern "C-unwind" fn does_not_unwind_but_could() {} fn main() { let f: extern "C-unwind" fn() = does_not_unwind_but_could; let f: extern "C" fn() = unsafe { std::mem::transmute(f) }; f(); } ``` I think this code should be allowed. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/ABI.20compatibility.20of.20.22C.22.20vs.20.22C-unwind.22) also led to the conclusion that this should be fine in LLVM -- the `nounwind` attribute does not affect the ABI. This is widely relied upon in the C ecosystem when doing calls between C and C++. Cc @nikic to confirm. I am not sure why #115476 left this conservative. There was discussion about explicitly listing the ABIs rather than saying this holds universally for all `*-unwind` that we may add in the future, but there was no discussion I could find about allowing a mismatch both ways. Cc @rust-lang/opsem @rust-lang/lang
We left this conservative in #115476. That means the following code is currently UB:
I think this code should be allowed. Zulip discussion also led to the conclusion that this should be fine in LLVM -- the
nounwindattribute does not affect the ABI. This is widely relied upon in the C ecosystem when doing calls between C and C++.Cc @nikic to confirm.
I am not sure why #115476 left this conservative. There was discussion about explicitly listing the ABIs rather than saying this holds universally for all
*-unwindthat we may add in the future, but there was no discussion I could find about allowing a mismatch both ways.Cc @rust-lang/opsem @rust-lang/lang