Skip to content

Fix bool calling convention for aarch64, etc. - #159317

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
workingjubilee:aarch64-bool-callconv
Jul 27, 2026
Merged

Fix bool calling convention for aarch64, etc.#159317
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
workingjubilee:aarch64-bool-callconv

Conversation

@workingjubilee

@workingjubilee workingjubilee commented Jul 15, 2026

Copy link
Copy Markdown
Member

View all comments

We have been making a broad assumption about the way bool should be handled that may be correct for Rust calling Rust but is wildly incorrect for cross-language FFI calls. The ABI of bool is generally poorly-specified in any C psABI, and often deliberately allows for deviation after the first 8 bits.

This has surfaced as a bug that can corrupt Rust programs on aarch64, but it is a potential latent bug when it comes to every ABI. The simplest solution is to simply stop applying the special case when generating bool's ArgAttributes. This yields control to the later ABI implementations, which may then sign or zero extend the bool (or not) according to their needs.

Fixes #159244

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 15, 2026
Comment thread compiler/rustc_ty_utils/src/abi.rs
@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-log-analyzer

This comment has been minimized.

@workingjubilee
workingjubilee force-pushed the aarch64-bool-callconv branch 3 times, most recently from fda6d0a to 0e89baa Compare July 15, 2026 23:29
@workingjubilee workingjubilee changed the title Fix inappropriate bool calling convention for aarch64 Fix bool calling convention for aarch64, etc. Jul 15, 2026
@workingjubilee workingjubilee added O-AArch64 Armv8-A or later processors in AArch64 mode A-ABI Area: Concerning the application binary interface (ABI) A-FFI Area: Foreign function interface (FFI) labels Jul 15, 2026
@workingjubilee
workingjubilee marked this pull request as ready for review July 15, 2026 23:41
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 15, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 15, 2026
@rustbot

rustbot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 20 candidates

We still attach `noundef` using the code that immediately follows.
It will be fine, trust.
@workingjubilee
workingjubilee force-pushed the aarch64-bool-callconv branch from 0e89baa to d32d914 Compare July 15, 2026 23:45
@workingjubilee

Copy link
Copy Markdown
Member Author

Might as well look at the baseline regression-or-not that we might be facing.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 16, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 16, 2026
Fix `bool` calling convention for aarch64, etc.
@rust-bors

rust-bors Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 47fb3c6 (47fb3c6d799d920ef079445db3076cc4e029e601)
Base parent: d0babd8 (d0babd8b6b05ef9bb65d42f928cef4129d64cf65)

@rust-timer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: davidtwco
Duration: 3h 29m 21s
Pushing ad0c9dc to main...

@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing dfbea5b (parent) -> ad0c9dc (this PR)

Test differences

Show 2 test diffs

Stage 1

  • [assembly] tests/assembly-llvm/aarch64/mask-bool-ffi-return.rs: [missing] -> pass (J1)

Stage 2

  • [assembly] tests/assembly-llvm/aarch64/mask-bool-ffi-return.rs: [missing] -> pass (J0)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard ad0c9dce27a22416b65946bc0010edaf22ac6c83 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-stable: 1h 28m -> 2h 20m (+59.2%)
  2. x86_64-gnu-llvm-21-3: 1h 10m -> 1h 46m (+51.4%)
  3. x86_64-gnu-gcc-core-tests: 14m 43s -> 7m 38s (-48.1%)
  4. i686-gnu-1: 2h 29m -> 1h 23m (-44.4%)
  5. test-various: 2h 15m -> 1h 30m (-33.7%)
  6. dist-i586-gnu-i586-i686-musl: 1h 13m -> 1h 38m (+33.3%)
  7. dist-x86_64-solaris: 1h 42m -> 1h 11m (-29.7%)
  8. dist-android: 22m 59s -> 29m 48s (+29.7%)
  9. i686-gnu-nopt-1: 2h 17m -> 1h 37m (-29.5%)
  10. aarch64-apple: 2h 59m -> 2h 7m (-28.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ad0c9dc): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary 4.1%, secondary -2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
4.1% [4.1%, 4.1%] 1
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.9% [-6.0%, -2.8%] 3
All ❌✅ (primary) 4.1% [4.1%, 4.1%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 486.74s -> 495.576s (1.82%)
Artifact size: 387.74 MiB -> 389.78 MiB (0.53%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ABI Area: Concerning the application binary interface (ABI) A-FFI Area: Foreign function interface (FFI) merged-by-bors This PR was explicitly merged by bors. O-AArch64 Armv8-A or later processors in AArch64 mode 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.

Miscompilation with FFI bool return type on AArch64

10 participants