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

Allow building for hard-float targets in RISC-V #65024

Closed
archshift opened this issue Oct 2, 2019 · 6 comments
Closed

Allow building for hard-float targets in RISC-V #65024

archshift opened this issue Oct 2, 2019 · 6 comments
Labels
A-cross Area: Cross compilation C-feature-request Category: A feature request, i.e: not implemented / a PR. O-riscv Target: RISC-V architecture T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@archshift
Copy link
Contributor

Currently Rust does not support compiling/linking with LLVM's -target-abi=lp64d option, which enables the hard-float ABI in riscv64.

This feature is necessary for Rust interop with C code on hard-float targets.

@jonas-schievink jonas-schievink added A-cross Area: Cross compilation C-feature-request Category: A feature request, i.e: not implemented / a PR. O-riscv Target: RISC-V architecture T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 2, 2019
@songdongsheng
Copy link

+1 for general-purpose binary Linux distributions has been agreed use lp64d as the Hardware baseline and ABI choice.

https://wiki.debian.org/RISC-V#Hardware_baseline_and_ABI_choice

tmandry added a commit to tmandry/rust that referenced this issue Nov 1, 2019
…excrichton

Allow specifying LLVM's MCTargetOptions::ABIName in target specification files

This addresses rust-lang#65024, as it allows RISC-V target specification files to set `"llvm-abiname": "lp64d"`.

Other languages (read: C) usually expose this codegen parameter under a compiler argument like `-mabi=<XYZ>`.
tmandry added a commit to tmandry/rust that referenced this issue Nov 1, 2019
…excrichton

Allow specifying LLVM's MCTargetOptions::ABIName in target specification files

This addresses rust-lang#65024, as it allows RISC-V target specification files to set `"llvm-abiname": "lp64d"`.

Other languages (read: C) usually expose this codegen parameter under a compiler argument like `-mabi=<XYZ>`.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Nov 5, 2019
…excrichton

Allow specifying LLVM's MCTargetOptions::ABIName in target specification files

This addresses rust-lang#65024, as it allows RISC-V target specification files to set `"llvm-abiname": "lp64d"`.

Other languages (read: C) usually expose this codegen parameter under a compiler argument like `-mabi=<XYZ>`.
@archshift
Copy link
Contributor Author

Now that #65953 is in, we can add new target specifications to close this issue.

We might want to add a d or f after the 32 or 64 in the target triple, like so:

  • riscv64dgc-unknown-none-elf
  • riscv32fgc-unknown-none-elf

The alternative is to append hf to the end of the triple, although the fact that not every RV distribution has hard doubles might complicate this. But we might assume that any target has float widths corresponding to the pointer width.

That way, we can specify:

  • riscv64gc-unknown-none-elfhf (lp64d)
  • riscv32gc-unknown-none-elfhf (ilp32f)

Or even:

  • riscv64gc-unknown-linux-gnuhf (lp64d)

@lenary
Copy link
Contributor

lenary commented Nov 25, 2019

It is very unlikely that rustc is doing the correct ABI lowering of calls etc for the C psABI, especially when hard-floats are considered. Just switching on ilp32d/ilp32f/lp64d/lp64f will not be enough.

It has been on my list for a while to check the ABI lowering in rustc so that it matches the psABI, which will potentially require backwards-incompatible changes. I hope to get to this soon (there's other RISC-V LLVM work on my plate first).

@lenary
Copy link
Contributor

lenary commented Mar 30, 2020

Rustc should now be doing the correct ABI lowering of calls in the C psABI, including hard-float support (since #68452).

A target spec for rv64gc + lp64d (targetting linux) has been added in the form of riscv64gc-unknown-linux-gnu which should be exactly what's needed for linux platform support.

@archshift
Copy link
Contributor Author

I suppose this can be closed now?

@sanxiyn
Copy link
Member

sanxiyn commented Nov 10, 2021

riscv64gc-unknown-linux-gnu target is hard-float with lp64d ABI. Closing.

@sanxiyn sanxiyn closed this as completed Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-feature-request Category: A feature request, i.e: not implemented / a PR. O-riscv Target: RISC-V architecture T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants