Login
You're viewing the functional.cafe public feed.
  • Nov 16, 2026, 2:35 PM

    Something that wasn't in the release blog post (I forgot), but is stable in Rust 1.100 is `extern "custom"`.

    These are functions with a calling convention (the details of where the arguments go in registers/on the stack) that rust does not know about, hence these functions can't be called, except via inline assembly.

    github.com/rust-lang/rust/pull

    #rustlang

    An example of an `extern "custom"` function from the rust compiler-builtins crate. It defines __rust_probestack. The symbol is exported, but should not be called from rust code. The full code is:

// Our goal here is to touch each page between `rsp+8` and `rsp+8-rax`,
// ensuring that if any pages are unmapped we'll make a page fault.
//
// The ABI here is that the stack frame size is located in `rax`. Upon
// return we're not supposed to modify `rsp` or `rax`.
#[cfg(target_arch = "x86_64")]
#[unsafe(naked)]
#[rustc_std_internal_symbol]
pub unsafe extern "custom" fn __rust_probestack() {
    core::arch::naked_asm!(
        "
            .cfi_startproc
            push  rbp
            .cfi_adjust_cfa_offset 8
            .cfi_offset rbp, -16
            mov   rbp, rsp
            .cfi_def_cfa_register rbp
    💬 0🔄 3⭐ 6