Skip to content

Fix passing/returning structs with the 64-bit SPARC ABI#142680

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
beetrees:sparc64-float-struct-abi
Feb 12, 2026
Merged

Fix passing/returning structs with the 64-bit SPARC ABI#142680
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
beetrees:sparc64-float-struct-abi

Conversation

@beetrees
Copy link
Contributor

@beetrees beetrees commented Jun 18, 2025

Fixes the 64-bit SPARC part of #115609 by replacing the current implementation with a new implementation modelled on the RISC-V calling convention code (SPARC ABI reference).

Pinging sparcv9-sun-solaris target maintainers: @psumbera @kulikjak
Fixes #115336
Fixes #115399
Fixes #122620
Fixes #147883
r? @workingjubilee

@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

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

@rustbot rustbot added 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 Jun 18, 2025
@beetrees
Copy link
Contributor Author

r? @bjorn3

@rustbot rustbot assigned bjorn3 and unassigned workingjubilee Jun 18, 2025
@beetrees
Copy link
Contributor Author

beetrees commented Jun 18, 2025

Note that there are currently two places that Clang and GCC disagree AFAIK:

  • Clang fails to correctly align 16-byte structs when passing them as arguments, whereas GCC correctly aligns them. As the specification states that the structs must be aligned, I've filed an Clang bug at Clang: 64-bit SPARC doesn't align struct arguments as required by ABI llvm/llvm-project#144709.
  • Clang passes floating point fields in packed structs in floating point register if the field is aligned within the argument as a whole, whereas GCC always passes packed structs in integer registers. The specification doesn't consider the existence of packed structs, however in my opinion Clang's interpretation seems more correct so that's what I've implemented in this PR. Issues for Rust, Clang and GCC.

@psumbera
Copy link
Contributor

Thank you for doing this! My knowledge in this area is rather limited.

I was able to build latest Rust sources with your fix on top on Solaris 11.4 SPARC. Then I used this version to build Firefox on Solaris. There was no problem. Firefox also worked as expected.

I also tested some problematic cases which I was handling few years ago (https://github.com/psumbera/rust-sparc64-abi-tests). All seemed to be ok.

@bjorn3
Copy link
Member

bjorn3 commented Jul 3, 2025

I don't have time to properly review this right now.

r? compiler

@rustbot rustbot assigned WaffleLapkin and unassigned bjorn3 Jul 3, 2025
@workingjubilee workingjubilee self-assigned this Jul 4, 2025
@bors
Copy link
Collaborator

bors commented Jul 6, 2025

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

@beetrees beetrees force-pushed the sparc64-float-struct-abi branch from 4eb3ce5 to 9e4a7bc Compare July 6, 2025 14:45
@beetrees
Copy link
Contributor Author

beetrees commented Jul 6, 2025

Rebased

@WaffleLapkin WaffleLapkin removed their assignment Jul 8, 2025
@bors
Copy link
Collaborator

bors commented Jul 22, 2025

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

@beetrees beetrees force-pushed the sparc64-float-struct-abi branch from 9e4a7bc to b7b3ed7 Compare July 27, 2025 08:50
@wesleywiser
Copy link
Member

Hi @workingjubilee, are you still interested in reviewing this? If not, we can reroll for a different reviewer. Thanks!

@tgross35
Copy link
Contributor

tgross35 commented Sep 5, 2025

Looks like there is a Clang fix in llvm/llvm-project#155829

@workingjubilee
Copy link
Member

Sorry about that, currently in catchup mode so I am going to delegate, yes.

r? @tgross35

@rustbot rustbot assigned tgross35 and unassigned workingjubilee Sep 10, 2025
@beetrees beetrees force-pushed the sparc64-float-struct-abi branch from b7b3ed7 to 7cba46f Compare September 10, 2025 19:41
@rustbot

This comment has been minimized.

@beetrees beetrees force-pushed the sparc64-float-struct-abi branch from 7cba46f to b2e4ee9 Compare September 10, 2025 19:51
@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 10, 2026
@folkertdev folkertdev force-pushed the sparc64-float-struct-abi branch from 7515aca to 9129b31 Compare February 10, 2026 10:39
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2026

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 folkertdev force-pushed the sparc64-float-struct-abi branch from 9129b31 to 4373d2f Compare February 10, 2026 11:17
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the sparc64-float-struct-abi branch from 4373d2f to 8ebba60 Compare February 10, 2026 11:30
@rust-log-analyzer

This comment has been minimized.

Co-authored-by: beetrees <b@beetr.ee>
@folkertdev folkertdev force-pushed the sparc64-float-struct-abi branch from 8ebba60 to c9b5c93 Compare February 10, 2026 11:40
@folkertdev
Copy link
Contributor

@bors r=tgross35

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

📌 Commit c9b5c93 has been approved by tgross35

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 10, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 11, 2026
… r=tgross35

Fix passing/returning structs with the 64-bit SPARC ABI

Fixes the 64-bit SPARC part of rust-lang#115609 by replacing the current implementation with a new implementation modelled on the RISC-V calling convention code ([SPARC ABI reference](https://sparc.org/wp-content/uploads/2014/01/SCD.2.4.1.pdf.gz)).

Pinging `sparcv9-sun-solaris` target maintainers: @psumbera @kulikjak
Fixes rust-lang#115336
Fixes rust-lang#115399
Fixes rust-lang#122620
Fixes rust-lang#147883
r? @workingjubilee
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 11, 2026
… r=tgross35

Fix passing/returning structs with the 64-bit SPARC ABI

Fixes the 64-bit SPARC part of rust-lang#115609 by replacing the current implementation with a new implementation modelled on the RISC-V calling convention code ([SPARC ABI reference](https://sparc.org/wp-content/uploads/2014/01/SCD.2.4.1.pdf.gz)).

Pinging `sparcv9-sun-solaris` target maintainers: @psumbera @kulikjak
Fixes rust-lang#115336
Fixes rust-lang#115399
Fixes rust-lang#122620
Fixes rust-lang#147883
r? @workingjubilee
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 12, 2026
… r=tgross35

Fix passing/returning structs with the 64-bit SPARC ABI

Fixes the 64-bit SPARC part of rust-lang#115609 by replacing the current implementation with a new implementation modelled on the RISC-V calling convention code ([SPARC ABI reference](https://sparc.org/wp-content/uploads/2014/01/SCD.2.4.1.pdf.gz)).

Pinging `sparcv9-sun-solaris` target maintainers: @psumbera @kulikjak
Fixes rust-lang#115336
Fixes rust-lang#115399
Fixes rust-lang#122620
Fixes rust-lang#147883
r? @workingjubilee
rust-bors bot pushed a commit that referenced this pull request Feb 12, 2026
Rollup of 17 pull requests

Successful merges:

 - #142415 (Add note when inherent impl for a alias type defined outside of the crate)
 - #142680 (Fix passing/returning structs with the 64-bit SPARC ABI)
 - #150768 (Don't compute FnAbi for LLVM intrinsics in backends)
 - #151152 (Add FCW for derive helper attributes that will conflict with built-in attributes)
 - #151814 (layout: handle rigid aliases without params)
 - #151863 (Borrowck: simplify diagnostics for placeholders)
 - #152159 (Add note for `?Sized` params in int-ptr casts diag)
 - #152434 (Clarify names of `QueryVTable` functions for "executing" a query)
 - #152478 (Remove tm_factory field from CodegenContext)
 - #152498 (Partially revert "resolve: Update `NameBindingData::vis` in place")
 - #152316 (fix: add continue)
 - #152394 (Correctly check if a macro call is actually a macro call in rustdoc highlighter)
 - #152425 (Port #![test_runner] to the attribute parser)
 - #152481 (Use cg_ssa's produce_final_output_artifacts in cg_clif)
 - #152485 (fix issue#152482)
 - #152495 (Clean up some subdiagnostics)
 - #152502 (Implement `BinaryHeap::from_raw_vec`)
@rust-bors rust-bors bot merged commit b1b6533 into rust-lang:main Feb 12, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 12, 2026
rust-timer added a commit that referenced this pull request Feb 12, 2026
Rollup merge of #142680 - beetrees:sparc64-float-struct-abi, r=tgross35

Fix passing/returning structs with the 64-bit SPARC ABI

Fixes the 64-bit SPARC part of #115609 by replacing the current implementation with a new implementation modelled on the RISC-V calling convention code ([SPARC ABI reference](https://sparc.org/wp-content/uploads/2014/01/SCD.2.4.1.pdf.gz)).

Pinging `sparcv9-sun-solaris` target maintainers: @psumbera @kulikjak
Fixes #115336
Fixes #115399
Fixes #122620
Fixes #147883
r? @workingjubilee
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 12, 2026
…at-test, r=RalfJung

sparc64: enable abi compatibility test

fixes rust-lang#115336

We can now remove the exceptions for sparc64 from the abi compatibility tests (since rust-lang#142680).

I was also able to remove a cfg for mips64. The remaining (tested) issues seem to be around how `f64` is handled there.

cc @RalfJung
r? tgross35
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 12, 2026
…at-test, r=RalfJung

sparc64: enable abi compatibility test

fixes rust-lang#115336

We can now remove the exceptions for sparc64 from the abi compatibility tests (since rust-lang#142680).

I was also able to remove a cfg for mips64. The remaining (tested) issues seem to be around how `f64` is handled there.

cc @RalfJung
r? tgross35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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