Skip to content

Strip debug sections from the embedded core and -w bundles #631

Description

@mparrett

Sub-issue of #503 (footprint). Sibling lever to #502. Where #502 compresses the embedded core_compiled.lgb, this removes data from it: the source maps and local-variable tables that exist only for error reporting. The two compose — strip drops the debug bytes, compression shrinks what remains, so strip-then-compress beats either alone.

Background

#624 added bytecode.StripDebug and taught lg -strip to omit source maps and local-var tables from -c/-b bytecode. It deliberately parked two follow-ups: the always-shipped embedded core, and the -w wasm program bundle. This tracks finishing both.

What it covers

  • lg -w -strip strips the per-app program.lgb in the emitted web app, mirroring the -c/-b paths.
  • lgbgen -strip regenerates core_compiled.lgb debug-free, so a release build can ship a stripped core. Default off — the committed core stays full-debug so dev builds keep source locations in core stack traces.

Measured

On the current core:

  • Core bundle: 258,956 → 201,624 bytes (−22.1%, −57 KB).
  • Native lg binary (-s -w ldflags): −66 KB.
  • The stripped core boots and passes the rt, vm, and compiler suites.

The tradeoff

Stripping is not free: a runtime error originating in clojure.core reports without a source location, and local-var names are gone from core frames. So this stays opt-in and release-only, the same posture #502 takes for compression — the committed artifact is untouched and the size win is a release build's choice, not a silent default.

A workable shape for that choice is a build-strip make target: regenerate the core with -strip, build, then restore the full-debug core (so the working tree is never left with a stripped core checked in). Whether the release lever is a make target, a build tag, or folded into the compression path is open — it should probably be decided together with #501/#502 rather than piecemeal.

Scope note

This strips the -w program bundle. The core embedded inside the wasm binary is pkg/rt's fixed //go:embed core_compiled.lgb, which buildWasm can't swap without an embed-override mechanism — so stripping the wasm core is a separate follow-up, not part of this.

Status

There's a working prototype: the two flag wirings, the build-strip recipe, and a test that asserts the regenerated core decodes debug-free and is smaller than the committed one. It's held on a branch rather than opened as a PR, pending the compression direction in #501/#502, so the footprint changes land as one coherent story instead of colliding on the same core generator. I'll open the PR once that settles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions