Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.

Add skip export --debug-info line-tables for faster debug native Android builds - #296

Merged
piercifani merged 6 commits into
mainfrom
perf/android-line-tables
Oct 13, 2026
Merged

piercifani merged 6 commits into
mainfrom
perf/android-line-tables

Conversation

@piercifani

@piercifani piercifani commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

skip android build is what Gradle runs for every Skip Fuse build and for skip export. It produced native libraries with full debug info: type DWARF plus every module's serialized AST, embedded in a .swift_ast section for a Swift-aware LLDB.

In debug builds, most projects don't use that information. Android Studio debugs native code with its bundled upstream LLDB 21 (plugins/android-ndk/resources/lldb/lib64/liblldb.dylib), which has no Swift support: 0 Swift type-system or runtime symbols, against 43 in Xcode's LLDB. So it can't show Swift variables or types whatever the debug info level. Debug builds also aren't what crash reporters symbolicate.

On a production Skip Fuse app with 16 Skip modules, the debug root library was 440 MB:

Section Size
.text (code) 112 MB
.debug_* 116 MB
.swift_ast 94 MB
.strtab + .symtab 90 MB

keepDebugSymbols("**/*.so") keeps AGP from stripping any of it, so Gradle compresses the whole library into the AAR on every build: bundleDebugAar took 11.7 s.

Change

A new skip export --debug-info <level> option, with full (the default, current behavior) and line-tables. A level rather than a flag leaves room for more levels later. It is documented in skip export --help like the other options, and the usage examples include it:

  --debug-info <level>    Debug info of the debug native libraries: line-tables
                          is faster to build and package; release libraries
                          keep full debug info (values: full, line-tables;
                          default: full)

The native libraries are built by the skip android build that SkipBridge's Gradle task runs, so the option reaches it the way --arch does. skip export --debug-info line-tables sets SKIP_EXPORT_DEBUG_INFO=line-tables for the Gradle process, next to SKIP_EXPORT_ARCHS.

For debug builds, runToolchainCommand then passes -debug-info-format none to swift build, together with -Xswiftc -gline-tables-only and -Xcc -gline-tables-only.

Under Swift Build, -Xswiftc -gline-tables-only alone has no effect: the build system's own debug information setting adds full debug info back. In a test, the library stayed at 441 MB with .swift_ast intact until -debug-info-format none was added.

The libraries keep .debug_line, so breakpoints, stepping and crash backtraces still have files and lines. Release builds keep full debug info even with --debug-info line-tables.

Usage

Export the debug variant faster:

skip export --debug --debug-info line-tables

Export one module, debug, one ABI:

skip export --module MyModule --debug --arch aarch64 --debug-info line-tables

Export both variants: without --debug or --release, skip export builds both. Only the debug libraries get line tables; the release ones keep full debug info.

skip export --debug-info line-tables

Check that it took effect. The exported library has no .swift_ast section:

unzip -o -q .build/skip-export/MyModule-debug.aar 'jni/arm64-v8a/*.so' -d /tmp/aar
xcrun llvm-objdump -h /tmp/aar/jni/arm64-v8a/libMyModule.so | grep swift_ast   # prints nothing with --debug-info line-tables

Behavior change

None by default. Without --debug-info line-tables, every export is unchanged.

With --debug-info line-tables, debug libraries are smaller and faster to build. The root library drops from 440 MB to 254 MB, and its AAR from 154 MB to 100 MB.

Android Studio's debugger behaves the same. Both test libraries (below) were loaded into upstream LLDB (the NDK's LLDB 19.0.1, the same upstream code Android Studio bundles):

Full debug info Line tables only
breakpoint set -f Crash.swift -l 5 0x11d0 0x11d0
breakpoint set -f Crash.swift -l 11 0x11f8 0x11f8
image lookup -a 0x1220 $s8CrashLib13totalNotionalySiSayAA5OrderVGF + 96 same
type lookup Order no type found no type found

Who would lose something by opting in: only someone who attaches Apple's Swift-aware LLDB from a swift.org toolchain to an Android debug build by hand.

Why release keeps full debug info. Crash reporters such as Sentry symbolicate release libraries, and with line tables only, inlined frames keep just their short name. In a release test library, a crash inside an inlined helper symbolicated through llvm-symbolizer --inlining like this:

Inlined frame name
Full debug info $s8CrashLib8notionalySiAA5OrderVF (CrashLib.notional(CrashLib.Order) -> Swift.Int)
Line tables only notional

The file, line and column (Crash.swift:5:29), the inline structure, and the non-inlined frame names were identical. sentry-cli debug-files check reported symtab, debug, unwind for both. But the short name loses its module and type, and it would change how native crashes are grouped.

Testing

M-series Mac, 14 cores, Swift 6.4, Swift Build, aarch64, debug configuration, the same 16-module app.

Gradle step that builds and packages the native library (assembleDebug of the transpiled project). Stock 1.9.13 against this branch with line tables only, with the same edits:

Stock 1.9.13 Opted in Change
After a public API change in a low-level module 93.0 s 81.6 s −11.4 s (−12%)
After a body edit 33.4 s 25.3 s −8.1 s (−24%)

Where the time goes inside that step:

Task Change after the API edit Change after the body edit
buildAndroidSwiftPackageDebug 76.4 → 70.8 s 16.9 → 14.6 s
bundleDebugAar 11.8 → 7.6 s 11.7 → 7.6 s

The native swift build on its own, run directly with the exact command skip android build issues, after the same public API edit:

Debug info Time Root library
Default 86.0 s 440 MB
-debug-info-format none 71.3 s 222 MB
-debug-info-format none + -gline-tables-only (this change) 71.1 s 254 MB

Section sizes with this change: .swift_ast is gone. .debug_info drops from 26 MB to 1.2 MB and .debug_str from 50 MB to 1.3 MB, while .debug_line stays at 16.5 MB.

skip export --debug-info line-tables end to end, with skip export --module App --no-export-project --debug --arch aarch64, run with and then without the option on the same Gradle daemon:

Root library .swift_ast AAR
--debug-info line-tables 254 MB gone 99 MB
default (full) 440 MB present 154 MB

skip android build flags per case:

SKIP_EXPORT_DEBUG_INFO (set by --debug-info) Debug Release
unset or full unchanged unchanged
line-tables -debug-info-format none -Xswiftc -gline-tables-only -Xcc -gline-tables-only unchanged

Not tested: a live Android Studio debugging session (the LLDB comparison above loaded the libraries without a running process), the native build system (older toolchains), Linux hosts, and running the app on a device with this build.

🤖 Generated with Claude Code

… debug info

Nothing debugs Swift on Android, yet `skip android build` produced full
debug info: type DWARF plus every module's AST embedded in the library for
LLDB. On a 16-module Skip Fuse app that made the root library 440 MB, of
which only 112 MB was code, and Gradle then compressed all of it into the
AAR on every build.

Debug Android builds now pass `-debug-info-format none` with
`-gline-tables-only` for Swift and C, which keeps files and lines for
crash backtraces. Release builds are unchanged: with line tables only,
inlined frames carry just their short name (`notional` rather than the
mangled `$s8CrashLib8notionalySiAA5OrderVF`), which would degrade crash
reporters such as Sentry. Passing any `-Xswiftc -g…` flag opts out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label Oct 8, 2026
…LES_ONLY

Debug native Android builds keep full debug info by default. Setting
SKIP_ANDROID_LINE_TABLES_ONLY=1 builds them with line tables only. An
environment variable reaches `skip android build` however it is invoked,
including from the Gradle task skip-bridge adds to Fuse apps, the same
way SKIP_EXPORT_ARCHS does. Release builds keep full debug info either
way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@piercifani piercifani changed the title Build debug native Android libraries with line tables instead of full debug info Add opt-in line-tables-only debug info for native Android debug builds Oct 8, 2026
…only

The opt-in is now a documented `skip export` flag that shows up in
`skip export --help` and its usage examples. Like `--arch`, it reaches
the `skip android build` that SkipBridge's Gradle task runs through an
environment variable set for the Gradle process,
SKIP_EXPORT_LINE_TABLES_ONLY, next to SKIP_EXPORT_ARCHS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@piercifani piercifani changed the title Add opt-in line-tables-only debug info for native Android debug builds Add skip export --line-tables-only for faster debug native Android builds Oct 8, 2026

@marcprux marcprux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@marcprux marcprux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On second thought, I think the "--line-tables-only" argument is a bit confusing. Could we change this to "--debug-info=line-tables" or "--debug-info=full" (or something like that)? That would give us the ability to add more options in the future without needing to add another parameter.

`--debug-info line-tables` builds the debug native libraries with only line
tables; `--debug-info full` (the default) keeps the current behavior. A level
option leaves room for more debug info levels without adding flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@piercifani piercifani changed the title Add skip export --line-tables-only for faster debug native Android builds Add skip export --debug-info line-tables for faster debug native Android builds Oct 11, 2026
@piercifani
piercifani requested a review from marcprux October 11, 2026 19:33
@piercifani
piercifani merged commit 906ca39 into main Oct 13, 2026
9 checks passed
@piercifani
piercifani deleted the perf/android-line-tables branch October 13, 2026 08:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants