Tears of Joy
What a difference 24 hours makes! Last night around this time, I was cursing at "Russell" because it was crashing in the bowels of the OS with some 10-level deep unlabeled stack frame when run in the debugger. I happened to launch it from the FInder, and the resulting crash log had a fully labelled stack frame, and the top was in malloc, so memory corruption is the likely candidate. This is where my frustration started - since "Russell" was a CFM app, CodeWarrior is too dumb to give a proper stack trace if you crash in the bowels of the OS. Drastic measures were needed.
To that end, I dropped everything and immediately put "Russell" on the fast-path to Mach-O. Doing so meant bringing over our entire Westlake porting library to Mach-O as well, and there has been talk about how this could end up a horrific task resulting in lots of dead bodies littering waterways. Still, I figured I'd give it a shot over the weekend. If no progress was made, I hadn't lost much.
So 2 hours ago, I finished and ran "Russell" as a Mach-O app for the first time. Because "Russell" has a 2 hour 15 minute compile time, it had taken longer than I would have liked to get the Mach-O version built. Because of that, I opted to build a "precompiled header" version towards the end because of all the full recompiles I kept having to do today. Naturally, when I ran it for the first time as Mach-O it crashed before getting to main as it did when I built the CFM version with precompiled headers. But by god, it was compiling and linking.
Then disaster struck. I had quit CodeWarrior and relaunched it, but now the project file for the game would not open, giving some cryptic error message. Some googling turned up a hint that this message would happen on very large project files, for which Russell qualified in spades - it contains 1000+ source files. So now I had nothing.
Desperate, I rebuilt the main project file, this time using only my precompiled header target. Because of the way I built the precompiled header version before, I included the bulk of the PC code in subprojects so the header magic would do its thing. More to the point, recreating the project would be a lot simpler if I stuck to that as a starting point, since it would mean I could just include the subproject files rather than including 1000+ source files in a mega-project like I had before.
Success! It took me 20 minutes of balls-to-the-wall scrambling, but I whipped it up pretty quick. What's more, inspiration struck me - perhaps my precompiled header woes were a result of the intermediate libraries being called in the wrong order. I rearranged the linking order and like magic, my precompiled header build ran as good as the app I'd built just 24 hours before, only now it takes 15 minutes to compile instead of 2:15. w00t!
Unluckily for me, I have to spend some time tomorrow on another project. But today's good tidings more than make up for that.