Skip to content

add extern "rust-tail" calling convention#157016

Draft
folkertdev wants to merge 1 commit into
rust-lang:mainfrom
folkertdev:add-tailcc-abi
Draft

add extern "rust-tail" calling convention#157016
folkertdev wants to merge 1 commit into
rust-lang:mainfrom
folkertdev:add-tailcc-abi

Conversation

@folkertdev
Copy link
Copy Markdown
Contributor

Maps to LLVM's tailcc and hence inherits all its problems.

This calling convention at least compiles on:

  • x86_64
  • aarch64
  • s390x
  • loongarch64

For most backends LLVM does not have support and fails loudly. At least for loongarch64 I noticed that LLVM does not actually have any tests for it.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 27, 2026
@rust-log-analyzer

This comment has been minimized.

CanonAbi::RustPreserveNone => default_call_conv,

// Cranelift doesn't currently have anything for this.
CanonAbi::RustTail => default_call_conv,
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please emit an error as a fallback to extern "C" would not be ABI compatible with LLVM.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the same true for RustPreserveNone? I can adjust that one too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

// Cranelift doesn't currently have anything for this.
CanonAbi::RustPreserveNone => default_call_conv,
CanonAbi::RustPreserveNone | CanonAbi::RustTail => {
sess.dcx().fatal("call conv {c:?} is LLVM-specific")
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sess.dcx().fatal("call conv {c:?} is LLVM-specific")
sess.dcx().fatal(format!("call conv {c:?} is LLVM-specific"))

View changes since the review

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [codegen] tests/codegen-llvm/zip.rs ... ok

failures:

---- [codegen] tests/codegen-llvm/tailcc.rs#UNSUPPORTED stdout ----
------rustc stdout------------------------------

------rustc stderr------------------------------
warning: unused variable: `x`
##[warning]  --> /checkout/tests/codegen-llvm/tailcc.rs:21:33
   |
21 | pub extern "rust-tail" fn peach(x: u16) {
   |                                 ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

error: extern "rust-tail" is only supported on x86_644 and aarch64
---
------------------------------------------

error in revision `UNSUPPORTED`: compilation failed!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/codegen-llvm/tailcc.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--cfg" "unsupported" "--check-cfg" "cfg(test,FALSE,x86,aarch64,unsupported)" "-O" "-Cdebug-assertions=no" "-Zcodegen-source-order" "--emit" "llvm-ir" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/tailcc.UNSUPPORTED/tailcc.ll" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "-C" "no-prepopulate-passes" "--target=powerpc64le-unknown-linux-gnu" "--extern" "minicore=/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/tailcc.UNSUPPORTED/libminicore.rlib"
stdout: none
--- stderr -------------------------------
warning: unused variable: `x`
##[warning]  --> /checkout/tests/codegen-llvm/tailcc.rs:21:33
   |
21 | pub extern "rust-tail" fn peach(x: u16) {
   |                                 ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

error: extern "rust-tail" is only supported on x86_644 and aarch64

error: aborting due to 1 previous error; 1 warning emitted
------------------------------------------

---- [codegen] tests/codegen-llvm/tailcc.rs#UNSUPPORTED stdout end ----

failures:
    [codegen] tests/codegen-llvm/tailcc.rs#UNSUPPORTED

test result: FAILED. 881 passed; 1 failed; 185 ignored; 0 measured; 3 filtered out; finished in 15.84s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants