Skip to content

Build the -lto prebuilts with line tables only (-g1); every other variant keeps full DWARF - #411

Merged
Jarred-Sumner merged 3 commits into
mainfrom
claude/release-prebuilts-line-tables
Aug 12, 2026
Merged

Jarred-Sumner merged 3 commits into
mainfrom
claude/release-prebuilts-line-tables

Conversation

@Jarred-Sumner

@Jarred-Sumner Jarred-Sumner commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

DEFAULT_CFLAGS passes plain -g to every variant, including the -lto ones. 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. Pulling ASCIICType.cpp.o out of the current release libWTF.a shows ~90 struct/class DIEs for a file with almost no code; several hundred MB of .debug_* from these archives end up in bun-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 -g1 in oven-sh/bun#37376.

The linux, musl and macOS build steps now append -g1 after DEFAULT_CFLAGS (last -g flag wins) when LTO_FLAG is set, which the workflow sets exactly on the -lto labels. So:

  • -lto variants (linux, musl MinSizeRel, macOS): line tables only. Linux/musl ICU is built with LTO_FLAG too and gets the same.
  • plain release, -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 -asan archives for JSC's type definitions.
  • Android and FreeBSD have no -lto variants (FreeBSD already builds release without -g); Windows (/Zi, -lto via /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-profile size gets measured by bumping the pin in bun once the prebuilts exist.

…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.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Summary

The build files now conditionally add -g1 to ICU and WebKit C and C++ compiler flags for LTO builds and selected Android builds.

Changes

Conditional debug flags

Layer / File(s) Summary
Primary LTO flag handling
Dockerfile
The main build documents the -g1 behavior and applies it to ICU and WebKit compiler flags when LTO is enabled.
Platform LTO flag handling
Dockerfile.macos, Dockerfile.musl
The macOS and musl builds apply -g1 to ICU and WebKit compiler flags for LTO builds.
Android build flag conditions
Dockerfile.android
The Android WebKit build applies -g1 unless the build is a Debug build or sanitizers are enabled.

Suggested reviewers: robobun, dylan-conway

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the rationale and scope, but it omits the required Bugzilla link, review status, and changed-file/function summary. Add the bug title and Bugzilla URL, include “Reviewed by NOBODY (OOPS!).”, and list the changed files and relevant functions.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: using -g1 for -lto prebuilts while retaining full DWARF for other variants.

Comment @coderabbitai help to get the list of available commands.

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.
@Jarred-Sumner Jarred-Sumner changed the title Build the release and -lto prebuilts with line tables only (-g1); debug and asan keep full DWARF Build the -lto prebuilts with line tables only (-g1); every other variant keeps full DWARF Aug 12, 2026

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 38e1ad6 and d297986.

📒 Files selected for processing (4)
  • Dockerfile
  • Dockerfile.android
  • Dockerfile.macos
  • Dockerfile.musl

Comment thread Dockerfile.android Outdated
Comment on lines +163 to +165
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/=." && \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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 300

Repository: 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(),
    })
PY

Repository: 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 300

Repository: 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.

Comment thread Dockerfile.android Resolved
Jarred-Sumner added a commit to oven-sh/bun that referenced this pull request Aug 12, 2026
…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
@Jarred-Sumner

Copy link
Copy Markdown
Collaborator Author

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 LTO_FLAG.

@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.

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.yml that lto_flag is non-empty on exactly the six -lto labels (linux ×2, musl ×2, macOS ×2) and empty on plain release/debug/asan, matching the PR description.
  • $G is 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.musl default ARG LTO_FLAG to a non-empty value, so a bare docker build would 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.

@github-actions

Copy link
Copy Markdown

Preview Builds

Commit Release Date
ef4db73f autobuild-preview-pr-411-ef4db73f 2026-08-12 05:45:07 UTC

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.

1 participant