Retrocomputing: What would it take to add PowerPC/Darwin9 support?

Please indulge my pipe dream for a moment :pray:

If I wanted to be able to target PowerPC / Darwin9 (Leopard), what would need to be added to the Swift compiler?

Would it be enough to add PowerPC / Darwin9 support to LLVM, and then the Swift infrastructure would automatically gain that target? Or would additional work be needed specific to the Swift compiler?

Thanks!

You probably couldn't get Objective-C support in this theoretical build of Swift because that requires support form the Objective-C Runtime support. But I'm sure it wouldn't be that hard considering someone ported a lot of Swift to Mac OS 9 at one point.

1 Like

Have you seen this? Swift on Mac OS 9 // -dealloc

3 Likes

I have, what an excellent hack! His post is what made me think this might be doable.

2 Likes

Aside from reviving LLVM's support for PowerPC Darwin, it's likely you'll have to modify the Swift runtime a bit; you could disable ObjC interop to avoid depending on the integration we get in newer versions of libobjc, but the runtime code also generally takes for granted a newer version of the C++ standard library than shipped in those older OSes. You might be able to treat it as an Embedded Swift target if you want to subset out any runtime support at all.

2 Likes

Yep, these days I’d probably start from embedded, so I wouldn’t have to chop the stdlib down and build the runtime up myself like I did with the hack. As has been said, you won’t get free ObjC interop, so no backporting Swift AppKit apps. You probably can get CF interop to work the same way I did, but that might take the wind out of your sails somewhat.

  • Get modern Clang to compile for powerpc-apple-darwin again
  • Go find all the places in the Swift codebase that use “darwin” as a shorthand for “has ObjC interop”. I got to skip this because I used “aix” as the name of the OS. (But you’d get to skip a lot of things I had to deal with about XCOFF.)
  • Make some module maps for the old OS SDKs, or find an SDK that still declares ppc things but is new enough for module maps.
  • Turn things off in the compiler until you have a subset that works. :upside_down_face: Get optimizations-on, no-debug-info working first, because it’s closest to what you would have had with C.

P.S. …it’s possible that you could get ObjC messages to work, just not subclassing. But the compiler right now only has “ObjC is present” and “ObjC is absent” modes, so this would be yet more work to disentangle.

4 Likes