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

Document the issues around calling code in another Rust runtime via the "Rust" ABI #1642

Open
RalfJung opened this issue Oct 3, 2024 · 1 comment

Comments

@RalfJung
Copy link
Member

RalfJung commented Oct 3, 2024

We do permit having more than one copy of the Rust runtime inside a binary, and AFAIK we also permit "Rust" ABI function calls between code using different runtimes, as long as they were built with the exact same toolchain. Or do we require the boundary to entirely consist of stable ABIs such as "C"? Either way, we should document this in the reference. There are probably restrictions on which code can be combined, e.g. if -Zrandomize-layout is set on either side then repr(Rust) types may end up having different layout. And there are definitely restrictions around -Cpanic=abort, since that flag makes the compiler assume that a "Rust" call can never unwind, which means it is UB to make a "Rust" call into another Rust runtime that does unwind.

This came up here but got moved to an issue.

Cc @rust-lang/opsem

@bjorn3
Copy link
Member

bjorn3 commented Oct 3, 2024

There are probably restrictions on which code can be combined, e.g. if -Zrandomize-layout is set on either side then repr(Rust) types may end up having different layout.

If you pass a type across the extern "Rust" boundary, both sides need to use the exact same rmeta/rlib/dylib for the type definition. If you do, then the -Zrandomize-layout for the type also matches.

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

No branches or pull requests

2 participants