Skip to content

Conversation

folkertdev
Copy link
Contributor

Have C define various functions that take a ... or va_list as an argument, and call them from rust. As far as I can see, this just wasn't actually tested before.

In particular this tests a difference between rust VaList and C va_list where C uses array-to-pointer decay, but rust cannot.

I've locally tested this for

  • x86_64-unknown-linux-gnu
  • aarch64-unknown-linux-gnu
  • s390x-unknown-linux-gnu
  • powerpc64-unknown-linux-gnu
  • powerpc64le-unknown-linux-gnu

The latter 2 use an opaque pointer, the first 3 use a single-element array.

cc @beetrees if you see anything incorrect here

r? @workingjubilee

@rustbot
Copy link
Collaborator

rustbot commented Jul 3, 2025

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

@rustbot rustbot added 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. labels Jul 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 3, 2025

This PR modifies run-make tests.

cc @jieyouxu

@folkertdev folkertdev force-pushed the test-variadic-call-from-rust-to-c branch from 6ef0403 to a956428 Compare July 3, 2025 20:53
@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

@bors2 try jobs=aarch64-gnu,x86_64-msvc-,x86_64-apple-

@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

⌛ Trying commit a956428 with merge 69400e8

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 4, 2025
… r=<try>

test passing a `VaList` from rust to C

Have C define various functions that take a `...` or `va_list` as an argument, and call them from rust. As far as I can see, this just wasn't actually tested before.

In particular this tests a difference between rust `VaList` and C `va_list` where C uses array-to-pointer decay, but rust cannot.

I've locally tested this for

- `x86_64-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu`
- `s390x-unknown-linux-gnu`
- `powerpc64-unknown-linux-gnu`
- `powerpc64le-unknown-linux-gnu`

The latter 2 use an opaque pointer, the first 3 use a single-element array.

cc `@beetrees` if you see anything incorrect here

r? `@workingjubilee`

try-job: aarch64-gnu
try-job: x86_64-msvc-*
try-job: x86_64-apple-*
@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

Ah dang, forgot aarch64-apple...
@bors2 cancel

@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

Unknown command "cancel".

@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

@bors2 try jobs=x86_64-msvc-,x86_64-apple-,aarch64-apple

@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

⌛ Trying commit a956428 with merge 037db17

(The previously running try build was automatically cancelled.)

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 4, 2025
… r=<try>

test passing a `VaList` from rust to C

Have C define various functions that take a `...` or `va_list` as an argument, and call them from rust. As far as I can see, this just wasn't actually tested before.

In particular this tests a difference between rust `VaList` and C `va_list` where C uses array-to-pointer decay, but rust cannot.

I've locally tested this for

- `x86_64-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu`
- `s390x-unknown-linux-gnu`
- `powerpc64-unknown-linux-gnu`
- `powerpc64le-unknown-linux-gnu`

The latter 2 use an opaque pointer, the first 3 use a single-element array.

cc `@beetrees` if you see anything incorrect here

r? `@workingjubilee`

try-job: x86_64-msvc-*
try-job: x86_64-apple-*
try-job: aarch64-apple
@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

💔 Test failed

@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

macOS is not happy:

2025-07-04T13:51:46.4617680Z === STDERR ===
2025-07-04T13:51:46.4617930Z test.c:66:22: error: ISO C requires a named parameter before '...'
2025-07-04T13:51:46.4618260Z size_t test_variadic(...) {
2025-07-04T13:51:46.4618490Z                      ^
2025-07-04T13:51:46.4618820Z test.c:68:18: warning: second argument to 'va_start' is not the last named parameter [-Wvarargs]
2025-07-04T13:51:46.4619210Z     va_start(ap, 0);
2025-07-04T13:51:46.4619400Z                  ^
2025-07-04T13:51:46.4619620Z 1 warning and 1 error generated.
2025-07-04T13:51:46.4619860Z ------------------------------------------

Not all our tooling is recent enough for C23.

@folkertdev folkertdev force-pushed the test-variadic-call-from-rust-to-c branch from a956428 to a3277a1 Compare July 4, 2025 15:28
@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

@bors2 try jobs=x86_64-msvc-*,x86_64-apple-*,aarch64-apple

@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

⌛ Trying commit a3277a1 with merge f1d78fc

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 4, 2025
… r=<try>

test passing a `VaList` from rust to C

Have C define various functions that take a `...` or `va_list` as an argument, and call them from rust. As far as I can see, this just wasn't actually tested before.

In particular this tests a difference between rust `VaList` and C `va_list` where C uses array-to-pointer decay, but rust cannot.

I've locally tested this for

- `x86_64-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu`
- `s390x-unknown-linux-gnu`
- `powerpc64-unknown-linux-gnu`
- `powerpc64le-unknown-linux-gnu`

The latter 2 use an opaque pointer, the first 3 use a single-element array.

cc `@beetrees` if you see anything incorrect here

r? `@workingjubilee`

try-job: x86_64-msvc-*
try-job: x86_64-apple-*
try-job: aarch64-apple
@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

☀️ Try build successful (CI)
Build commit: f1d78fc (f1d78fcc4b1c2cca5eacc790284a3a135265e3a7, parent: 556d20a834126d2d0ac20743b9792b8474d6d03c)

@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

Looks like a good baseline to have before any refactors, thanks. :)

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 4, 2025

📌 Commit a3277a1 has been approved by RalfJung

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 Jul 4, 2025
@beetrees beetrees mentioned this pull request Jul 4, 2025
bors added a commit that referenced this pull request Jul 5, 2025
Rollup of 11 pull requests

Successful merges:

 - #142440 (`tests/ui`: A New Order [14/N])
 - #143040 (Add `const Rem`)
 - #143086 (Update poison.rs to fix the typo (sys->sync))
 - #143202 (`tests/ui`: A New Order [18/N])
 - #143296 (`tests/ui`: A New Order [21/N])
 - #143297 (`tests/ui`: A New Order [22/N])
 - #143299 (`tests/ui`: A New Order [24/N])
 - #143300 (`tests/ui`: A New Order [25/N])
 - #143397 (test passing a `VaList` from rust to C)
 - #143410 (Block SIMD in transmute_immediate; delete `OperandValueKind`)
 - #143452 (Fix CLI completion check in `tidy`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5b509e6 into rust-lang:master Jul 5, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 5, 2025
rust-timer added a commit that referenced this pull request Jul 5, 2025
Rollup merge of #143397 - folkertdev:test-variadic-call-from-rust-to-c, r=RalfJung

test passing a `VaList` from rust to C

Have C define various functions that take a `...` or `va_list` as an argument, and call them from rust. As far as I can see, this just wasn't actually tested before.

In particular this tests a difference between rust `VaList` and C `va_list` where C uses array-to-pointer decay, but rust cannot.

I've locally tested this for

- `x86_64-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu`
- `s390x-unknown-linux-gnu`
- `powerpc64-unknown-linux-gnu`
- `powerpc64le-unknown-linux-gnu`

The latter 2 use an opaque pointer, the first 3 use a single-element array.

cc `@beetrees` if you see anything incorrect here

r? `@workingjubilee`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs 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.

6 participants