-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add target page for riscv64gc-unknown-linux-gnu #127490
Merged
bors
merged 2 commits into
rust-lang:master
from
ferrocene:hoverbear/add-riscv64gc-unknown-linux-target-page
Aug 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/doc/rustc/src/platform-support/riscv64gc-unknown-linux-gnu.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# `riscv64gc-unknown-linux-gnu` | ||
|
||
**Tier: 2 (with Host Tools)** | ||
|
||
RISC-V targets using the *RV64I* base instruction set with the *G* collection of extensions, as well as the *C* extension. | ||
|
||
|
||
## Target maintainers | ||
|
||
- TODO | ||
|
||
|
||
## Requirements | ||
|
||
This target requires: | ||
|
||
* Linux Kernel version 4.20 or later | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may need to raise this to 6.6 given #117022 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd leave that decision outside of a purely documentation PR. |
||
* glibc 2.17 or later | ||
|
||
|
||
## Building the target | ||
|
||
These targets are distributed through `rustup`, and otherwise require no | ||
special configuration. | ||
|
||
If you need to build your own Rust for some reason though, the targets can be | ||
enabled in `config.toml`. For example: | ||
|
||
```toml | ||
[build] | ||
target = ["riscv64gc-unknown-linux-gnu"] | ||
``` | ||
|
||
|
||
## Building Rust programs | ||
|
||
|
||
On a RISC-V host, the `riscv64gc-unknown-linux-gnu` target should be automatically | ||
installed and used by default. | ||
|
||
On a non-RISC-V host, add the target: | ||
|
||
```bash | ||
rustup target add riscv64gc-unknown-linux-gnu | ||
``` | ||
|
||
Then cross compile crates with: | ||
|
||
```bash | ||
cargo build --target riscv64gc-unknown-linux-gnu | ||
``` | ||
|
||
|
||
## Testing | ||
|
||
There are no special requirements for testing and running the targets. | ||
For testing cross builds on the host, please refer to the "Cross-compilation | ||
toolchains and C code" | ||
section below. | ||
|
||
|
||
## Cross-compilation toolchains and C code | ||
|
||
A RISC-V toolchain can be obtained for Windows/Mac/Linux from the | ||
[`riscv-gnu-toolchain`](https://github.com/riscv-collab/riscv-gnu-toolchain) | ||
repostory. Binaries are available via | ||
[embecosm](https://www.embecosm.com/resources/tool-chain-downloads/#riscv-linux), | ||
and may also be available from your OS's package manager. | ||
|
||
On Ubuntu, a RISC-V toolchain can be installed with: | ||
|
||
```bash | ||
apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross | ||
``` | ||
|
||
Depending on your system, you may need to configure the target to use the GNU | ||
GCC linker. To use it, add the following to your `.cargo/config.toml`: | ||
|
||
```toml | ||
[target.riscv64gc-unknown-linux-gnu] | ||
linker = "riscv64-linux-gnu-gcc" | ||
``` | ||
|
||
If your `riscv64-linux-gnu-*` toolchain is not in your `PATH` you may need to | ||
configure additional settings: | ||
|
||
```toml | ||
[target.riscv64gc-unknown-linux-gnu] | ||
# Adjust the paths to point at your toolchain | ||
cc = "/TOOLCHAIN_PATH/bin/riscv64-linux-gnu-gcc" | ||
cxx = "/TOOLCHAIN_PATH/bin/riscv64-linux-gnu-g++" | ||
ar = "/TOOLCHAIN_PATH/bin/riscv64-linux-gnu-ar" | ||
ranlib = "/TOOLCHAIN_PATH/bin/riscv64-linux-gnu-ranlib" | ||
linker = "/TOOLCHAIN_PATH/bin/riscv64-linux-gnu-gcc" | ||
``` | ||
|
||
To test cross compiled binaries on a non-RISCV-V host, you can use | ||
[`qemu`](https://www.qemu.org/docs/master/system/target-riscv.html). | ||
On Ubuntu, a RISC-V emulator can be obtained with: | ||
|
||
```bash | ||
apt install qemu-system-riscv64 | ||
``` | ||
|
||
Then, in `.cargo/config.toml` set the `runner`: | ||
|
||
```toml | ||
[target.riscv64gc-unknown-linux-gnu] | ||
runner = "qemu-riscv64-static -L /usr/riscv64-linux-gnu -cpu rv64" | ||
``` | ||
|
||
On Mac and Linux, it's also possible to use | ||
[`lima`](https://github.com/lima-vm/lima) to emulate RISC-V in a similar way to | ||
how WSL2 works on Windows: | ||
|
||
```bash | ||
limactl start template://riscv | ||
limactl shell riscv | ||
``` | ||
|
||
Using [Docker (with BuildKit)](https://docs.docker.com/build/buildkit/) the | ||
[`riscv64/ubuntu`](https://hub.docker.com/r/riscv64/ubuntu) image can be used | ||
to buiild or run `riscv64gc-unknown-linux-gnu` binaries. | ||
|
||
```bash | ||
docker run --platform linux/riscv64 -ti --rm --mount "type=bind,src=$(pwd),dst=/checkout" riscv64/ubuntu bash | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see rust-embedded specifies some people that are part of the RISC-V team. I am not sure if this is the same as the target maintainers. If not, maybe they would know who this should be.
CC: @almindor @dkhayes117 @romancardenas @MabezDev @jessebraham
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riscv
is a generic group, for me for example, while I'm happy to look at PRs, 64bit risc is something I cannot test since I currently do not own such hardware. Same goes for-linux
targets, I only have bare-metal 32bit MCUs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi folks. As discussed separately with @Hoverbear, I am happy to help. @Hoverbear: Please let me know if there is anything else needed from me. Also note that there are at least 2 more colleagues who will shortly chime in in this thread who have agreed to be a part of this maintainers group. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to include me as part of this maintainers group :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Count me in here, as a long-time RISC-V toolchain contributor, I am happy to help triage and resolve toolchain compiler issue for RISC-V :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Count me in too.