Skip to content

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

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

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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
7 participants