Repository navigation
fix(build): compile native Swift helpers as universal arm64+x86_64 binaries - #638
Open
YuriNachos wants to merge 1 commit into
Open
YuriNachos wants to merge 1 commit into
YuriNachos wants to merge 1 commit into
Conversation
Author
|
I've had this one in mind since #463 sorted esbuild's native binary for both architectures — the Swift helpers were the remaining piece building single-arch, and this PR closes that gap for arm64+x86_64. Is there anything you'd like from my side to move it toward review, such as a verified Intel build or a rebase onto the latest main? Whatever helps, I'm on it. If a smaller change is an easier entry point, #639, #640 and #642 are open as well, and I'd gladly prioritise whichever is most useful. |
…naries The Swift-driver build emitted single-arch arm64 slices, so Intel Macs hit 'bad CPU type in executable' (SuperCmdLabs#634). Swift's driver rejects -arch, so compile arm64 and x86_64 as separate slices (targeted to macos11) and merge them with lipo -create into a universal Mach-O. Per-arch slices are cleaned up in a finally.
YuriNachos
force-pushed
the
YuriNachos/r3-supercmd
branch
from
August 13, 2026 18:26
47fd5e9 to
3131260
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 15 native Swift helper binaries built by
scripts/build-native.mjs(get-selected-text,color-picker,screen-ocr,snippet-expander, …) were compiled as single-arch arm64 executables, so on Intel Macs every feature that shells out to one of them fails withbad CPU type in executable(#634). The HyperKey monitor binary thatsrc/main/main.tscompiles at runtime had the same single-arch problem.Solution
Swift's driver rejects the
-archflag, so the usual "compile once with multiple-archflags" path does not work for Swift sources. Instead,scripts/build-native.mjsnow:arm64-apple-macos11, once targetingx86_64-apple-macos11(the Swift sources themselves are unchanged; only the deployment target and the second arch slice are added).lipo -createinto the final universal (arm64 + x86_64) Mach-O binary.finally, so a failed arch build doesn't leave stale slices behind.ensureHyperKeyMonitorBinaryinsrc/main/main.tsgets the same slice-and-lipo treatment, with one difference: the host-arch slice is mandatory, while the second slice is best-effort — on a toolchain that cannot cross-compile (e.g. an Intel Mac with only Command Line Tools) it falls back to a working host-arch binary instead of disabling HyperKey.macos11(Big Sur) is the deployment floor — the arm64 minimum and a broad floor for Intel Macs.Testing
npm test(node --test scripts/test-*.mjs) — 96 passed, 0 failed, including the newscripts/test-native-universal-arch.mjs, which asserts that each built helper is universal (lipo -archsreports botharm64andx86_64). The new tests skip on non-macOS hosts, where the native binaries are not built andlipodoes not exist.node scripts/build-native.mjs(build:native) — completes clean; the produced helpers are universal.npm run build(fullbuild:main+build:renderer+build:native) — green.Notes
native_helpers.node) is unaffected — it is already handled by the existing arch-aware build path; only the Swift helper binaries needed the universal treatment.whisper-transcriber,soulver,parakeet) are out of scope here.