Repository navigation
Conversation
fornwall
force-pushed
the
one-text-section
branch
from
August 9, 2026 10:58
f848494 to
af0f583
Compare
The lib-vt Zig compilation unit was emitted as one text and data section, so linker garbage collection retained the entire C API. Enable per-function and per-data sections for static artifacts. Force LLVM code generation because the self-hosted x86 backend accepts these flags without splitting the unit, while leaving shared artifacts unchanged. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
We can continue to let x86-64 Linux use the self-hosted backend for debug builds.
fornwall
force-pushed
the
one-text-section
branch
from
August 9, 2026 19:37
a4558ee to
19cc796
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The lib-vt Zig compilation unit was emitted as one text and data section, so linker garbage collection retained the entire C API.
Enable per-function and per-data sections for static artifacts. Force LLVM code generation because the self-hosted x86 backend accepts these flags without splitting the unit, while leaving shared artifacts unchanged.
Ghostling size impact
Ghostling PR #17 updates Ghostling for the current lib-vt API and Zig 0.16. Its branch links the shared
ghostty-vttarget, while current Ghostty provides aghostty-vt-staticimported target withGHOSTTY_STATICand the platform link dependencies. Changing that one target makes Ghostling build successfully against the static lib-vt.I built the PR #17 branch twice against adjacent Ghostty commits, changing only whether this patch was applied:
f64f4acbefore andf848494after.ghostty_*definitionsFor context, the stripped shared build was 1,433,088 bytes for
ghostlingplus 2,006,064 bytes forlibghostty-vt.so, or 3,439,152 bytes together. The patched static executable was 323,576 bytes (9.41%) smaller than that two-file payload.Seeing similar savings in another internal program embedding libghostty.
Measurement environment
89da5be, Raylib 5.5, and current Ghostty (f64f4acversus this PR'sf848494)/home/linuxbrew/.linuxbrew/bin/zig, GCC 15.2.0, GNU ld/strip 2.46, CMake 4.2.3, and Ninja 1.13.2Both static variants changed Ghostling's link target to
ghostty-vt-staticand used:This compiles Ghostling and Raylib with
-O3 -DNDEBUG. Ghostty's CMake wrapper maps the Release configuration to ZigReleaseFastand invokeszig build -Demit-lib-vt -Doptimize=ReleaseFast.Verification
ghostty_*symbol instead of all 189..text$...and.rdata$...sections; Mach-O emitsMH_SUBSECTIONS_VIA_SYMBOLS.Tradeoffs
LLVM references
-ffunction-sections-fdata-sectionsTargetMachinesection controls