From b09be6e9b9b73af6103ade2058091a289194e846 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 Jul 2026 16:00:52 -0700 Subject: [PATCH 1/3] Fix abi_custom header levels This updates section headers to use Markdown 2nd level headings. As part of https://github.com/rust-lang/rfcs/pull/3883 we switched the template to not use level-1 headings --- text/0000-extern-custom.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/text/0000-extern-custom.md b/text/0000-extern-custom.md index af1e05fbbe9..6fd5086d1c8 100644 --- a/text/0000-extern-custom.md +++ b/text/0000-extern-custom.md @@ -3,7 +3,7 @@ - RFC PR: [rust-lang/rfcs#0000](https://github.com/rust-lang/rfcs/pull/0000) - Rust Issue: [rust-lang/rust#140829)](https://github.com/rust-lang/rust/issues/140829) -# Summary +## Summary [summary]: #summary An `extern "custom" fn` is 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, so using this helps rustc block you from using this in any place where rustc would need to understand that calling convention. @@ -40,14 +40,14 @@ unsafe extern "custom" { * https://github.com/rust-lang/rust/pull/140770 * https://github.com/rust-lang/rust/pull/158504 -# Motivation +## Motivation [motivation]: #motivation In some low-level scenarios we must define naked functions with a custom ABI. This comes up in `rust-lang/compiler-builtins` (e.g. for `__rust_probestack` and `__aeabi_uidivmod`), and also in systems programming (e.g. when defining `__fentry__`, a symbol used the mcount mechanism). The current solution is often to use `extern "C"`, but that is misleading: the function does not use the C calling convention, and calling it as if it were is almost certainly causing UB. -# Guide-level explanation +## Guide-level explanation [guide-level-explanation]: #guide-level-explanation Because rust doesn't know what calling convention to use, an `extern "custom"` function can only be called via inline assembly or FFI. @@ -125,24 +125,24 @@ help: remove the parameters and return type | ``` -# Reference-level explanation +## Reference-level explanation [reference-level-explanation]: #reference-level-explanation See https://github.com/rust-lang/reference/pull/2300. -# Drawbacks +## Drawbacks [drawbacks]: #drawbacks No specific drawback. -# Rationale and alternatives +## Rationale and alternatives [rationale-and-alternatives]: #rationale-and-alternatives https://github.com/rust-lang/rust/issues/140566 The name has already been debated. The name `unknown` has been mentioned, but to write the implementation you really do need to know the ABI. It is custom in the sense that rustc does not know about it, but the author definitely does. -# Prior art +## Prior art [prior-art]: #prior-art https://github.com/rust-lang/rust/issues/140566#issuecomment-2846205457 @@ -154,12 +154,12 @@ We do have some other calling conventions that cannot be called using rust's fun Those however do have a known ABI, it's just that semantically it does not make sense to call them from a rust program. -# Unresolved questions +## Unresolved questions [unresolved-questions]: #unresolved-questions None currently. -# Future possibilities +## Future possibilities [future-possibilities]: #future-possibilities None currently. From 31544eabfb6b1d182f87adcc6b29137b5ed39e7c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 Jul 2026 16:01:39 -0700 Subject: [PATCH 2/3] Rename 3980 extern-custom --- text/{0000-extern-custom.md => 3980-extern-custom.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename text/{0000-extern-custom.md => 3980-extern-custom.md} (100%) diff --git a/text/0000-extern-custom.md b/text/3980-extern-custom.md similarity index 100% rename from text/0000-extern-custom.md rename to text/3980-extern-custom.md From 33d32acba50144489845d742926412b79bca220c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 Jul 2026 16:02:24 -0700 Subject: [PATCH 3/3] Set 3980 RFC PR link --- text/3980-extern-custom.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/3980-extern-custom.md b/text/3980-extern-custom.md index 6fd5086d1c8..ee4cb361231 100644 --- a/text/3980-extern-custom.md +++ b/text/3980-extern-custom.md @@ -1,6 +1,6 @@ - Feature Name: `abi_custom` - Start Date: 2026-07-01) -- RFC PR: [rust-lang/rfcs#0000](https://github.com/rust-lang/rfcs/pull/0000) +- RFC PR: [rust-lang/rfcs#3980](https://github.com/rust-lang/rfcs/pull/3980) - Rust Issue: [rust-lang/rust#140829)](https://github.com/rust-lang/rust/issues/140829) ## Summary