Repository navigation
CI: add LTO lanes for Windows arm64, drop -mtune=ampere1 - #1088
dylan-conway wants to merge 6 commits into
Conversation
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>
There was a problem hiding this comment.
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.
| 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}`, |
There was a problem hiding this comment.
🟡 (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.
There was a problem hiding this comment.
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
|
Preview build of d548a2a: |
-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>
There was a problem hiding this comment.
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.
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>
There was a problem hiding this comment.
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.
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>
There was a problem hiding this comment.
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), theudata.ao: CXXFLAGS += -fno-ltotarget-specific variable applies to ICU's.aostatic-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
-ltoand-lto-aotlanes 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>
|
It is not from this change. The build arguments of that lane and Generated by Claude Code |
Gives Bun an LTO prebuilt for every platform, and takes
-mtune=ampere1out of the arm64 lanes. No source changes.What changes
windows-arm64-lto,windows-arm64-lto-aottestFFIand the objects ofjscandtestaotmove here fromwindows-arm64andwindows-arm64-aot.windows-arm64*-moutline-atomics, also inbuild-icu.ps1.windows-*-lto*, x64 tooudata.cpp._FORTIFY_SOURCEwrapper stays out of line, like the hardened glibc lanes.-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*-g1in 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 theDBG_VALUEof 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-atomicsis 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 fromclang_rt.builtins, Bun from Rust'scompiler_builtins.LLVM 23 miscompiles weak references here. ThinLTO marks an
extern_weakdeclarationdso_localwhen 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, soudata.cppstays 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=ampere1ldpandstpthat are not known to be aligned to both registers._FORTIFY_SOURCEwrappers 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
-ltoand-lto-aottests pass with generic tuning. Nothing here runs the Windows, FreeBSD or Android lanes, orbuild-icu.ps1. Bun's test lanes run the Windows ones.Generated by Claude Code