scratchfoundation / scratch-link

Device interoperability layer for Windows and MacOS
BSD 3-Clause "New" or "Revised" License
102 stars 83 forks source link

Scratch Link does not build for Apple Silicon / M1 #186

Open cwillisf opened 3 years ago

cwillisf commented 3 years ago

Expected Behavior

Scratch Link should run natively on all current and recent macOS machines.

Actual Behavior

Scratch Link runs natively on Intel-based macOS, but only runs under Rosetta 2 on Apple M1 machines.

Discussion

Swift 5.3, which comes with Xcode 12, is required for native Apple M1 support. In theory, we should be able to add --arch x86_64 --arch arm64 to the swift build command line in order to build a "universal binary" which natively supports both architectures.

Unfortunately, the networking libraries we use, PerfectHTTPServer and PerfectWebSockets, do not build for M1 on Swift 5.3 due to some incompatibilities. It appears that PerfectlySoft, the group behind these libraries, has disbanded and the libraries are no longer maintained. This is to say: it's not just a matter of updating to the latest version of these libraries.

While we need more testing, it appears that Scratch Link runs successfully through Rosetta 2. For now, I recommend that we take advantage of this and take our time deciding how best to support M1 natively.

cwillisf commented 3 years ago

Investigation notes: what if we try to fix the Perfect networking libraries ourselves?

The good news is that it appears that the code changes would be relatively small. The bad news is that the necessary change is in a core library in the Perfect family of libraries. This is bad news because in order to fix the issue it appears we'd need to fork quite a few of their repositories for no other reason than to adjust their dependency tree to use our version of a "leaf" module.

Specifically, the problem centers around a call to vsyslog in PerfectLib's logging code.

Summary:

cwillisf commented 3 years ago

Investigation of alternative networking libraries has been moved to #187

cikichen commented 2 years ago

Cannot convert value of type 'CVaListPointer' to expected argument type '__darwin_va_list?' (aka 'Optional<UnsafeMutablePointer>')

Apple M1