Skip to content

Conversation

@folkertdev
Copy link
Contributor

@folkertdev folkertdev commented Nov 9, 2025

tracking issue: #148767

#t-lang > C-variadic naked functions

This feature allows naked c-variadic function definitions with any ABI that is supported for foreign c-variadic functions.

#![feature(c_variadic, c_variadic_naked_functions)]

#[unsafe(naked)]
unsafe extern "win64" fn variadic_win64(_: u32, _: ...) -> u32 {
    core::arch::naked_asm!(
        r#"
        push    rax
        mov     qword ptr [rsp + 40], r9
        mov     qword ptr [rsp + 24], rdx
        mov     qword ptr [rsp + 32], r8
        lea     rax, [rsp + 40]
        mov     qword ptr [rsp], rax
        lea     eax, [rdx + rcx]
        add     eax, r8d
        pop     rcx
        ret
    "#,
    )
}

r? @workingjubilee

@folkertdev folkertdev added A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS F-c_variadic `#![feature(c_variadic)]` labels Nov 9, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2025

workingjubilee is currently at their maximum review capacity.
They may take a while to respond.

@workingjubilee
Copy link
Member

ferris_aware

@workingjubilee
Copy link
Member

seems fine.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 11, 2025

📌 Commit 9129b90 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 11, 2025
…kingjubilee

implement `feature(c_variadic_naked_functions)`

tracking issue: rust-lang#148767

[#t-lang > C-variadic naked functions](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/C-variadic.20naked.20functions/with/554593886)

This feature allows naked c-variadic function definitions with any ABI that is supported for foreign c-variadic functions.

```rust
#![feature(c_variadic, c_variadic_naked_functions)]

#[unsafe(naked)]
unsafe extern "win64" fn variadic_win64(_: u32, _: ...) -> u32 {
    core::arch::naked_asm!(
        r#"
        push    rax
        mov     qword ptr [rsp + 40], r9
        mov     qword ptr [rsp + 24], rdx
        mov     qword ptr [rsp + 32], r8
        lea     rax, [rsp + 40]
        mov     qword ptr [rsp], rax
        lea     eax, [rdx + rcx]
        add     eax, r8d
        pop     rcx
        ret
    "#,
    )
}
```

r? `@workingjubilee`
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 11, 2025
…kingjubilee

implement `feature(c_variadic_naked_functions)`

tracking issue: rust-lang#148767

[#t-lang > C-variadic naked functions](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/C-variadic.20naked.20functions/with/554593886)

This feature allows naked c-variadic function definitions with any ABI that is supported for foreign c-variadic functions.

```rust
#![feature(c_variadic, c_variadic_naked_functions)]

#[unsafe(naked)]
unsafe extern "win64" fn variadic_win64(_: u32, _: ...) -> u32 {
    core::arch::naked_asm!(
        r#"
        push    rax
        mov     qword ptr [rsp + 40], r9
        mov     qword ptr [rsp + 24], rdx
        mov     qword ptr [rsp + 32], r8
        lea     rax, [rsp + 40]
        mov     qword ptr [rsp], rax
        lea     eax, [rdx + rcx]
        add     eax, r8d
        pop     rcx
        ret
    "#,
    )
}
```

r? ``@workingjubilee``
bors added a commit that referenced this pull request Nov 12, 2025
Rollup of 12 pull requests

Successful merges:

 - #146627 (Simplify `jemalloc` setup)
 - #147753 (Suggest add bounding value for RangeTo)
 - #147974 (Improve diagnostics for buffer reuse with borrowed references)
 - #148080 ([rustdoc] Fix invalid jump to def macro link generation)
 - #148424 (bootstrap: Add snapshot tests for path-to-step handling)
 - #148500 (Update git index before running diff-index)
 - #148536 (cmse: add test for `async` and `const` functions)
 - #148770 (implement `feature(c_variadic_naked_functions)`)
 - #148819 (Remove specialized warning for removed target)
 - #148830 (miri subtree update)
 - #148833 (Update rustbook dependencies)
 - #148841 (Remove more `#[must_use]` from portable-simd)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 12, 2025
…kingjubilee

implement `feature(c_variadic_naked_functions)`

tracking issue: rust-lang#148767

[#t-lang > C-variadic naked functions](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/C-variadic.20naked.20functions/with/554593886)

This feature allows naked c-variadic function definitions with any ABI that is supported for foreign c-variadic functions.

```rust
#![feature(c_variadic, c_variadic_naked_functions)]

#[unsafe(naked)]
unsafe extern "win64" fn variadic_win64(_: u32, _: ...) -> u32 {
    core::arch::naked_asm!(
        r#"
        push    rax
        mov     qword ptr [rsp + 40], r9
        mov     qword ptr [rsp + 24], rdx
        mov     qword ptr [rsp + 32], r8
        lea     rax, [rsp + 40]
        mov     qword ptr [rsp], rax
        lea     eax, [rdx + rcx]
        add     eax, r8d
        pop     rcx
        ret
    "#,
    )
}
```

r? ```@workingjubilee```
bors added a commit that referenced this pull request Nov 12, 2025
Rollup of 16 pull requests

Successful merges:

 - #146627 (Simplify `jemalloc` setup)
 - #147753 (Suggest add bounding value for RangeTo)
 - #147832 (rustdoc: Don't pass `RenderOptions` to `DocContext`)
 - #147974 (Improve diagnostics for buffer reuse with borrowed references)
 - #148080 ([rustdoc] Fix invalid jump to def macro link generation)
 - #148465 (Adjust spans into the `for` loops context before creating the new desugaring spans.)
 - #148500 (Update git index before running diff-index)
 - #148531 (rustc_target: introduce Abi, Env, Os)
 - #148536 (cmse: add test for `async` and `const` functions)
 - #148770 (implement `feature(c_variadic_naked_functions)`)
 - #148780 (fix filecheck typos in tests)
 - #148819 (Remove specialized warning for removed target)
 - #148830 (miri subtree update)
 - #148833 (Update rustbook dependencies)
 - #148834 (fix(rustdoc): Color doctest errors)
 - #148841 (Remove more `#[must_use]` from portable-simd)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 60b2068 into rust-lang:main Nov 12, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 12, 2025
rust-timer added a commit that referenced this pull request Nov 12, 2025
Rollup merge of #148770 - folkertdev:naked-c-variadic, r=workingjubilee

implement `feature(c_variadic_naked_functions)`

tracking issue: #148767

[#t-lang > C-variadic naked functions](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/C-variadic.20naked.20functions/with/554593886)

This feature allows naked c-variadic function definitions with any ABI that is supported for foreign c-variadic functions.

```rust
#![feature(c_variadic, c_variadic_naked_functions)]

#[unsafe(naked)]
unsafe extern "win64" fn variadic_win64(_: u32, _: ...) -> u32 {
    core::arch::naked_asm!(
        r#"
        push    rax
        mov     qword ptr [rsp + 40], r9
        mov     qword ptr [rsp + 24], rdx
        mov     qword ptr [rsp + 32], r8
        lea     rax, [rsp + 40]
        mov     qword ptr [rsp], rax
        lea     eax, [rdx + rcx]
        add     eax, r8d
        pop     rcx
        ret
    "#,
    )
}
```

r? ````@workingjubilee````
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Nov 12, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#146627 (Simplify `jemalloc` setup)
 - rust-lang/rust#147753 (Suggest add bounding value for RangeTo)
 - rust-lang/rust#147832 (rustdoc: Don't pass `RenderOptions` to `DocContext`)
 - rust-lang/rust#147974 (Improve diagnostics for buffer reuse with borrowed references)
 - rust-lang/rust#148080 ([rustdoc] Fix invalid jump to def macro link generation)
 - rust-lang/rust#148465 (Adjust spans into the `for` loops context before creating the new desugaring spans.)
 - rust-lang/rust#148500 (Update git index before running diff-index)
 - rust-lang/rust#148531 (rustc_target: introduce Abi, Env, Os)
 - rust-lang/rust#148536 (cmse: add test for `async` and `const` functions)
 - rust-lang/rust#148770 (implement `feature(c_variadic_naked_functions)`)
 - rust-lang/rust#148780 (fix filecheck typos in tests)
 - rust-lang/rust#148819 (Remove specialized warning for removed target)
 - rust-lang/rust#148830 (miri subtree update)
 - rust-lang/rust#148833 (Update rustbook dependencies)
 - rust-lang/rust#148834 (fix(rustdoc): Color doctest errors)
 - rust-lang/rust#148841 (Remove more `#[must_use]` from portable-simd)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS F-c_variadic `#![feature(c_variadic)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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