Install the RISC-V target using rustup and compile your code with the --target flag.
-
Add the RISC-V target to your toolchain.
rustup target add riscv64gc-unknown-none-elf -
Compile your project for the RISC-V architecture.
cargo build --target riscv64gc-unknown-none-elf -
Run tests for the target if a simulator is available.
cargo test --target riscv64gc-unknown-none-elf
Note: The riscv64im-unknown-none-elf target is also available as a tier 3 option in Rust 1.94.0.