Skip to content

Support u128/i128 c-variadic arguments#155429

Open
folkertdev wants to merge 2 commits into
rust-lang:mainfrom
folkertdev:c-variadic-i128
Open

Support u128/i128 c-variadic arguments#155429
folkertdev wants to merge 2 commits into
rust-lang:mainfrom
folkertdev:c-variadic-i128

Conversation

@folkertdev

@folkertdev folkertdev commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

View all comments

The restriction on u128 is kind of arbitrary, so let's see what it would take to support it.

r? @ghost

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 17, 2026
@folkertdev

Copy link
Copy Markdown
Contributor Author

@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 17, 2026
Support `u128`/`i128` c-variadic arguments


try-job: dist-various-1
try-job: dist-various-2
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the c-variadic-i128 branch 2 times, most recently from 3f2ff65 to 5e8c8b5 Compare April 17, 2026 13:27
@folkertdev

Copy link
Copy Markdown
Contributor Author

@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1

rust-bors Bot pushed a commit that referenced this pull request Apr 17, 2026
Support `u128`/`i128` c-variadic arguments


try-job: dist-various-1
try-job: dist-various-2
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2026
@rust-bors

rust-bors Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

💔 Test for d3bd26f failed: CI. Failed job:

@folkertdev

Copy link
Copy Markdown
Contributor Author

@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 17, 2026
Support `u128`/`i128` c-variadic arguments


try-job: dist-various-1
try-job: dist-various-2
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-bors

rust-bors Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d505291 (d50529125c96155f22b48fab34b00ab49c79dcad, parent: f29256dd1420dc681bf4956e3012ffe9eccdc7e7)

@rustbot

This comment has been minimized.

Comment thread library/core/src/ffi/va_list.rs Outdated
Comment thread compiler/rustc_codegen_llvm/src/va_arg.rs Outdated
Primitive::Int(integer, _) => match integer {
Integer::I8 | Integer::I16 => unreachable!(),
Integer::I32 | Integer::I64 => { /* fall through */ }
Integer::I128 => return Align::EIGHT,

@folkertdev folkertdev Apr 21, 2026

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.

It has custom behavior, the va_arg implementation for powerpc64 is here

https://github.com/llvm/llvm-project/blob/c7eea85b8046660f0a1fd4a1c5c41b44475f8caf/clang/lib/CodeGen/Targets/PPC.cpp#L998

and it uses the implementation here

https://github.com/llvm/llvm-project/blob/c7eea85b8046660f0a1fd4a1c5c41b44475f8caf/clang/lib/CodeGen/Targets/PPC.cpp#L765

The logic falls through to the last line for i128, returning 8. For f128 it curiously does use an alignment of 16, so I've just added that already because it would be easy to miss down the line.

View changes since the review

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.

That's Weird. Kinda almost want to ask if that's intentional. I suppose this is currently correct, at least...? ...but does gcc agree...?

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.

GCC does agree, see https://godbolt.org/z/eW3daf7rG. 24 is added to the pointer, with an alignment of 16 you'd expect to see 32 to be added. 24 = 8 (for the u32 plus padding) + 16 (for the i128).

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.

Ah thanks for digging that up! Such a weird assembly language, to notate immediate adds with their own instruction and use juxtaposition for addition...

Comment thread library/core/src/ffi/va_list.rs

@workingjubilee workingjubilee left a comment

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.

r? workingjubilee

Thanks! I'm going to cogitate on this a little now that I've absorbed it and raised what half-formed thoughts of concerns I have and had those addressed insofar as they were addressable, and will approve-approve this later this night or tomorrow assuming l'esprit d'escalier does not come up with a more material problem. Feel free to ping if it's like Thursday/Friday and it's still waiting on r+, shouldn't be even that long.

View changes since this review

@rustbot rustbot assigned workingjubilee and unassigned tgross35 Jun 30, 2026

@workingjubilee workingjubilee left a comment

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.

I think this is the only extra thing I'd like to record, since clang also mentions "welllll, this isn't in the psABI buuuuut..." and someone might apply the impl without checking the compiler code and then at some point we encounter hilarity and bug reports and etc.

View changes since this review

Comment thread compiler/rustc_codegen_llvm/src/va_arg.rs
@rustbot

rustbot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@folkertdev

Copy link
Copy Markdown
Contributor Author

r=you when CI is green?

@workingjubilee

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 68d7148 has been approved by workingjubilee

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jul 2, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 2, 2026
…ingjubilee

Support `u128`/`i128` c-variadic arguments

The restriction on `u128` is kind of arbitrary, so let's see what it would take to support it.

r? @ghost
rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 3 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
@rust-bors

rust-bors Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit 68d7148 with merge d3b0bac...

Workflow: https://github.com/rust-lang/rust/actions/runs/28565410648

rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Support `u128`/`i128` c-variadic arguments



The restriction on `u128` is kind of arbitrary, so let's see what it would take to support it. 

r? @ghost
@jhpratt

jhpratt commented Jul 2, 2026

Copy link
Copy Markdown
Member

yielding to rollup

@bors yield

@rust-bors

rust-bors Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #158678.

rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 3 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 3 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 2, 2026
…ingjubilee

Support `u128`/`i128` c-variadic arguments

The restriction on `u128` is kind of arbitrary, so let's see what it would take to support it.

r? @ghost
rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 4 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
 - #158682 (Avoid delayed bug for disabled on_type_error arguments)
rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 4 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
 - #158682 (Avoid delayed bug for disabled on_type_error arguments)
rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 4 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
 - #158682 (Avoid delayed bug for disabled on_type_error arguments)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 2, 2026
…ingjubilee

Support `u128`/`i128` c-variadic arguments

The restriction on `u128` is kind of arbitrary, so let's see what it would take to support it.

r? @ghost
rust-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
Rollup of 5 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158627 (Simplify option-iterator flattening in the compiler)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
 - #158682 (Avoid delayed bug for disabled on_type_error arguments)
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. A-run-make Area: port run-make Makefiles to rmake.rs 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants