Rust for Nintendo GameCube

Howdy! I'm new here and recently decided to start learning Rust. I'm really excited to get into this ecosystem and start developing software! My background is mostly in scripting with bash, design and digital art, and 3D graphics.

I'm also into retro game consoles. Lately, I've been wondering how feasible it would be to get Rust compiling for the Nintendo GameCube. The GameCube is an embedded home console device circa 2001 with a 485 MHz 32-bit PowerPC 750 "Gekko" CPU with some special enhancements for fast vector processing. It has 24 MB or SRAM, 16 MB of "ARAM" (dedicated RAM for fast asynchronous audio processing), and a custom fixed-function graphics chip called the "GX".

Honestly, I feel a system like this would be an ideal candidate for learning Rust, as my interest is primarily in doing 3D graphics and game engine development. How much work would it take to get Rust to compile on a system such as this? From what I can gather asking AI, Rust at least partially relies on SPIRV LLVM for compiling, which already supports the GameCube, so theoretically Rust wouldn't be impossible to port over. The hard part would maybe be getting it to play well with the GameCube C libraries like LibOGC2? The benefit of getting it compiling on the GameCube is that getting it to work on the Wii would basically be free as they are essentially the same hardware!

I thought I'd come here and ask about it since I'm just getting into systems programming. I think it would be really cool if we get Rust compiling for the GameCube as I'd personally love to learn that way. I have a few ideas in mind for software projects I'd like to tackle on the GameCube, and I'd love to do that in Rust if that is something feasible in the near future.

Is anybody interested in getting Rust to target a system like this? How much work would that entail? Is this likely to happen? Is this something someone like me would be capable of, given my inexperience with low level programming?

Thanks for reading!
Cheers

I've got no idea where AI got SPIRV from, maybe for the GPU backends? (eg. PTX for Nvidia, GCN for AMD) But I'm pretty doubtful, there's little reason when it already has it's own IR representation....

Theoretically, since Rustc is built on LLVM, it's possible to compile for a PPC target, but it's kind of a pain to get a working setup in most cases, if nobody has done the work for you already. I couldn't find any crate providing out of the box support with a quick look, but it's quite possible there's some blog it there with detailed instructions.

Specifically, if you're doing this yourself, first you need to get code for the CPU generated; there's a bunch of PPC targets on the Rust platform support list:

but if you're trying to run directly on the metal (which is I assume still true as of GameCube? Looks like it from a quick search) you would in theory need a "unknown" / "none" target, and it doesn't look like there's a defined one there already, so you're now looking at custom targets:

As you can see, there's pretty minimal documentation since it's a pretty exposure of the LLVM target concepts, that are really intended for compiler engineers. Certainly not an easy on ramp for those just getting started.

That said, you can possibly just pick one of the existing PPC targets and get lucky, that would likely depend on the details of the BIOS/interrupt interaction with that target, if there's any calling conventions you need to follow etc., though you would have to figure out linking to a bootable image rather than letting Rustc do that for you. I doubt there's anything as dramatic as the x86 real vs protected mode code differences!

After you have it generating code for the CPU target, you then will need to figure out how to talk to everything at the bare metal level, likely including generating rendering instructions, from whatever reverse engineered documentation is out there.

2 Likes

Thanks for taking the time to respond!

I definitely would be targeting bare metal (GameCube has no OS) so it sounds like that would be a bit of a challenge. There is RedoxOS which runs on bare metal and is mostly Rust. Wouldn't that be a "unknown/none" target? Could their solution (or something similar) possibly work for the GameCube?

Also, sorry for the mention of SPIRV! I was working on a Minecraft Vulkan project and totally mistyped! I meant to say LLVM, lol!

It definitely sounds like this is doable, but it also sounds like it would benefit from (or require) an expert working on this project.

Yeah, I've had about a decade of (mostly personal) Rust experience and have bounced off messing with targets a few times, even when they're actually supported ones that are just without binaries. This is definitely not an area for the faint hearted!

But there are still a lot of resources out there, their just scattered and incomplete. I'm sure with enough dedication it's something you could push through, it's just a matter of if you want to spend your time creating a GameCube SDK rather than games.

You'll probably want to use the linker from devkitPPC, which is the canonical C development environment for GC home brew.