Using Rust for Dreamcast
If all went well, you will now have a working Rust for Dreamcast environment!
- cargo can be invoked to target Dreamcast using the
kos-cargo
command.kos-cargo run
can be used to build and run code on a Dreamcast console using dcload-ip or dcload-serial. You will need to set up theKOS_LOADER
variable with the necessary command in the/opt/toolchains/dc/rust/misc/environ.sh
file (and then re-source the file for the change to take effect).
- rustc can be invoked to target Dreamcast using the
kos-rustc
command.
Using the libc crate with KallistiOS
If any of the crates in your project's dependency tree requires the libc crate, you will need to override fetching the default crate with our custom libc crate with KallistiOS/Dreamcast definitions. This custom version was copied to /opt/toolchains/dc/rust/libc
when building the Rust sysroot earlier. Add the following text to your Cargo.toml
:
[patch.crates-io]
libc = { path = "/opt/toolchains/dc/rust/libc" }
Adjusting build flags
Build settings can be adjusted through the KOS_RCG_RUSTFLAGS
variable in the environ.sh
file under the ### Rust Flags
section.
- To pass arguments to the rustc frontend, e.g. to disable debug assertions:
export KOS_RCG_RUSTFLAGS="${KOS_RCG_RUSTFLAGS} -Cdebug-assertions=no"
- To pass arguments to the GCC backend, e.g. to enable the
-freorder-blocks-algorithm=simple
optimization for Rust code:
export KOS_RCG_RUSTFLAGS="${KOS_RCG_RUSTFLAGS} -Cllvm-args=-freorder-blocks-algorithm=simple"