Stabilize extern "custom" - #158504
Conversation
|
r? tgross35 |
|
|
|
cc @tgross35 |
This comment has been minimized.
This comment has been minimized.
|
Do we deny this on wasm? Wasm requires the function signature to be known when defining or importing it. |
|
In that case, does the whole concept of a naked function even make sense there? That is, can it do something that a normal function whose body is an Practically inline assembly is unstable (and extremely incomplete) for wasm, so I'm not sure if/how it'll eventually fit in. But we can deny |
|
Naked asm can avoid touching the stack, maybe there are cases that is useful? Naked asm doesn't help for defining functions that use ref types or GC types as there isn't a way to express those using rust syntax, so those still need |
|
Allowing only assembly calls seems quite restrictive in terms of cross platform capabilities, as a special case, an |
|
This is a restriction on |
|
Just making this explicit: #158621 removes support for wasm and spirv targets. Neither have stable assembly, so practically this doesn't change anything, but the whole concept of |
|
Makes sense to me. Thanks @folkertdev for your work on this. @rfcbot fcp merge lang cc @Amanieu |
|
@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
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. |
|
@rustbot blocked |
|
RFC is up at rust-lang/rfcs#3980 |
|
Based on rust-lang/rfcs#3980 being in FCP... |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
Wasn't actually aware that this was opened before the RFC, but I think this should at least be blocked on the RFC merging, then start FCP, not both happening concurrently. |
|
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. |
2beadda to
e50eeac
Compare
This comment has been minimized.
This comment has been minimized.
e50eeac to
5e6a3e9
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. |
This comment has been minimized.
This comment has been minimized.
5e6a3e9 to
8436fc4
Compare
View all comments
tracking issue: #140829
reference PR: rust-lang/reference#2300
closes #140829
Summary
An
extern "custom" fnis a function with a custom ABI that is unknown to rust. Often these are low-level functions that pass arguments in different registers than any standard calling convention.Design
Because rust doesn't know what calling convention to use, an
extern "custom"function can only be called via inline assembly or FFI.An
extern "custom"function definition must be a naked function:An
extern "custom"function definition must be unsafe. The intent here is that a safety comment is written on how this function may be called.In an
extern "custom"block, functions cannot be marked assafe:An
extern "custom"function cannot have any arguments or a return type:Tests
extern "custom"function gives an error, etc.History
extern "unspecified"for naked functions with arbitrary ABI #140566abi_custom#140829extern "custom"functions #140770extern "custom"function pointers #159780unresolved questions
None