macOS: build a baseline (non-AVX2) x64 WebKit#290
Conversation
Adds a bun-webkit-macos-amd64-baseline lane and forwards MARCH_FLAG into macos-cross-release.sh, which otherwise defaults x86_64 to -march=haswell. Without a baseline macOS WebKit, bun cannot build a baseline darwin bun, so @oven/bun-darwin-x64-baseline ships the AVX2 build and pre-AVX2 Intel Macs have no working binary.
@oven/bun-darwin-x64-baseline is byte-identical to @oven/bun-darwin-x64 (the AVX2 build), so pre-AVX2 Intel Macs get no working binary and no fallback. buildPlatforms had no darwin baseline lane, though platform.ts already declares the npm package and prebuiltSuffix() already requests the baseline WebKit tarball. Gated on oven-sh/WebKit#290, which publishes bun-webkit-macos-amd64-baseline.
WalkthroughChangesmacOS x64 baseline artifact
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for tracking this down, the analysis in oven-sh/bun#34206 is spot on. One gap worth flagging: bun's release pipeline will also need bun's darwin release builds are cross-compiled from Linux with LTO on by default: // bun scripts/build/config.ts
const ltoDefault = release && (linux || darwinCross) && ci && !assertions && !asan;and I opened #291 before noticing this PR, sorry for the overlap. It's the same change as yours plus the |
bun's release cross-compiles darwin from Linux with LTO on by default (ltoDefault = release && (linux || darwinCross) && ci), and prebuiltSuffix() composes -baseline with -lto, so a darwin-x64-baseline release build requests bun-webkit-macos-amd64-baseline-lto.tar.gz. Without this lane that 404s. Mirrors the existing linux/windows amd64 baseline lanes, which each ship both a plain and an -lto variant. Caught by robobun in oven-sh#291.
The windows-cross job builds bun-webkit-windows-amd64-baseline-lto on every run, but the release job never downloaded, staged, or published it, so the tarball 404s. bun's scripts/build/config.ts references this variant. Caught by robobun in oven-sh#291.
|
Re the Description check: I think that's inherited from upstream WebKit's template rather than this fork's practice. Of the last 12 merged PRs here, 0 have a oven-sh/WebKit tracks issues on GitHub, so a Bugzilla link would have to be invented. Happy to reformat if maintainers do want the upstream template on fork-native PRs. |
|
Preview build results, from #291 (same workflow change as this PR now has; #290's own preview needs a maintainer approval to run since it's from a fork): The run built the full matrix and published
Verified the CI-produced Since this PR now includes the |
Problem
bun-webkit-macos-amd64-baseline.tar.gzis never built. Every other x64 platform has a baseline lane; macOS doesn't.bun already asks for it —
scripts/build/deps/webkit.ts:prebuiltSuffix()appends-baselinefor any x64 target, no OS check:So a
darwin-x64 --baselinebuild resolves to this tarball and 404s:Consequence: bun can't build a baseline darwin at all, so
@oven/bun-darwin-x64-baselineon npm is byte-identical to@oven/bun-darwin-x64— the-march=haswellbuild:Pre-AVX2 Intel Macs get no working bun and no fallback. Downstream: opencode#29039, opencode#24876.
Fix
Two matrix lanes in
.github/workflows/build-reusable.yml, mirroring the linux/windows amd64 baseline lanes (each of which ships a plain and an-ltovariant), plus their release plumbing.1. Add the lanes — clones of
bun-webkit-macos-amd64/-ltowithMARCH_FLAG: "-march=nehalem":The
-ltovariant is required, not optional: bun's release cross-compiles darwin from Linux with LTO on by default —— and
prebuiltSuffix()composes-baselinewith-lto, so a darwin-x64-baseline release build requestsbun-webkit-macos-amd64-baseline-lto.tar.gz. (The LTO-disabling guard coverswindows && baseline, not darwin.) With only the plain artifact, that 404s.2. Forward
MARCH_FLAGinto the build step —MARCH_FLAG="${{matrix.MARCH_FLAG}}"on themacos-cross-release.shinvocation. This is the load-bearing line. The script defaults x86_64 to haswell:Without forwarding it, a
-baseline-labelled lane silently rebuilds the AVX2 default and ships it under the baseline name — reproducing the exact bug this fixes.3. Release plumbing — the release job enumerates every label by hand, so both tarballs also need a
download-artifactentry, amvinto./out, and a line in the releasefiles:list. Without those the lanes build and are never published.4. Publish
bun-webkit-windows-amd64-baseline-lto— a pre-existing bug in that same plumbing: thewindows-crossjob builds this artifact on every run, but the release job never downloaded, staged, or published it, so it 404s whilebun-webkit-windows-amd64-baselineis 200. bun'sscripts/build/config.tsreferences the variant.No change to
Dockerfile.macos(already takesMARCH_FLAG, already setsCMAKE_SYSTEM_NAME=Darwin) ormacos-cross-release.sh(already honors a caller-suppliedMARCH_FLAG).Verification
Built with the unmodified recipe, changing only the two settings this PR configures:
MACOS_ARCH=x86_64 MARCH_FLAG="-march=nehalem" WEBKIT_RELEASE_TYPE=Release \ USE_MIMALLOC=ON USE_EXTERNAL_MIMALLOC=ON bash macos-cross-release.shProduces the expected layout (
Source/ bin/ include/ lib/) —libJavaScriptCore.a560 MB,libWTF.a34 MB,libbmalloc.a454 KB.Baseline confirmed by disassembly of
libJavaScriptCore.a(7.87M lines):%ymm)%zmm)-march=nehalem)bun-webkit-macos-amd64(-march=haswell)Zero AVX2 — nothing for a pre-AVX2 CPU to trap on.
Without hunk 2, the same lane produces the AVX2 build (the script's haswell default) — i.e. the bug reproduces.
Recipe validated on real pre-AVX2 hardware (Sandy Bridge Xeon, AVX + SSE4.2, no AVX2/FMA): the
-march=nehalemlinux baseline runs there; the-march=haswellbuild crashes (~21 s, ~3.9 GB RSS, segfault in the simdutf path).Refs oven-sh/bun#34206 (the downstream report). Consumed by oven-sh/bun#34207, which adds the
darwin-x64-baselinebuild lane and is gated on these artifacts existing.On #291
I opened this PR first; @robobun opened #291 shortly after with the same core change plus two pieces mine was missing. I've reviewed its feedback, verified both points against the source, and merged them in here:
-ltovariant is required.ltoDefault = release && (linux || darwinCross) && ciin bun'sconfig.tsputs darwin cross-compiles on LTO by default, and the disabling guard below it coverswindows && baselinebut not darwin — so bun's darwin release genuinely requests-baseline-lto. Every other baseline platform already ships both variants. Without this, the plain artifact alone would have left the release broken. I'd built locally with--lto=off, which is exactly why I missed it.windows-amd64-baseline-ltois built but never published. Verified: 1 matrix lane builds it, 0 download/mv/release entries reference it, and the tarball 404s while the plain windows baseline is 200.So #290 now covers the same ground as #291. I did not expect robobun to automatically create a PR.
Prebuilt artifacts from this recipe (a baseline bun + an opencode compiled against it), for anyone with a pre-AVX2 Mac willing to test: https://github.com/tobocop2/opencode-bun-pre-avx2-mac