Skip to content

Pass explicit -target to zig on macOS - #258

Merged
linzhp merged 2 commits into
uber:mainfrom
linzhp:macos
Jul 13, 2026
Merged

Pass explicit -target to zig on macOS#258
linzhp merged 2 commits into
uber:mainfrom
linzhp:macos

Conversation

@linzhp

@linzhp linzhp commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

On macOS 26 (Xcode/CommandLineTools with MacOSX26.x.sdk), bazel build //rules:cp and ci/zig-utils both fail with undefined-symbol link errors (_abort, _getenv, _sigaction, __availability_version_check, …).

Root cause

Both code paths invoke zig without a -target, so zig links against the host macOS SDK's libSystem.tbd. Zig 0.14.0's TAPI parser can't parse the tbd shipped with newer Xcode SDKs (ziglang/zig#23324) and silently yields zero symbols. Confirmed by isolation: the same commands with -target aarch64-macos-none or an older SDK sysroot link and run.

Fix

Pass an explicit -target on macOS only, so zig links against its bundled hermetic libc stubs instead of the host SDK. Linux and Windows are untouched — they build natively as before (Linux glibc detection works, Windows bundles mingw-w64 libc).

  • rules/zig_binary.bzl — adds -target aarch64-macos-none / x86_64-macos-none for macOS targets; other platforms pass no target.
  • ci/zig-utils — adds -target for Darwin-* hosts only; non-Darwin runs zig test with no target flag.

@linzhp linzhp changed the title Pass explicit -target to zig build-exe so zig_binary links hermetically Pass explicit -target to zig on macOS Jul 12, 2026
@linzhp
linzhp merged commit 8a1449e into uber:main Jul 13, 2026
6 checks passed
@linzhp
linzhp deleted the macos branch July 13, 2026 05:11
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.

2 participants