Skip to content

build: produce a universal (arm64 + x86_64) macOS slice - #59

Open
prakashrj wants to merge 1 commit into
tailscale:mainfrom
indiagrams:macos-universal-slice
Open

build: produce a universal (arm64 + x86_64) macOS slice#59
prakashrj wants to merge 1 commit into
tailscale:mainfrom
indiagrams:macos-universal-slice

Conversation

@prakashrj

Copy link
Copy Markdown

Problem

The macOS build is Apple-Silicon-only by construction, so an app embedding TailscaleKit can't 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:

Where What
root Makefilec-archive builds libtailscale.a for the host arch; no GOARCH is set
swift/Makefilemacos -destination 'platform=macOS,arch=arm64', so the framework is one arch even if the archive were fat

Approach

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 pinning SDK and arch. This mirrors that pattern rather than inventing a second one:

  • 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 uses it, 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: libtailscale.a are: x86_64 arm64

$ make -C swift macos
$ lipo -info swift/build/.../TailscaleKit.framework/Versions/A/TailscaleKit
Architectures in the fat file: ... are: x86_64 arm64

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant