Replies: 2 comments 10 replies
-
Unfortunately, this is exactly what's going on here. It uses XCOFF instead of ELF. When classic MacOS was first ported to PowerPC, Apple used the compiler toolchain from IBM's AIX operating system, which uses the XCOFF object format instead of ELF. Then they added the PEF format on top of that. So And even more unfortunately, the solution is not a simple file format conversion, the ABI is different, as well. In fact, the classic MacOS ABI and the 32-bit AIX ABI are very similar to the 64bit ELF ABI, but quite different from what is usually in 32bit ELF files. IBM seems to have recently contributed XCOFF support to LLVM. I haven't checked yet, but I assume that's only for 64bit mode so far. It might also be possible to implement an ELF loader for classic MacOS instead.... |
Beta Was this translation helpful? Give feedback.
-
Any updates? There seem to be a lot of Rust GCC compilers on Github now. |
Beta Was this translation helpful? Give feedback.
-
So, because I apparently don't have enough spare time projects in my life, and perhaps taking this blog post as a challenge, I decided to try and tell Rust how to use the Retro68 toolchain to build classic Mac OS apps.
So far, I've managed to get it to spit out PPC objects using the following target file:
(Ignore everything after
eh-frame-header
, that is me flipping random switches as a debugging mechanism)The
linker
parameter in this case specifically refers to the resulting binary I got after building the Retro68 toolchain under WSL (which I've put in myPATH
). I also have a bare-minimumno_std
project just to verify that the build system is working (I'll have to write Toolbox bindings later on for this to actually be useful). When I build that bare-minimum project, I get this error out ofcargo
:As far as I can tell, the file being complained about is a valid ELF file (I checked with
readelf
), and contains code for the given architecture... but I've no idea if the linker is even supposed to accept ELF files at this stage. There's this makefile in one of the sample applications that seemed to indicate that I was on the right track (and Grand Star, the Wii Homebrew port of Rust, does something similar).However, it turns out that said Makefile isn't actually in use, as the rest of the project uses CMake, and I can't seem to find the actual loader configuration in there. Peeking into the actual compiled example programs, they also have PEF and XCOFF files, which are the native executable formats PowerPC Macs want to work with. The way I was assuming this all went together was:
and that with some clever target file and Cargo configuration I could change that to
For the record, using gcc's linker with rustc is a supported configuration, as far as I could tell. However, the Retro86 GCC doesn't seem to like rustc's object files, for one of two possible reasons:
rustc
(even though it's a valid ELF file?)I'm not sure which is which, so I figured I'd bring up my progress here and ask if I'm anywhere close to the right track.
Beta Was this translation helpful? Give feedback.
All reactions