Skip to content

CI: add LTO lanes for Windows arm64, drop -mtune=ampere1 - #1088

Open
dylan-conway wants to merge 6 commits into
mainfrom
claude/quirky-rubin-bv7xq3
Open

dylan-conway wants to merge 6 commits into
mainfrom
claude/quirky-rubin-bv7xq3

Conversation

@dylan-conway

@dylan-conway dylan-conway commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Gives Bun an LTO prebuilt for every platform, and takes -mtune=ampere1 out of the arm64 lanes. No source changes.

What changes

Lanes Change
windows-arm64-lto, windows-arm64-lto-aot New. The flags of the x64 ones. testFFI and the objects of jsc and testaot move here from windows-arm64 and windows-arm64-aot.
windows-arm64* -moutline-atomics, also in build-icu.ps1.
windows-*-lto*, x64 too ICU is bitcode, as in every other LTO lane, but for udata.cpp.
musl, optimized Fail when a _FORTIFY_SOURCE wrapper stays out of line, like the hardened glibc lanes.
Linux glibc, musl and FreeBSD arm64 (19 lanes) No -mtune=ampere1. The hardened and Windows lanes had none. Android keeps -mtune=cortex-a78.
freebsd-*-lto* -g1. They were the only LTO lanes without line tables.
android-lto* ICU is compiled with -g1 in place of -g, like WebKit beside it.

No toolchain image gets a new tag.

Windows arm64

The lanes were left out for LLVM ERROR: unknown codeview register Q22_Q23_Q24_Q25 (#239, LLVM 21). The CodeView emitter still has no number for a register tuple, but what handed it one was MachineCopyPropagation, which widened the DBG_VALUE of a Q register to the whole tuple: llvm/llvm-project#207682, fixed by llvm/llvm-project#207861. The fix is in 23.1.0, so the lanes keep full /Zi.

-moutline-atomics is clang's default on the other arm64 targets and rustc's on this one too. LLVM inlines no function that has it into one that does not. The code takes LSE where the CPU has it. The programs here get the helpers from clang_rt.builtins, Bun from Rust's compiler_builtins.

LLVM 23 miscompiles weak references here. ThinLTO marks an extern_weak declaration dso_local when clang defines the symbol in bitcode and it is not imported, and the AArch64 back end then loads from the symbol in place of taking its address. The link fails only if that address is misaligned. ICU's decompression hook is such a reference, so udata.cpp stays native, and the lane checks that. The hooks of WTF and JavaScriptCore are defined in Rust, which is not affected. Bun's build checks for the next one.

-mtune=ampere1

  • It aligns every function and loop to 64 bytes.
  • It splits ldp and stp that are not known to be aligned to both registers.
  • LLVM 23 for AArch64 inlines no function into one with another tune CPU, and clang gives its copies of _FORTIFY_SOURCE wrappers none (CI: the hardened Linux arm64 lanes are compiled without -mtune #916). The musl lanes are fortified too.

Speed on arm64 hardware is not measured.

Has to land with the change in Bun

With different tune CPUs, LTO inlines nothing between these libraries and Bun, in either direction, and no check fails for it. A Bun that pins a commit with this change needs the build scripts of oven-sh/bun#49409, which pins the preview.

The branch starts at 499846f, which Bun pins, and not at main, so that the preview differs from the pin by this change alone.

Testing

All 79 lanes build here, and the arm64 -lto and -lto-aot tests pass with generic tuning. Nothing here runs the Windows, FreeBSD or Android lanes, or build-icu.ps1. Bun's test lanes run the Windows ones.


Generated by Claude Code

Windows arm64 gets -lto and -lto-aot. The CodeView abort that kept them
out came from MachineCopyPropagation widening a DBG_VALUE to a register
tuple, which LLVM 23.1.0 fixes (llvm/llvm-project#207861).

The Linux glibc, musl and FreeBSD arm64 lanes are compiled with generic
tuning, as the hardened and Windows ones already are.

The FreeBSD -lto lanes get line tables, and ICU of the Android -lto
lanes gets -g1 in place of -g, as in the other Dockerfiles.

Co-authored-by: dylanc <dylanc@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline findings, I also checked the two Dockerfile -g1 changes and the new Windows arm64 LTO lanes. On Android the ICU stage's -g1 now follows DEFAULT_CFLAGS' -g in the same order as the WebKit stage, so it narrows to line tables rather than adding a second level; on FreeBSD only the -lto Release lanes gain line tables and the Debug path still takes DEBUG_CFLAGS alone, so the full--g OOM the file's comment describes is not reintroduced. No base stage is touched, so no toolchain image tag changes, and Dockerfile.windows has no arch-gated LTO path the arm64 lanes would miss.

Extended reasoning...

The change edits only CI configuration: lanes.mjs (adds Windows arm64 lto/lto-aot via NO_ASAN, moves bunTests to lto for both Windows arches, drops -mtune=ampere1 from glibc, musl and FreeBSD arm64), the ICU/WebKit debug-info flags in Dockerfile.android and Dockerfile.freebsd, and one CLAUDE.md sentence. It touches no security-sensitive surface. Three confirmed inline findings about coordination with Bun's pinned flags and unverified fortification stand, and /.github is listed in CODEOWNERS, so this is not approved; the note records the concrete items ruled out beyond them.

Comment thread .github/scripts/lanes.mjs Resolved
Comment thread .github/scripts/lanes.mjs
arch === "arm64"
? `--target=aarch64-unknown-linux-gnu ${ARMV8}${v.hardened ? "" : " -mtune=ampere1"}`
: `--target=x86_64-unknown-linux-gnu ${NEHALEM}`,
MARCH_FLAG: arch === "arm64" ? `--target=aarch64-unknown-linux-gnu ${ARMV8}` : `--target=x86_64-unknown-linux-gnu ${NEHALEM}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 (optional) Bun users on Linux arm64 get a bun whose LTO link inlines nothing between bun and JavaScriptCore if bun's pin moves to this commit before bun's flags.ts drops -mtune=ampere1, and nothing reports it. lanes.mjs:181, :196 and :252 now emit no -mtune for arm64, while the bun that pins the base still passes -mtune=ampere1, which LLVM 23 treats as inline-incompatible. Fix: make a -march/-mtune mismatch detectable in either order, e.g. record MARCH_FLAG in the tarball's include/cmakeconfig.h next to BUN_WEBKIT_ENABLE_AOT (ci.yml:274) so bun's build can refuse or warn. The PR says 'no check fails for it'; that holds, and the loss is silent.

Why this was flagged

The trigger is a bun checkout whose pinned WebKit commit is moved to this change while its scripts/build/flags.ts still names -mtune=ampere1 for Linux arm64, which is what matched the base's MARCH_FLAG (base lanes.mjs:181, :196, :252 had -mtune=ampere1 for glibc, musl and FreeBSD arm64). After the change those three lines emit only -march=armv8-a+crc, so every JavaScriptCore, WTF and bmalloc function in the arm64 lanes carries no tune-cpu while bun's own objects carry ampere1. The comment the PR adds at lanes.mjs:80-83 states that LLVM 23 for AArch64 inlines no function into one with another tune CPU, so bun's ThinLTO link then imports nothing across the library boundary in either direction: the cross-language LTO the -lto lanes exist for is lost on Linux arm64 glibc, musl and FreeBSD, with no error. On the base branch the flags agree and inlining works. The only safeguard is ordering the two pull requests by hand; the tarball records BUN_WEBKIT_VERSION and BUN_WEBKIT_ENABLE_AOT (ci.yml:270-276) but not the code-generation flags, so neither bun's build nor this repository's CI can notice the mismatch.

Verification: lanes.mjs:181 now emits --target=aarch64-unknown-linux-gnu ${ARMV8}, :196 and :252 now emit ARMV8, so every object in the glibc, musl and FreeBSD arm64 lanes carries no tune-cpu attribute. The pack step in ci.yml:270-276 appends only BUN_WEBKIT_VERSION, BUN_WEBKIT_ENABLE_AOT/ENABLE_AOT and defines to include/cmakeconfig.h; MARCH_FLAG is never recorded anywhere in the tarball.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and both descriptions say so. oven-sh/bun#49409 drops the flag in the commit that moves the pin. Recording MARCH_FLAG in the tarball for bun to compare would catch the next mismatch too. It needs a change in both repositories, so it is not part of this one.


Generated by Claude Code

Comment thread .github/scripts/lanes.mjs Resolved
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Preview build of d548a2a: autobuild-preview-pr-1088-d548a2ad

-moutline-atomics is clang's default on the other arm64 targets and
rustc's on Windows too. LLVM inlines no function that has it into one
that does not, and the code takes LSE where the CPU has it.

The musl lanes fail when a _FORTIFY_SOURCE wrapper stays out of line,
like the hardened glibc ones.

Co-authored-by: dylanc <dylanc@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the inline findings, I also checked that the new Windows arm64 LTO lanes have no stale gating left behind: nothing in Dockerfile.windows, ci.yml or the other Dockerfiles still excludes arm64 from LTO or mentions the old CodeView register error, and no -mtune=ampere1 remains anywhere outside Android's cortex-a78. The -g1 additions in Dockerfile.freebsd and Dockerfile.android match the LTO_FLAG guard the glibc Dockerfile already uses.

Extended reasoning...

The change is CI configuration only: lanes.mjs adds Windows arm64 lto/lto-aot lanes and moves bunTests to them, drops -mtune=ampere1 from glibc, musl and FreeBSD arm64, adds -moutline-atomics on Windows arm64, and the Dockerfiles add -g1 for LTO ICU/WebKit on FreeBSD and Android plus a fortify-inlining check on musl. It touches no security-sensitive runtime surface. The inline finding that the new musl check is guarded by WEBKIT_RELEASE_TYPE = Release while lanes.mjs:190 maps every musl Release variant to MinSizeRel is verified from lanes.mjs:326-329, so the check never runs; that keeps this from being approvable as-is.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Still open from earlier reviews (3):

  • Unresolved: 3 minor or pre-existing.

Comment thread Dockerfile.musl Resolved
Comment thread .github/scripts/lanes.mjs Resolved
claude and others added 2 commits November 22, 2026 01:54
The optimized musl lanes are MinSizeRel, so the check ran in none.

Co-authored-by: dylanc <dylanc@anthropic.com>
They were the only LTO lanes whose ICU was native code.

Co-authored-by: dylanc <dylanc@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

The two things raised on the previous push are fixed in the code: the musl _FORTIFY_SOURCE guard now fires for MinSizeRel (!= Debug), and build-icu.ps1 carries -moutline-atomics. Beyond the inline finding, I also checked the new Windows ICU LTO hookup in Dockerfile.windows:338-341 — the ${LTO_FLAG//\/clang:/} substitution runs under the bash SHELL set at line 60, and it brings Windows in line with the Linux, Android and FreeBSD ICU stages, which already compile ICU with LTO_FLAG; note it also changes the existing x64 -lto/-lto-aot lanes (ICU now ships as bitcode), which the description does not list.

Extended reasoning...

The change is CI configuration only: lanes.mjs lane tables and -march/-mtune flags, the Windows, musl, FreeBSD and Android Dockerfiles, build-icu.ps1 and the matching CLAUDE.md sentence. It touches no security-sensitive surface beyond build hardening flags. The open inline finding about -moutline-atomics depends on bun's Windows arm64 link line, which cannot be read from this checkout, and the PR itself requires a coordinated change in bun, so a human should confirm that side before merging.

Still open from earlier reviews (1):

  • Unresolved: 1 minor or pre-existing.

Comment thread .github/scripts/lanes.mjs Resolved
For arm64, ThinLTO marks the weak declaration of the decompression hook
dso_local, and LLVM 23 then loads from the function's code in place of
taking its address. The link fails only if the address is misaligned.

Co-authored-by: dylanc <dylanc@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the latest push (udata.cpp kept out of LTO on Windows) and found no bugs; because this changes the code generation of every shipped arm64 lane and has to land together with the Bun-side flags change, a human look is still worthwhile.

What was reviewed:

  • Dockerfile.windows ICU stage: the ${LTO_FLAG//\/clang:/} expansion runs under bash (SHELL at line 60), the udata.ao: CXXFLAGS += -fno-lto target-specific variable applies to ICU's .ao static-object rule, and the .refptr. / bcanalyzer checks self-verify both halves on every lane.
  • Dockerfile.musl: the fortify-wrapper check now guards on != Debug, so it covers the MinSizeRel build type the musl lanes actually use.
  • Scope note: the amd64 Windows -lto and -lto-aot lanes also change — their ICU is now compiled to bitcode like the other platforms' LTO lanes — which the PR table does not list; consumers linking those tarballs need an LTO-capable linker (Bun's lld-link is).
  • Not run here: no lane was built in this review; the Windows, FreeBSD and Android lanes are, per the PR, not tested by CI either.
Extended reasoning...

The change touches only CI configuration: lanes.mjs (adds Windows arm64 LTO lanes, drops -mtune=ampere1 from glibc/musl/FreeBSD arm64, adds -moutline-atomics on Windows arm64), four Dockerfiles (-g1 for LTO ICU/WebKit on FreeBSD and Android, a musl fortify-inlining check, ICU bitcode plus a udata.cpp opt-out on Windows), build-icu.ps1 and the CLAUDE.md sentence describing the hardened lanes. It touches no auth, injection or data-exposure surface. It was not approved because it changes codegen of every shipped arm64 build with unmeasured performance, is explicitly coupled to a change in Bun's repository, and one earlier inline thread of mine (outline-atomics helpers for consumers of the Windows arm64 tarballs) has no reply yet.

Still open from earlier reviews (2):

  • Unresolved: 2 minor or pre-existing.

make writes common/Makefile again before it reads it.

Co-authored-by: dylanc <dylanc@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

Still open from earlier reviews (1):

  • Unresolved: 1 minor or pre-existing.

Copy link
Copy Markdown
Member Author

Test bun-webkit-linux-arm64-lto-hardened failed on d548a2a in one test, stress/string-object-from-inlined-function-of-another-realm.js.dfg-eager: reoptimizationRetryCount(site) was 1, not 0 (line 69).

It is not from this change. The build arguments of that lane and Dockerfile are the same as on the base, no source differs, and the job passed on e542564. The mode compiles concurrently with --collectContinuously, and a compilation that is invalidated also counts as a reoptimization, which may be what happened. I have not reproduced it. Re-run once.


Generated by Claude Code

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