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

**URL:** <https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797>\
**Category:** Compiler\
**Tags:** off-topic\
**Created:** [May 13, 2024, 4:41pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797 "2024-05-13T16:41:21Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepas-everly](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pepas-everly/32/35339_2.png) [@pepas-everly](https://forums.swift.org/u/pepas-everly)\
**Post date:** [May 13, 2024, 4:41pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/1 "2024-05-13T16:41:22Z")

</div>

Please indulge my pipe dream for a moment 🙏

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!

---

<div class="post-metadata">

**Author:** ![austintatious](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@austintatious](https://forums.swift.org/u/austintatious)\
**Post date:** [May 13, 2024, 6:32pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/2 "2024-05-13T18:32:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [May 13, 2024, 7:10pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/3 "2024-05-13T19:10:36Z")

</div>

Have you seen this? [Swift on Mac OS 9 // -dealloc](https://belkadan.com/blog/2020/04/Swift-on-Mac-OS-9/)

---

<div class="post-metadata">

**Author:** ![pepas-everly](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pepas-everly/32/35339_2.png) [@pepas-everly](https://forums.swift.org/u/pepas-everly)\
**Post date:** [May 13, 2024, 9:25pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/4 "2024-05-13T21:25:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [May 13, 2024, 11:51pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/5 "2024-05-13T23:51:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [May 14, 2024, 12:21am UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/6 "2024-05-14T00:21:52Z")

</div>

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. 🙃 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.

---

<div class="post-metadata">

**Author:** ![pepas-everly](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pepas-everly/32/35339_2.png) [@pepas-everly](https://forums.swift.org/u/pepas-everly)\
**Post date:** [May 21, 2024, 5:36pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/7 "2024-05-21T17:36:12Z")

</div>

Thanks so much for the in-depth replies!

I've just recently started looking at Iain Sandoe's fork of LLVM-7.x, the goal of which was to complete the unfinished PowerPC/Darwin work in LLVM. Might be a while before I can circle back around to Swift support 😅

---

<div class="post-metadata">

**Author:** ![turbolent](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/turbolent/32/6562_2.png) [@turbolent](https://forums.swift.org/u/turbolent)\
**Post date:** [May 21, 2024, 9:54pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/8 "2024-05-21T21:54:39Z")

</div>

Not a pipe dream, but a reality! 😉

 ![image](https://global.discourse-cdn.com/swift/original/3X/0/3/03118867a1aa7815cecbad9633f1e7ea0c912882.jpeg)

You can already target Darwin/PowerPC today, see [x.com](https://twitter.com/turbolent/status/1485439938946420736) (and many other systems, see [x.com](https://twitter.com/turbolent/status/1621992945745547264)), by cross-compiling to WebAssembly, and then further compiling to native code, via e.g. [w2c2](https://github.com/turbolent/w2c2), or [wasm2c](https://github.com/WebAssembly/wabt/tree/main/wasm2c).

This requires no changes to the Swift compiler or LLVM.

This approach comes with support for [WASI](https://wasi.dev/) (essentially a POSIX-like/subset API), but you can also import and call "host" C functions. I'm currently working on [GitHub - turbolent/W2C2BridgeGenerator: Generate bindings for w2c2 from a bridgesupport file](https://github.com/turbolent/W2C2BridgeGenerator), a tool that automatically generates bindings for C and Objective-C code, so it's possible to use all Mac OS X frameworks, e.g. AppKit (via [GitHub - turbolent/BridgeSupport-Tiger: Modern BridgeSupport (LLVM/Clang-based), adjusted for Mac OS X Tiger (10.4) and Leopard (10.5)](https://github.com/turbolent/BridgeSupport-Tiger)).

Even small Swift binaries are quite large, as they include the whole Standard Library. Those binaries can be translated to C very quickly with w2c2, but the final compilation with gcc takes quite a while, especially on era-appropriate hardware.

The new Swift [Embedded feature](https://forums.swift.org/t/embedded-swift/67057) greatly improves the size and performance of WebAssembly binaries, see [Some feedback from my short experience with SwiftWasm - #5 by Max\_Desiatov](https://forums.swift.org/t/some-feedback-from-my-short-experience-with-swiftwasm/69605/5). However, this feature is still experimental and seems to have some bugs ([Bug in Embedded/ARC/WebAssembly combination?](https://forums.swift.org/t/bug-in-embedded-arc-webassembly-combination/71967)).

---

<div class="post-metadata">

**Author:** ![pepas-everly](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pepas-everly/32/35339_2.png) [@pepas-everly](https://forums.swift.org/u/pepas-everly)\
**Post date:** [May 22, 2024, 5:07pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/9 "2024-05-22T17:07:31Z")

</div>

omg this is amazing!

---

<div class="post-metadata">

**Author:** ![turbolent](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/turbolent/32/6562_2.png) [@turbolent](https://forums.swift.org/u/turbolent)\
**Post date:** [June 8, 2024, 11:51pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/10 "2024-06-08T23:51:05Z")

</div>

Happy to finally announce TigerSwift:

> <https://x.com/turbolent/status/1799589508473606390>

---

<div class="post-metadata">

**Author:** ![austintatious](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@austintatious](https://forums.swift.org/u/austintatious)\
**Post date:** [June 9, 2024, 2:33am UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/11 "2024-06-09T02:33:40Z")

</div>

Oh my God

---

<div class="post-metadata">

**Author:** ![austintatious](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@austintatious](https://forums.swift.org/u/austintatious)\
**Post date:** [June 9, 2024, 2:50am UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/12 "2024-06-09T02:50:33Z")

</div>

You made this tool work with Rhapsody OS!!!!

---

<div class="post-metadata">

**Author:** ![pepas-everly](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pepas-everly/32/35339_2.png) [@pepas-everly](https://forums.swift.org/u/pepas-everly)\
**Post date:** [June 10, 2024, 4:04pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/13 "2024-06-10T16:04:24Z")

</div>

Bastian is on fire! Wow!

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [June 10, 2024, 7:38pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/14 "2024-06-10T19:38:29Z")

</div>

@jrose What hath you wrought?

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [June 10, 2024, 7:43pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/15 "2024-06-10T19:43:54Z")

</div>

Personally, I'm still hoping to run Swift on my Amiga 500 one day 🤞 Can we get a 68000 backend going?

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [June 10, 2024, 8:03pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/16 "2024-06-10T20:03:25Z")

</div>

I need to look into what @turbolent’s done to make the ObjC parts work, I kinda assumed it just wouldn’t! Though I _did_ say maybe `objc_msgSend` was going to be sufficient…

---

<div class="post-metadata">

**Author:** ![turbolent](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/turbolent/32/6562_2.png) [@turbolent](https://forums.swift.org/u/turbolent)\
**Post date:** [June 10, 2024, 10:24pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/17 "2024-06-10T22:24:58Z")

</div>

> [@jrose](#):
>
> what @turbolent’s done to make the ObjC parts work, I kinda assumed it just wouldn’t!

To be clear, though it is possible to call into Objective-C APIs, this isn't accomplished by getting Swift's Objective-C bridge working.

Instead, [GitHub - turbolent/W2C2BridgeGenerator: Generate bindings for w2c2 from a bridgesupport file](https://github.com/turbolent/W2C2BridgeGenerator) parses [`bridgesupport` files](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/RubyPythonCocoa/Articles/GenerateFrameworkMetadata.html), which describe Objective-C classes and methods, and generates C functions for all Objective-C methods.  
The bridge generator also optionally translates between little-endian and big-endian (WebAssembly is little-endian), so that the bridging code and application also works on PowerPC systems.

---

<div class="post-metadata">

**Author:** ![turbolent](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/turbolent/32/6562_2.png) [@turbolent](https://forums.swift.org/u/turbolent)\
**Post date:** [June 10, 2024, 10:26pm UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/18 "2024-06-10T22:26:19Z")

</div>

With w2c2, you should be able to run Swift on Amiga OS. I have not tried it myself, but as long as a C89 compiler is available, it should be little effort.

---

<div class="post-metadata">

**Author:** ![Jens\_Nerup](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jens_nerup/32/374_2.png) [@Jens\_Nerup](https://forums.swift.org/u/Jens_Nerup)\
**Post date:** [June 13, 2024, 6:37am UTC](https://forums.swift.org/t/retrocomputing-what-would-it-take-to-add-powerpc-darwin9-support/71797/19 "2024-06-13T06:37:07Z")

</div>

It would be so awesome if PowerPC/Darwin support could return to LLVM. Please let us know if you are planing some kind of GitHub Sponsor.
