Skip to content

Commit 9526a89

Browse files
authored
Rollup merge of #140770 - folkertdev:custom-abi, r=tgross35
add `extern "custom"` functions tracking issue: rust-lang/rust#140829 previous discussion: rust-lang/rust#140566 In short, an `extern "custom"` function is a function with a custom ABI, that rust does not know about. Therefore, such functions can only be defined with `#[unsafe(naked)]` and `naked_asm!`, or via an `extern "C" { /* ... */ }` block. These functions cannot be called using normal rust syntax: calling them can only be done from inline assembly. The motivation is low-level scenarios where a custom calling convention is used. Currently, we often pick `extern "C"`, but that is a lie because the function does not actually respect the C calling convention. At the moment `"custom"` seems to be the name with the most support. That name is not final, but we need to pick something to actually implement this. r? `@traviscross` cc `@tgross35` try-job: x86_64-apple-2
2 parents 5b31687 + 8d85b5a commit 9526a89

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/abi/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ pub(crate) fn conv_to_call_conv(
5151
CanonAbi::Rust | CanonAbi::C => default_call_conv,
5252
CanonAbi::RustCold => CallConv::Cold,
5353

54+
// Functions with this calling convention can only be called from assembly, but it is
55+
// possible to declare an `extern "custom"` block, so the backend still needs a calling
56+
// convention for declaring foreign functions.
57+
CanonAbi::Custom => default_call_conv,
58+
5459
CanonAbi::X86(x86_call) => match x86_call {
5560
X86Call::SysV64 => CallConv::SystemV,
5661
X86Call::Win64 => CallConv::WindowsFastcall,

0 commit comments

Comments
 (0)