Skip to content

Commit 9ba7852

Browse files
committed
refactor readme
1 parent 2846968 commit 9ba7852

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/doc/rustc/src/platform-support/riscv64im-unknown-none-elf.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Bare-metal target for RISC-V CPUs with the RV64IM ISA.
1212

1313
This target is cross-compiled and uses static linking. The target supports `core` and `alloc`, but not `std`.
1414

15-
The target does not support atomic compare-and-swap operations, as the RV64IM ISA lacks the "A" (Atomics) extension. Atomic operations are emulated using the `+forced-atomics` feature.
15+
As the RV64IM ISA lacks the "A" (Atomics) extension, atomic operations are emulated using the `+forced-atomics` feature.
1616

1717
No external toolchain is required and the default `rust-lld` linker works, but you must specify a linker script. The [`riscv-rt`] crate provides suitable linker scripts. The [`riscv-rust-quickstart`] repository gives examples of RISC-V bare-metal projects.
1818

@@ -21,34 +21,27 @@ No external toolchain is required and the default `rust-lld` linker works, but y
2121

2222
## Building the target
2323

24-
This target is included in Rust and can be installed via `rustup`:
24+
You can build Rust with support for the target by adding it to the `target` list in `bootstrap.toml`:
2525

26-
```bash
27-
rustup target add riscv64im-unknown-none-elf
26+
```toml
27+
[build]
28+
target = ["riscv64im-unknown-none-elf"]
2829
```
2930

30-
## Building Rust programs
31-
32-
Build using the standard Cargo workflow:
31+
Alternatively, you can use the `-Z build-std` flag to build the standard library on-demand:
3332

3433
```bash
35-
cargo build --target riscv64im-unknown-none-elf
34+
cargo build -Z build-std=core,alloc --target riscv64im-unknown-none-elf
3635
```
3736

38-
You will need to provide a linker script. The [`riscv-rt`] crate handles this automatically when used as a dependency.
37+
## Building Rust programs
38+
39+
Rust does not yet ship pre-compiled artifacts for this target. To compile for this target (see "Building the target" above)
3940

4041
## Testing
4142

4243
This is a cross-compiled `no-std` target, which must be run either in a simulator or by programming onto suitable hardware. It is not possible to run the Rust test-suite on this target.
4344

44-
You can test the target in QEMU with:
45-
46-
```bash
47-
qemu-system-riscv64 -machine virt -cpu rv64,a=false,c=false -nographic -semihosting -kernel your-binary
48-
```
49-
50-
Note: You must explicitly disable the 'a' (atomics) and 'c' (compressed) extensions when using QEMU to accurately emulate an RV64IM-only CPU.
51-
5245
## Cross-compilation toolchains and C code
5346

5447
This target supports C code. If interlinking with C or C++, you may need to use `riscv64-unknown-elf-gcc` with the appropriate `-march=rv64im -mabi=lp64` flags as a linker instead of `rust-lld`.

0 commit comments

Comments
 (0)