Whereas before I had created a cheeky Rust demo on Dreamcast with the limited gccrs, I have now managed to get rustc_codegen_gcc, the official Rust compiler's codegen backend leveraging GCC's libgccjit to generate code, working to target the Dreamcast. This means we can now use the real rustc compiler and borrow checker, we have access to all of libcore and liballoc, etc. We can now write bare metal Rust programs and call KOS and kos-ports libraries via C FFI.
I've created a full tutorial on how to set everything up here: https://dreamcast.wiki/Rust_on_Dreamcast
This includes patches to build a compatible toolchain and scripts to set up the compiler and operate it.
With this, we can create Dreamcast crates with the Cargo build system targetting KallistiOS on Dreamcast. Examples are included!
Rust projects on Dreamcast now a reality with rustc_codegen_gcc
-
- DCEmu Webmaster
- Posts: 16389
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Wed Mar 14, 2001 6:00 pm
- Location: New Orleans, LA
- Has thanked: 119 times
- Been thanked: 92 times
- Contact:
-
- DCEmu Cool Newbie
- Posts: 16
- Joined: Tue Feb 13, 2024 2:33 am
- Has thanked: 1 time
- Been thanked: 8 times
Re: Rust projects on Dreamcast now a reality with rustc_codegen_gcc
That's fantastic. Thanks a lot for the detailed write-up.
Let's try to get as much of that upstreamed as possible.
Let's try to get as much of that upstreamed as possible.
-
- DCEmu Webmaster
- Posts: 16389
- Joined: Wed Mar 14, 2001 6:00 pm
- Location: New Orleans, LA
- Has thanked: 119 times
- Been thanked: 92 times
- Contact:
Re: Rust projects on Dreamcast now a reality with rustc_codegen_gcc
First update!
- Eliminated the need to add the .cargo/config file to add in the linker wrapper in your projects, this is now handled for you automatically by the cargo-dc script
-- Removed these from the examples
-- Removed this from the guide
- Now added the ability to pass arguments to GCC directly through a CG_GCCFLAGS environment variable
-- The scripts will re-format the flags with the llvm-args prefix rustc_codegen_gcc wants, and pass these through to libgccjit for you
-- Works for both cargo-dc and rustc-dc
-- Example:
-- There are some flags set by default, but if you want to adjust the defaults you can do so in the common.sh file
-- Added this to the guide
- A patch that hardcoded passing on the floating point precision setting was removed, now only 3 total patches remain
-- One for libgccjit building incorrectly on certain targets has already been submitted upstream
-- One is for disabling libstd and will be eliminated if we add KOS to libstd, which I intend to do in due time
-- One is for SuperH arch and will be eliminated if the arch is added to Rust, which cbmuser seems eager to do ASAP
- Eliminated the need to add the .cargo/config file to add in the linker wrapper in your projects, this is now handled for you automatically by the cargo-dc script
-- Removed these from the examples
-- Removed this from the guide
- Now added the ability to pass arguments to GCC directly through a CG_GCCFLAGS environment variable
-- The scripts will re-format the flags with the llvm-args prefix rustc_codegen_gcc wants, and pass these through to libgccjit for you
-- Works for both cargo-dc and rustc-dc
-- Example:
Code: Select all
CG_GCCFLAGS="-freorder-blocks-algorithm=simple" cargo-dc build
-- Added this to the guide
- A patch that hardcoded passing on the floating point precision setting was removed, now only 3 total patches remain
-- One for libgccjit building incorrectly on certain targets has already been submitted upstream
-- One is for disabling libstd and will be eliminated if we add KOS to libstd, which I intend to do in due time
-- One is for SuperH arch and will be eliminated if the arch is added to Rust, which cbmuser seems eager to do ASAP
It's thinking...