The Rust Calling Convention We Deserve

Rust’s 'fast' calling plan sparks word-game wars and dress memes

TLDR: Rust proposes a 'fast' switch to pass function arguments in registers for speed, challenging the old C rulebook. Commenters split: critics call it “word games” not a real standard, others ask about the “Diana’s $89 dress” mnemonic, and some hope it might even speed up compiling—why it matters: faster Rust.

Rust is fed up with the old “C ABI”—the rulebook for how functions hand off stuff—and wants a sleeker, faster way. The article pitches a “fast” switch (-Zcallconv) so Rust can pass small values in registers (think: pockets) instead of by pointers (think: mailing a package). The author even nods to Go’s register style and shows how today’s Rust sometimes makes simple functions do clumsy handoffs. Cue the crowd: some cheer the idea of smarter defaults and speed, others clutch their debuggers and compatibility guides. One line keeps popping up: we’re too conservative, and missing easy wins. And yes, the post focuses on x86 chips but claims broader ideas.

Then the drama. tomhow points to last year’s debate, proving this isn’t the first Rust rodeo. wahern drops a mic with “word games,” saying this isn’t a real standard but picky, per-function optimization. dataflow asks what on earth “Diana’s $89 dress” means—a cheeky mnemonic for register order that turned into a fashion meme. jauntywundrkind wonders if Rust’s old green threads changed any of this, while zamalek dreams the fast flag might even make compiling Rust itself faster. Verdict? Speed fans vs. standards sticklers, with dress jokes stitched into the seams.

Key Points

  • Rust currently lowers its calling convention to LLVM’s built-in C ABI, favoring Clang-like signatures for stability and debugger compatibility.
  • This conservative approach can cause inefficient codegen, such as passing a 12-byte array ([i32; 3]) by pointer instead of registers in extern "Rust".
  • Under extern "C", small aggregates like [i32; 3] can be passed in registers on x86_64 (e.g., rdi/rsi) and returned efficiently, demonstrating potential gains.
  • The article proposes a per-crate flag, -Zcallconv, with modes legacy (current behavior) and fast (register-friendly), potentially auto-enabled with -O.
  • Constraints include potential confusion from non-C ABI register order, lack of support on targets like WASM, unsuitability for debug builds, and forcing function-pointer calls to legacy due to per-crate configuration.

Hottest takes

"This reads like word games." — wahern
"Can someone explain the part about Diana's $89 dress?" — dataflow
"maybe the improvements from this could make the other bits ... fast enough" — zamalek
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.