Repository navigation
Build the -lto prebuilts with line tables only (-g1); every other variant keeps full DWARF - #411
Conversation
…ug and asan keep full DWARF DEFAULT_CFLAGS passes plain -g to every variant, so the release/-lto archives bun links against carry full type DWARF (a trivial WTF object has ~90 type DIEs; several hundred MB of .debug_* end up in bun-profile). For the -lto variants that debug metadata is inside the bitcode, so bun's ThinLTO link loads, imports and re-emits all of it, then compresses it post-link. Line tables are all release bun uses (crash backtraces, symbolizer, sanitizer reports); bun's own release C++ moved to -g1 in oven-sh/bun#37376 for the same reason. Each build step now appends -g1 after DEFAULT_CFLAGS unless the build is Debug or has sanitizers enabled, so the -debug and -asan variants are unchanged (bun's asan builds keep full debug info and rely on these archives for JSC's type definitions). ICU gets the same on linux/musl. FreeBSD already builds release without -g; Windows (/Zi) is untouched.
WalkthroughSummaryThe build files now conditionally add ChangesConditional debug flags
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Comment |
The debug info only costs at bun's ThinLTO link, where it rides in the bitcode. The non-LTO release archives are what local release builds and the non-LTO CI lanes link, and there full DWARF is worth having when something needs debugging, so leave those alone. Android has no -lto variants, so it needs no change.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile.android`:
- Around line 163-165: The G flag selection should depend on whether LTO is
enabled, not only on release type or sanitizers. Update the export of G near
CFLAGS/CXXFLAGS to emit -g1 only when LTO_FLAG is non-empty, and otherwise emit
no additional debug-level flag so Android Release builds retain DEFAULT_CFLAGS’
full debug information.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ac6ef4a8-84fc-4d24-80db-cfeeefb8dd9d
📒 Files selected for processing (4)
DockerfileDockerfile.androidDockerfile.macosDockerfile.musl
| export G=$(if [ "$WEBKIT_RELEASE_TYPE" = "Debug" ] || [ -n "${ENABLE_SANITIZERS:-}" ]; then echo ""; else echo "-g1"; fi) && \ | ||
| export CFLAGS="${CROSS} ${DEFAULT_CFLAGS} $G ${MARCH_FLAG} ${LTO_FLAG} -isystem /icu/include -ffile-prefix-map=/webkit/Source=vendor/WebKit/Source -ffile-prefix-map=/webkitbuild/=." && \ | ||
| export CXXFLAGS="${CROSS} -isystem ${NDK_SYSROOT}/usr/include/c++/v1 ${DEFAULT_CFLAGS} $G ${MARCH_FLAG} ${LTO_FLAG} -isystem /icu/include -fno-c++-static-destructors -ffile-prefix-map=/webkit/Source=vendor/WebKit/Source -ffile-prefix-map=/webkitbuild/=." && \ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 8 'Dockerfile\.android|ENABLE_SANITIZERS|WEBKIT_RELEASE_TYPE|LTO_FLAG' --glob '*.ts' --glob 'Dockerfile*' .Repository: oven-sh/WebKit
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Android Dockerfile arguments and build stage ---'
sed -n '1,20p;133,205p' Dockerfile.android
printf '%s\n' '--- Build configuration and Docker invocations ---'
rg -n -C 6 'Dockerfile\.android|docker(build| buildx)|ENABLE_SANITIZERS|LTO_FLAG|WEBKIT_RELEASE_TYPE' \
--glob '*.ts' --glob '*.js' --glob '*.yml' --glob '*.yaml' --glob '*.sh' --glob 'Dockerfile*' \
. | head -n 500
printf '%s\n' '--- Sanitizer configuration references ---'
rg -n -C 5 'ENABLE_SANITIZERS|address sanitizer|asan|sanitizer' build.ts .github \
--glob '*.ts' --glob '*.yml' --glob '*.yaml' --glob '*.sh' 2>/dev/null | head -n 300Repository: oven-sh/WebKit
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Android-specific callers ---'
rg -n -C 10 'android-release\.sh|Dockerfile\.android|android' \
--glob '*.sh' --glob '*.yml' --glob '*.yaml' --glob '*.ts' --glob '*.js' \
. | head -n 400
printf '%s\n' '--- Release dispatcher ---'
if [ -f release.sh ]; then
sed -n '1,220p' release.sh
fi
printf '%s\n' '--- Deterministic G behavior ---'
python3 - <<'PY'
import subprocess
script = r'''
WEBKIT_RELEASE_TYPE="$1"
LTO_FLAG="$2"
ENABLE_SANITIZERS="$3"
G=$(if [ "$WEBKIT_RELEASE_TYPE" = "Debug" ] || [ -n "${ENABLE_SANITIZERS:-}" ]; then echo ""; else echo "-g1"; fi)
printf '%s\n' "$G"
'''
for release_type, lto, sanitizers in [
("Release", "", ""),
("Release", "-flto=thin", ""),
("Debug", "", ""),
("Release", "", "address"),
]:
result = subprocess.run(
["bash", "-c", script, "probe", release_type, lto, sanitizers],
check=True, text=True, capture_output=True,
)
print({
"WEBKIT_RELEASE_TYPE": release_type,
"LTO_FLAG": lto,
"ENABLE_SANITIZERS": sanitizers,
"G": result.stdout.strip(),
})
PYRepository: oven-sh/WebKit
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Android release script ---'
sed -n '1,90p' android-release.sh
printf '%s\n' '--- Android references outside vendored website assets ---'
rg -n -C 5 'android-release\.sh|Dockerfile\.android|ANDROID_ARCH|ENABLE_SANITIZERS' \
.github '*.sh' '*.ts' '*.js' 'Dockerfile*' 2>/dev/null \
--glob '!Websites/**' --glob '!**/dist/**' --glob '!**/node_modules/**' \
| head -n 300
printf '%s\n' '--- Sanitizer build matrix entries ---'
rg -n -C 4 'label:.*android|ENABLE_SANITIZERS|android-release' .github/workflows \
--glob '*.yml' --glob '*.yaml' | head -n 300Repository: oven-sh/WebKit
Length of output: 13386
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Android workflow matrix and invocation ---'
sed -n '520,590p' .github/workflows/build-reusable.yml
printf '%s\n' '--- Android LTO and sanitizer references ---'
rg -n -C 3 'lto_flag|ENABLE_SANITIZERS|LTO_FLAG|CMAKE_BUILD_TYPE' \
.github/workflows/build-reusable.yml android-release.sh Dockerfile.android \
| awk 'BEGIN{IGNORECASE=1} /android|ANDROID|lto_flag|ENABLE_SANITIZERS|LTO_FLAG|CMAKE_BUILD_TYPE/'Repository: oven-sh/WebKit
Length of output: 17446
Limit -g1 to LTO builds.
The Android workflow has no LTO variants and passes an empty LTO_FLAG for Release builds. The current condition still appends -g1 after DEFAULT_CFLAGS supplies -g, so Android Release archives lose full debug information.
Use a non-empty LTO_FLAG as the condition for G. Android has no sanitizer variants.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Dockerfile.android` around lines 163 - 165, The G flag selection should
depend on whether LTO is enabled, not only on release type or sanitizers. Update
the export of G near CFLAGS/CXXFLAGS to emit -g1 only when LTO_FLAG is
non-empty, and otherwise emit no additional debug-level flag so Android Release
builds retain DEFAULT_CFLAGS’ full debug information.
…ere else Same policy as the WebKit prebuilts (oven-sh/WebKit#411): the debug info is only expensive where it rides through the ThinLTO link, so -g1 is now tied to lto rather than to release. Local release builds, asan and the non-LTO CI lanes get -g (types and variables) with -fno-standalone-debug, which is what makes it affordable; debug keeps -g3. This replaces the asan-only special case from earlier in this branch. No-Verification-Needed: flag-table change pinned by test/internal/build-debug-info-flags.test.ts; CI builds every configuration
|
Good catch — the first commit had already committed the Dockerfile.android hunk, so the second one only thought it dropped it. Reverted to main's Dockerfile.android; the PR now touches only the linux, musl and macOS files, all gated on |
There was a problem hiding this comment.
LGTM — the Dockerfile.android hunk is gone and the three remaining files gate -g1 on [ -n "${LTO_FLAG:-}" ], which the workflow sets exactly on the -lto matrix entries.
Checked $G placement in each file — it lands after DEFAULT_CFLAGS' -g so last-flag-wins applies, and expands to an empty token (harmless extra space) when LTO_FLAG is empty. Cross-referenced .github/workflows/build-reusable.yml: linux/musl/macOS non-LTO, debug and asan lanes all pass lto_flag: "", so they keep full -g as described.
Extended reasoning...
Overview
Three Dockerfiles (Dockerfile, Dockerfile.macos, Dockerfile.musl) each gain a one-line export G=$(if [ -n "${LTO_FLAG:-}" ]; then echo "-g1"; fi) and splice $G into CFLAGS/CXXFLAGS immediately after DEFAULT_CFLAGS (which carries -g). Net effect: -lto prebuilts emit line-tables-only DWARF; every other variant is byte-for-byte unchanged (empty $G → extra whitespace in the flag string). The earlier Dockerfile.android hunk that I flagged has been reverted in ef4db73, and grep confirms no -g1/export G= remains there.
Security risks
None. This only adjusts the debug-info level passed to clang for CI-built static archives; no code paths, inputs, or trust boundaries are touched.
Level of scrutiny
Low. Build-infrastructure tweak with a bounded blast radius: worst case is a prebuilt with more or less debug info than intended, correctable by rebuilding. The author explicitly plans to measure the effect downstream by bumping bun's WebKit pin, so any regression surfaces immediately in bun CI.
Other factors
- Verified against
.github/workflows/build-reusable.ymlthatlto_flagis non-empty on exactly the six-ltolabels (linux ×2, musl ×2, macOS ×2) and empty on plain release/debug/asan, matching the PR description. $Gis placed after${DEFAULT_CFLAGS}in all five insertion points (ICU + WebKit for linux/musl, WebKit-only for macOS), so clang's last--g-wins semantics give the intended override.Dockerfile/Dockerfile.musldefaultARG LTO_FLAGto a non-empty value, so a baredocker buildwould now also get-g1— but that build was already an LTO build, so this is consistent with the stated policy.- The prior review round's only finding (Android leftover) was acknowledged by the author and fixed; the current diff matches what they described.
Preview Builds
|
DEFAULT_CFLAGSpasses plain-gto every variant, including the-ltoones. There the debug info lives inside the bitcode, so bun's ThinLTO link — currently the largest single piece of a bun CI build, ~1m46 on linux-x64 after oven-sh/bun#37733 — loads, imports and re-emits all of it and then compresses it post-link. PullingASCIICType.cpp.oout of the current releaselibWTF.ashows ~90 struct/class DIEs for a file with almost no code; several hundred MB of.debug_*from these archives end up inbun-profile. Line tables are all release bun uses out of them (crash backtraces, symbolizer, the order-file tooling); bun's own release C++ moved to-g1in oven-sh/bun#37376.The linux, musl and macOS build steps now append
-g1afterDEFAULT_CFLAGS(last-gflag wins) whenLTO_FLAGis set, which the workflow sets exactly on the-ltolabels. So:-ltovariants (linux, muslMinSizeRel, macOS): line tables only. Linux/musl ICU is built withLTO_FLAGtoo and gets the same.-debug,-asan,-debug-asan: unchanged, full-g— the non-LTO release archives are what local release builds and the non-LTO CI lanes link, and full DWARF is worth having there when something needs debugging; bun's asan builds also rely on the-asanarchives for JSC's type definitions.-ltovariants (FreeBSD already builds release without-g); Windows (/Zi,-ltovia/clang:flags) is untouched, matching the scope of build: put -glldb before the -g level flags so release C++ gets line tables, not full DWARF bun#37376.Effect on bun's link time and
bun-profilesize gets measured by bumping the pin in bun once the prebuilts exist.