build: produce a universal (arm64 + x86_64) macOS slice - #59
Open
prakashrj wants to merge 1 commit into
Open
Conversation
The macOS build is Apple-Silicon-only by construction, so an app embedding
TailscaleKit cannot produce a universal macOS release build:
TailscaleKit.xcframework is missing architecture(s) required by this target
(x86_64), but may still be link-compatible
Two places pin it. The root Makefile's `c-archive` builds libtailscale.a for
the host arch, because no GOARCH is set. And swift/Makefile's `macos` target
passes -destination 'platform=macOS,arch=arm64', so the framework is built for
one arch even if the archive were fat.
The iOS Simulator target already solves exactly this: separate GOARCH=arm64 and
GOARCH=amd64 c-archives joined with lipo, each built through a clangwrap script
that pins the SDK and arch. This mirrors that pattern for macOS rather than
inventing a second approach:
- clangwrap-macos-arm.sh / clangwrap-macos-x86.sh, matching the existing
ios-sim wrappers and pinning -mmacos-version-min to MACOS_TARGET (15.0)
- libtailscale_macos_arm64.a and libtailscale_macos_x86_64.a
- c-archive-macos-universal, which lipos them into libtailscale.a
- swift/Makefile's macos target now uses c-archive-macos-universal and builds
with -destination 'generic/platform=macOS' ARCHS="arm64 x86_64"
`make c-archive` is untouched, so anything building for the host only keeps its
current behaviour.
Verified on an Apple Silicon host:
lipo -info libtailscale.a
-> Architectures in the fat file: x86_64 arm64
make -C swift macos
lipo -info swift/build/Build/Products/Release/TailscaleKit.framework/Versions/A/TailscaleKit
-> Architectures in the fat file: x86_64 arm64
Updates tailscale/tailscale#20992
7 tasks
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 macOS build is Apple-Silicon-only by construction, so an app embedding
TailscaleKitcan't produce a universal macOS release build:Two places pin it:
Makefile—c-archivelibtailscale.afor the host arch; noGOARCHis setswift/Makefile—macos-destination 'platform=macOS,arch=arm64', so the framework is one arch even if the archive were fatApproach
The iOS Simulator target already solves exactly this — separate
GOARCH=arm64andGOARCH=amd64c-archives joined withlipo, each built through a clangwrap script pinning SDK and arch. This mirrors that pattern rather than inventing a second one:clangwrap-macos-arm.sh/clangwrap-macos-x86.sh, matching the existingios-simwrappers and pinning-mmacos-version-mintoMACOS_TARGET(15.0)libtailscale_macos_arm64.aandlibtailscale_macos_x86_64.ac-archive-macos-universal, whichlipos them intolibtailscale.aswift/Makefile'smacostarget uses it, and builds with-destination 'generic/platform=macOS' ARCHS="arm64 x86_64"make c-archiveis untouched, so anything building for the host only keeps its current behaviour.Verified
On an Apple Silicon host:
Both the archive and the built framework come out universal.
Scope
4 files, +13 −2, two of them new scripts. No existing target changes behaviour.
Updates tailscale/tailscale#20992
Related: #57 (privacy manifests, macOS slice, upload validator) and #58 (LocalAPI actor deadlock), from the same work.