Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

folkertdev
Copy link
Contributor

@folkertdev folkertdev commented Jul 27, 2025

similar to #144379, but for arm, requested in #144066.

Quoting rust-lang/reference#1946 (comment)

"aapcs" specifically refers to the soft-float ABI where floating-point values are passed in integer registers.

However for c-variadic functions, aapcs behaves the same as C:

https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#65parameter-passing

A variadic function is always marshaled as for the base standard.

https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#7the-standard-variants

This section applies only to non-variadic functions. For a variadic function the base standard is always used both for argument passing and result return.


I also noticed that rustc currently emit more instructions than clang for c-variadic functions on arm, see https://godbolt.org/z/hMce9rnTh. I'll fix that separately. (edit: #144549)

try-job: armhf-gnu
r? @RalfJung

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@folkertdev
Copy link
Contributor Author

@bors2 try

@rust-bors
Copy link

rust-bors bot commented Jul 27, 2025

⌛ Trying commit 7c6fa6a with merge 80a837c

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

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

c-variadic: multiple ABIs in the same program for arm

try-job: armhf-gnu
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

This looks right but I don't know enough about ARM to properly review this. Most of these targets don't have a maintainer listed either so I am not sure whom to ping. So let's try

@rustbot ping arm

"only-aarch64-unknown-linux-gnu",
"only-apple",
"only-arm",
"only-arm-unknown-linux-gnueabihf",
Copy link
Member

Choose a reason for hiding this comment

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

@jieyouxu is this the right thing to do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To let more targets through (as requested below), we can instead allow only-eabihf. That is not perfect, because there are aebi (no hf) targets that still do support executing floating point instructions, but it at least casts a wider net.

Maybe ignore-softfloat could work. I'm not sure how to check for that actually working, from what I can tell the arm targets generally still support floating point instructions, even if they don't pass arguments via fp registers.

Copy link
Member

@jieyouxu jieyouxu Jul 28, 2025

Choose a reason for hiding this comment

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

is this the right thing to do here?

This depends on why you need to have the test run on only-arm-unknown-linux-gnueabihf specifically. I think it's fine if we don't really have a good way to partition the targets as @folkertdev describes.

Also yeah, if this is actually about targets with hard float support, maybe something based on that would be better.

Copy link
Member

Choose a reason for hiding this comment

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

What I meant is, do we just have to add this here? I am surprised there's no new code implementing the logic for this filter.^^

Copy link
Member

@jieyouxu jieyouxu Jul 28, 2025

Choose a reason for hiding this comment

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

What I meant is, do we just have to add this here? I am surprised there's no new code implementing the logic for this filter.^^

Yes, that would be sufficient. This filter is only meant to catch unknown directives (I haven't gotten around to getting rid of it yet), but compiletest actually already have logic to accept //@ only-$target_tuple for all target tuples.

@@ -0,0 +1,62 @@
#![feature(extended_varargs_abi_support)]
//@ run-pass
//@ only-arm-unknown-linux-gnueabihf
Copy link
Member

Choose a reason for hiding this comment

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

Why only that one specific target? (And not all arm targets, or so)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the assembly needs hardware floats, and we're using floats because that is one case where we know aapcs and C are different. We don't have a nice way of filtering for hardware float. Also this is a target that actually runs on CI.

Copy link
Member

Choose a reason for hiding this comment

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

we're using floats because that is one case where we know aapcs and C are different

Please always put such choices into comments! The chance that someone else reading the code will realize this without a comment is probably negligible.

Copy link
Member

Choose a reason for hiding this comment

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

this is a target that actually runs on CI.

That may change though...

Would it work to enable the test on all ARM targets, and then inside the test use a cfg!(target_abi) to neuter it when we don't have floats? Then at least if CI switches to some other arm eabihf target the test will still run.

@rustbot rustbot added the O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Jul 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

Hey ARM Group! This bug has been identified as a good "ARM candidate".
In case it's useful, here are some instructions for tackling these sorts of
bugs. Maybe take a look?
Thanks! <3

cc @adamgemmell @davidtwco @hug-dev @jacobbramley @JamieCunliffe @joaopaulocarreiro @raw-bin @Stammark

@rust-bors
Copy link

rust-bors bot commented Jul 27, 2025

☀️ Try build successful (CI)
Build commit: 80a837c (80a837c50e935a52ceed8d575e3dad16a2c43adf, parent: edc3841c5d28e0f54c6d3c7e906ad083129f3903)

@folkertdev folkertdev force-pushed the c-variadic-same-program-multiple-abis-arm branch from 7c6fa6a to 5440cce Compare July 27, 2025 20:00
@bors
Copy link
Collaborator

bors commented Jul 30, 2025

☔ The latest upstream changes (presumably #144673) made this pull request unmergeable. Please resolve the merge conflicts.

@folkertdev folkertdev force-pushed the c-variadic-same-program-multiple-abis-arm branch from 5440cce to 74c6fdf Compare August 3, 2025 12:05
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

This looks good to me

@folkertdev
Copy link
Contributor Author

With the ARM approval we're good to go here, right?

@RalfJung
Copy link
Member

@bors r=RalfJung,davidtwco

@bors
Copy link
Collaborator

bors commented Aug 21, 2025

📌 Commit 74c6fdf has been approved by RalfJung,davidtwco

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 Aug 21, 2025
bors added a commit that referenced this pull request Aug 21, 2025
Rollup of 16 pull requests

Successful merges:

 - #137494 (libstd: init(): dup() subsequent /dev/nulls instead of opening them again)
 - #144541 (c-variadic: multiple ABIs in the same program for arm)
 - #144613 (aarch64-nintendo-switch-freestanding - Enable CPU features that are always available in a live system (crypto instructions, plus explicit NEON).)
 - #144780 (Add a method to dump MIR in the middle of MIR building)
 - #145137 (Consolidate panicking functions in `slice/index.rs`)
 - #145507 (Refactor attribute parsing to improve ergonomics and some diagnostics)
 - #145604 (Gate static closures behind a parser feature)
 - #145648 (Add two tidy dependency checks)
 - #145661 (update some s390x codegen tests)
 - #145672 (Instantiate higher-ranked binder with erased when checking `IntoIterator` predicate for query instability)
 - #145689 (Migrate `panic_unwind` to use `cfg_select!`)
 - #145700 (Handle `ReEarlyParam` in `type_name`.)
 - #145703 (Remove MIPS targets from CI LLVM platforms)
 - #145704 (ci: don't cleanup windows disk)
 - #145705 (remove an `as` cast in prefetch codegen)
 - #145712 (Update outdated link in bound region comments)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 32975fe into rust-lang:master Aug 22, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 22, 2025
rust-timer added a commit that referenced this pull request Aug 22, 2025
Rollup merge of #144541 - folkertdev:c-variadic-same-program-multiple-abis-arm, r=RalfJung,davidtwco

c-variadic: multiple ABIs in the same program for arm

similar to #144379, but for arm, requested in #144066.

Quoting rust-lang/reference#1946 (comment)

> `"aapcs"` specifically refers to the soft-float ABI where floating-point values are passed in integer registers.

However for c-variadic functions, `aapcs` behaves the same as `C`:

https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#65parameter-passing

> A variadic function is always marshaled as for the base standard.

https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#7the-standard-variants

> This section applies only to non-variadic functions. For a variadic function the base standard is always used both for argument passing and result return.

---

I also noticed that rustc currently emit more instructions than clang for c-variadic functions on arm, see https://godbolt.org/z/hMce9rnTh. I'll fix that separately. (edit: #144549)

try-job: armhf-gnu
r? `@RalfJung`
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 22, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#137494 (libstd: init(): dup() subsequent /dev/nulls instead of opening them again)
 - rust-lang/rust#144541 (c-variadic: multiple ABIs in the same program for arm)
 - rust-lang/rust#144613 (aarch64-nintendo-switch-freestanding - Enable CPU features that are always available in a live system (crypto instructions, plus explicit NEON).)
 - rust-lang/rust#144780 (Add a method to dump MIR in the middle of MIR building)
 - rust-lang/rust#145137 (Consolidate panicking functions in `slice/index.rs`)
 - rust-lang/rust#145507 (Refactor attribute parsing to improve ergonomics and some diagnostics)
 - rust-lang/rust#145604 (Gate static closures behind a parser feature)
 - rust-lang/rust#145648 (Add two tidy dependency checks)
 - rust-lang/rust#145661 (update some s390x codegen tests)
 - rust-lang/rust#145672 (Instantiate higher-ranked binder with erased when checking `IntoIterator` predicate for query instability)
 - rust-lang/rust#145689 (Migrate `panic_unwind` to use `cfg_select!`)
 - rust-lang/rust#145700 (Handle `ReEarlyParam` in `type_name`.)
 - rust-lang/rust#145703 (Remove MIPS targets from CI LLVM platforms)
 - rust-lang/rust#145704 (ci: don't cleanup windows disk)
 - rust-lang/rust#145705 (remove an `as` cast in prefetch codegen)
 - rust-lang/rust#145712 (Update outdated link in bound region comments)

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-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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