Stabilize extern "custom"#158504
Conversation
|
r? tgross35 |
|
|
|
cc @tgross35 |
|
☔ The latest upstream changes (presumably #158524) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
|
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. |
|
Looks great! This will be useful for some fun low-level systems programming stunts. @rfcbot reviewed |
|
@rfcbot reviewed I am in favor of this and I like the name I am mildly negative on not having an RFC. I think this is skipping steps and overall that's less good, I'd like to see a (short) write-up with rationale, alternative names considered, etc. That said, I'm leaving it up to @tmandry to make the call on whether to raise a concern. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
In the lang call today, there was a slight preference for seeing an RFC here first. @rfcbot concern needs-rfc |
|
@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. 🔔 |
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 #140770unresolved questions
None