Skip to content

Upgrade zig toolchain to 0.15.2 - #247

Closed
nmattia wants to merge 7 commits into
uber:mainfrom
nmattia:nm-0.15.2
Closed

Upgrade zig toolchain to 0.15.2#247
nmattia wants to merge 7 commits into
uber:mainfrom
nmattia:nm-0.15.2

Conversation

@nmattia

@nmattia nmattia commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

The new toolchain includes some bug fixes, most importantly the concurrency issue in the zig cache: #224

The wrapper had to be updated due to some changes in stdlib, and some of the paths had to be updated to reflect the structure of the recent installs. The targets OS & arch have also been swapped to reflect Zig's new naming scheme.

Closes #224

The new toolchain includes some bug fixes, most importantly the
concurrency issue in the zig cache: uber#224

The wrapper had to be updated due to some changes in stdlib, and some of
the paths had to be updated to reflect the structure of the recent
installs. The targets OS & arch have also been swapped to reflect Zig's
new naming scheme.
@nmattia

nmattia commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

This can probably be reverted: #150

But I don't think this is being tested automatically so probably best to do separately to avoid breaking things silently

@nmattia

nmattia commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

checking if zig is mirorred in "https://mirror.bazel.build/ziglang.org/download/0.15.2/zig-x86_64-windows-0.15.2.zip"
error: zig is correctly mirrored: got non-200: 404 Not Found

I guess this will need to be uploaded?

@linzhp

linzhp commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Created a mirror request: bazelbuild/bazel#29000

@linzhp

linzhp commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Also #248 will make future upgrades easier

Comment thread toolchain/private/defs.bzl
Comment thread tools/releaser/main.go
@linzhp

linzhp commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Sorry for the delay. It takes a while for me to sort out all the errors I ran into at Uber with this PR. The errors I got so far:

  1. It seems Zig 0.15.2 enables ubsan by default, so we got a lot of errors like ld.lld: error: undefined symbol: __ubsan_handle_builtin_unreachable. This can be worked around by adding -fno-sanitize=undefined here, here and here.
  2. zig cc fails to link thin archives? ziglang/zig#25694 affects libraries built with meson, because meson created thin archives for internal static libraries. This can be worked around by disabling meson targets that produce thin archives, if they are not needed for final output.
  3. The same issue as @chrisirhc ran into when he was trying to upgrade Zig to 0.14.0 (upgrade to zig 0.14.0 #203). I added a test so it's easier to catch this regression in the future (Adding a test for colon link #249). As @chrisirhc found, this issue only affect 0.14.0 and later. So one option is to upgrade Zig to 0.13.x, if it has the fix you need.

@nmattia

nmattia commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

Hey @linzhp, huh that's unfortunate!

I guess we're blocked on zig for (2) and (3). It looks like the issue for which we need the fix will actually only be included in 0.16, it looks like I jumped the gun here.

The lib path issue is technically labeled as "urgent", so who knows, 0.16 will fix all our issues... I'd say let's wait until it is release and see where we stand then.

Thanks for trying this out internally!

DhashS added a commit to DhashS/hermetic_cc_toolchain that referenced this pull request Jul 21, 2026
Addresses the two workaround-able issues reported when testing the Zig
0.15.2 upgrade at Uber (see uber#247 discussion):

1. Zig 0.15 compiles C/C++ with UBSan instrumentation by default, which
   surfaces as `ld.lld: error: undefined symbol: __ubsan_handle_*` at
   link time. The wrapper now passes -fno-sanitize=undefined in cc mode,
   placed before the caller's args so an explicit -fsanitize=undefined
   still takes precedence. The dbg/fastbuild features repeat the flag so
   the intent is visible in the toolchain config.

2. Zig 0.15's linker cannot read thin archives (ziglang/zig#25694):
       error: unexpected token in LD script: literal: '!<thin>'
   Build systems like Meson create thin archives for internal static
   libraries via ar's `T` modifier. Since archives produced by this
   toolchain are also consumed by it, the wrapper's ar mode now strips
   the `T` modifier from the operation string and drops `--thin`, so
   regular archives are created instead.

Both are verified against the real 0.15.2 toolchain: default compiles
reference __ubsan_* symbols and -fno-sanitize=undefined removes them;
`zig ar rcsT` produces a `!<thin>` archive that fails to link with
exactly the error above, while the stripped `rcs` archive links fine.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nmattia

nmattia commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #259

@nmattia nmattia closed this Jul 27, 2026
@nmattia
nmattia deleted the nm-0.15.2 branch July 27, 2026 09:46
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.

Zig cache issue on concurrent builds

2 participants