Skip to content
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

Always specify llvm_abiname for RISC-V targets #131807

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

beetrees
Copy link
Contributor

@beetrees beetrees commented Oct 17, 2024

For RISC-V targets, when llvm_abiname is not specified LLVM will infer the ABI from the target features, causing #116344 to occur. This PR adds the correct llvm_abiname to all RISC-V targets where it is missing (which are all soft-float targets), and adds a test to prevent future RISC-V targets from accidentally omitting llvm_abiname. The only affect of this PR is that -Ctarget-feature=+f (or similar) will no longer affect the ABI on the modified targets.

r? @RalfJung

@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 Oct 17, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2024

These commits modify compiler targets.
(See the Target Tier Policy.)

@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member

I can't speak to the consequences of this PR, so I can't review it, sorry. All I am doing is going around and bothering everyone to get their ABIs in check, I don't actually know the technical details of how exactly to do that on each architecture. ;)

r? compiler

@rustbot rustbot assigned nnethercote and unassigned RalfJung Oct 17, 2024
@RalfJung
Copy link
Member

The only affect of this PR is that -Ctarget-feature=+f (or similar) will no longer affect the ABI on the modified targets.

That sounds great!
What will -Ctarget-feature=-f do when the abiname says "use floats"?

@workingjubilee
Copy link
Member

What will -Ctarget-feature=-f do when the abiname says "use floats"?

I think the answer is actually, surprisingly, that LLVM shrieks "DON'T!" at us. Obviously we have to actually reach codegen, but LLVM actually checks this sort of dependency for the RISCV backend.

@RalfJung
Copy link
Member

RalfJung commented Oct 17, 2024

I wish that would be true. However, according to this, the answer is "Disabling target features required by the requested ABI will cause LLVM to ignore the ABI", which sounds less nice.

@RalfJung
Copy link
Member

Also we probably want to show a nicer error than have LLVM do error reporting. But it's always good to have a safety net :)

@workingjubilee
Copy link
Member

Ah, yeah, I checked and the code that I thought might be there isn't. Sadness!

@RalfJung
Copy link
Member

RalfJung commented Oct 17, 2024 via email

@RalfJung
Copy link
Member

RalfJung commented Oct 17, 2024 via email

@workingjubilee
Copy link
Member

I think we can make that happen, yeah. RISCV does some forms of feature dependency-checking already.

@workingjubilee workingjubilee added O-riscv Target: RISC-V architecture A-ABI Area: Concerning the application binary interface (ABI) labels Oct 21, 2024
@workingjubilee
Copy link
Member

I believe this PR that sets llvm_abiname for all RISCV targets is correct, and I know it is for the tier 2 targets it affects, so I am approving it. Hopefully it simply breaks on CI if I am wrong about those. I am pinging affected tier 3 target maintainers as a "by the way": Let us know if this needs fixing, but it shouldn't, because this should be a nop unless you were depending on -Ctarget-feature="+f" affecting the ABI.

@bors r+

@bors
Copy link
Contributor

bors commented Oct 22, 2024

📌 Commit 3ea91c0 has been approved by workingjubilee

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 Oct 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2024
…kingjubilee

Rollup of 6 pull requests

Successful merges:

 - rust-lang#130432 (rust_for_linux: -Zregparm=<N> commandline flag for X86 (rust-lang#116972))
 - rust-lang#131697 (`rt::Argument`: elide lifetimes)
 - rust-lang#131807 (Always specify `llvm_abiname` for RISC-V targets)
 - rust-lang#131954 (shave 150ms off bootstrap)
 - rust-lang#132015 (Move const trait tests from `ui/rfcs/rfc-2632-const-trait-impl` to `ui/traits/const-traits`)
 - rust-lang#132017 (Update triagebot.toml)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1b24c6f into rust-lang:master Oct 22, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2024
Rollup merge of rust-lang#131807 - beetrees:riscv-target-abi, r=workingjubilee

Always specify `llvm_abiname` for RISC-V targets

For RISC-V targets, when `llvm_abiname` is not specified LLVM will infer the ABI from the target features, causing rust-lang#116344 to occur. This PR adds the correct `llvm_abiname` to all RISC-V targets where it is missing (which are all soft-float targets), and adds a test to prevent future RISC-V targets from accidentally omitting `llvm_abiname`. The only affect of this PR is that `-Ctarget-feature=+f` (or similar) will no longer affect the ABI on the modified targets.

<!-- homu-ignore:start -->
r? `@RalfJung`
<!--- homu-ignore:end -->
assert_matches!(&*self.llvm_abiname, "ilp32" | "ilp32f" | "ilp32d" | "ilp32e")
}
"riscv64" => {
assert_matches!(&*self.llvm_abiname, "lp64" | "lp64f" | "lp64d" | "lp64q")
Copy link

Choose a reason for hiding this comment

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

What about lp64e?

Copy link
Member

Choose a reason for hiding this comment

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

we currently don't support any rv64e targets, and we don't really (intentionally) support "this can have one of multiple ABIs" target tuples. we'll need to fix this when we cross that bridge though, so if you want to PR to fix it now, happy to take that on.

Copy link
Member

Choose a reason for hiding this comment

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

more explicitly: r? me and I'll sign off on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the list of ABIs from the RISC-V ABIs Specification: lp64e is not currently mentioned anywhere in that document as it's still waiting for a 2-year-old PR to be reviewed and merged.

@rustbot
Copy link
Collaborator

rustbot commented Oct 28, 2024

Assignment is not allowed on a closed PR.

@workingjubilee
Copy link
Member

workingjubilee commented Oct 28, 2024

thbbbt rustbot.

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Nov 1, 2024
…, r=workingjubilee

Remove `""` case from RISC-V `llvm_abiname` match statement

For RISC-V, `""` isn't the always the same ABI as `"ilp32"`/`"lp64"` (`""` means LLVM will infer the ABI based on the enabled target features), but `create_object_file` currently assumes that it is. Since all RISC-V targets explicitly specify their ABI since rust-lang#131807, this PR removes `""` from the match arm's pattern (meaning an empty string will now fall through to the `_ => bug!` arm).

r? `@workingjubilee`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2024
Rollup merge of rust-lang#132421 - beetrees:riscv-abi-no-empty-string, r=workingjubilee

Remove `""` case from RISC-V `llvm_abiname` match statement

For RISC-V, `""` isn't the always the same ABI as `"ilp32"`/`"lp64"` (`""` means LLVM will infer the ABI based on the enabled target features), but `create_object_file` currently assumes that it is. Since all RISC-V targets explicitly specify their ABI since rust-lang#131807, this PR removes `""` from the match arm's pattern (meaning an empty string will now fall through to the `_ => bug!` arm).

r? `@workingjubilee`
Arnavion added a commit to Arnavion/riscv that referenced this pull request Nov 4, 2024
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) O-riscv Target: RISC-V architecture 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
Development

Successfully merging this pull request may close these issues.

8 participants