Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub(crate) fn target() -> Target {
llvm_target: "riscv64-unknown-linux-gnu".into(),
metadata: TargetMetadata {
description: Some("RISC-V Linux (kernel 6.8.0, glibc 2.39)".into()),
tier: Some(3),
host_tools: Some(true),
tier: Some(2),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
Expand Down
8 changes: 6 additions & 2 deletions src/ci/docker/host-x86_64/dist-riscv64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ ENV PATH=$PATH:/x-tools/riscv64-unknown-linux-gnu/bin

ENV CC_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \
AR_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-ar \
CXX_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++
CXX_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++ \
CC_riscv64a23_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \
AR_riscv64a23_unknown_linux_gnu=riscv64-unknown-linux-gnu-ar \
CXX_riscv64a23_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++

ENV HOSTS=riscv64gc-unknown-linux-gnu
ENV TARGETS=riscv64gc-unknown-linux-gnu,riscv64a23-unknown-linux-gnu

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs
ENV SCRIPT python3 ../x.py dist --target $HOSTS --host $HOSTS
ENV SCRIPT python3 ../x.py dist --target $TARGETS --host $HOSTS
20 changes: 11 additions & 9 deletions src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `riscv64a23-unknown-linux-gnu`

**Tier: 3**
**Tier: 2 (without Host Tools)**

RISC-V target using the ratified [RVA23 Profile](https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc).
This target will enable all mandary features of rva23u64 by default.
Expand All @@ -18,24 +18,26 @@ Other platforms may work, but are not tested. Please contanct if you encounter a

## Building the target

Tier-3 target is not distributed through `rustup`.

You need to build your own Rust, the target can be build with:
Tier-2 targets are distributed through `rustup`. Install the target with:

```bash
./x build --target riscv64a23-unknown-linux-gnu
rustup target add riscv64a23-unknown-linux-gnu
```

## Building Rust programs

Add the toolchain:
Cross compile crates with:

```bash
rustup toolchain link rva23-toolchain {path-to-rust}/build/host/stage2
cargo build --target=riscv64a23-unknown-linux-gnu
```

Then cross compile crates with:
For cross-compilation, you may need to install the appropriate linker:

```bash
RUSTFLAGS="-C linker=riscv64-linux-gnu-gcc" cargo +rva23-toolchain build --target=riscv64a23-unknown-linux-gnu
# Ubuntu/Debian
sudo apt-get install gcc-riscv64-linux-gnu

# Then set the linker
RUSTFLAGS="-C linker=riscv64-linux-gnu-gcc" cargo build --target=riscv64a23-unknown-linux-gnu
Copy link
Member

@Urgau Urgau Nov 3, 2025

Choose a reason for hiding this comment

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

Does the target work with lld? If so, it may be better to set rust-lld as the default linker instead asking users to use an external linker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review!
This target works with rust-lld. From my understanding, the default linker should be configured by targets that provide host tools for cross-compilation, rather than by the target itself. If I'm wrong about this, please share more guidance.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are all bare-metal targets. In contrast, Linux targets like riscv64gc-unknown-linux-gnu, x86_64-unknown-linux-gnu, and aarch64-unknown-linux-gnu do not set rust-lld as default.

So I'm quite confused now.

```
Loading