Rust projects on Dreamcast now a reality with rustc_codegen_gcc

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
|darc|
DCEmu Webmaster
DCEmu Webmaster
Posts: 16375
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: 104 times
Been thanked: 91 times
Contact:

Rust projects on Dreamcast now a reality with rustc_codegen_gcc

Post by |darc| »

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!
It's thinking...
cbmuser
DCEmu Newbie
DCEmu Newbie
Posts: 8
Joined: Tue Feb 13, 2024 2:33 am
Has thanked: 1 time
Been thanked: 7 times

Re: Rust projects on Dreamcast now a reality with rustc_codegen_gcc

Post by cbmuser »

That's fantastic. Thanks a lot for the detailed write-up.

Let's try to get as much of that upstreamed as possible.
|darc|
DCEmu Webmaster
DCEmu Webmaster
Posts: 16375
Joined: Wed Mar 14, 2001 6:00 pm
Location: New Orleans, LA
Has thanked: 104 times
Been thanked: 91 times
Contact:

Re: Rust projects on Dreamcast now a reality with rustc_codegen_gcc

Post by |darc| »

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:

Code: Select all

CG_GCCFLAGS="-freorder-blocks-algorithm=simple" cargo-dc build
-- 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 :)
These users thanked the author |darc| for the post:
cbmuser
It's thinking...
Post Reply