Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

folkertdev
Copy link
Contributor

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

It looks like aapcs and C are in fact the same for variadic functions on 32-bit arm using hardware floats. For non-variadic functions, there are differences between these ABIs.

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.

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

@@ -959,6 +959,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"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
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-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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants