Rust Hello World on a PSP
github.com
github.com
extern {
fn pspDebugScreenInit();
fn pspDebugScreenPrintf(format: *const u8, ...);
}
So the actual rust code basically does nothing besides calling a bunch of external C functions. The real work was probably in the rustc code itself to add a new target for the PSP.I've written a bit of low level rust code and it's quite pleasant to work with. For one, it's very easy to crosscompile: all targets are included by default, so if you have a rustc installed you can probably generate code for arm or whatever (although you will have to crosscompile the various libs you need, but in the case of a bare metal application it's probably only libcore).
Then it's pretty much like working with C. I think my main annoyance is that pointer arithmetics is a pity to work with at the moment (you can't even use it in constexpr which is sometimes hard to work around). Oh and you code breaks every other day when you update rustc, but that's life on the edge :)
I think this is still really cool - it shows how easy it is to interface Rust with C code and how it's possible to configure Rust for new foreign build targets.
When I first learned Python years ago, I was told that I can specialize some parts of my Python program using C code to speed up the entire application. However, I've never tried that. Maybe it seemed too complicated to me? I don't know, but it just haven't made my mind go.
The official docs are nice: https://docs.python.org/2/extending/extending.html
I know people like O(1) indexing into strings, but I'm unconvinced it's so useful to totally fuck up your string implementation. Java, Windows and .Net have the excuse of being thought up before Unicode was over 16-bits so it's slightly excusable (but still a bad tradeoff for many, many, applications, probably the majority of server apps).
That was my first experience with C before I knew what C was. It also was an excuse to finally just use linux instead of whacky cygwin.
And if not (I suspect it could have something to do with kernel-specific stuff), then shouldn't there be some intermediate kernel-API translator that would make the process of porting the compiler more easy?
https://github.com/luqmana/rust-psp-hello/blob/master/psp.js...
Basically any compiler supporting MIPS-EABI-ELF can be made to generate PSP executables with the use of the ELF-to-PRX tools from the open-source PSP toolchain.
The PSP does support some special instructions (a VFPU and some "allegrex extensions") but they aren't necessary to make working binaries - just for performance.