build: fat static archive and ubsan fix for external linkers#12217
Open
deblasis wants to merge 3 commits intoghostty-org:mainfrom
Open
build: fat static archive and ubsan fix for external linkers#12217deblasis wants to merge 3 commits intoghostty-org:mainfrom
deblasis wants to merge 3 commits intoghostty-org:mainfrom
Conversation
67f75cd to
999d7b8
Compare
Contributor
|
Rebase this please |
The static libghostty archive previously only bundled vendored dependencies on macOS (via libtool). On Windows and Linux the archive contained only the Zig-compiled code, leaving consumers to discover and link freetype, harfbuzz, glslang, spirv-cross, simdutf, oniguruma, and other vendored deps separately. Now all platforms produce a single fat archive: - macOS: libtool (unchanged) - Windows: zig ar qcL --format=coff (LLVM archiver with the L flag to flatten nested archives; MSVC's lib.exe cannot read Zig-produced GNU-format archives) - Linux: ar -M with MRI scripts (same as libghostty-vt) This makes the static library self-contained for consumers like .NET NativeAOT that link via the platform linker (MSVC link.exe) and need all symbols resolved from a single archive.
Zig's ubsan runtime cannot be bundled on Windows (LNK4229), leaving __ubsan_handle_* symbols unresolved when the static archive is consumed by an external linker like MSVC link.exe. freetype, glslang, spirv-cross, and highway already suppress ubsan unconditionally. Add MSVC-conditional suppression to the seven C dependencies that were missing it: harfbuzz, libpng, dcimgui, wuffs, oniguruma, zlib, and stb. The fix is gated on abi == .msvc so ubsan coverage is preserved on Linux and macOS where bundle_ubsan_rt works.
999d7b8 to
2020905
Compare
Contributor
Author
|
done |
mitchellh
requested changes
Apr 13, 2026
| /// Combine multiple static archives into a single fat archive. | ||
| /// Uses libtool on Darwin, lib.exe on Windows, and ar MRI scripts | ||
| /// on other platforms. | ||
| fn combineArchives( |
Contributor
There was a problem hiding this comment.
Would be nice to combine this with ghosttylibvt combineArchives and also fix the names to the new internal name here.
Extract CombineArchivesStep.zig so both GhosttyLib and GhosttyLibVt use the same archive-combining logic. Uses libtool on Darwin and the cross-platform combine_archives build tool elsewhere. Renames the internal library's fat archive outputs from ghostty to ghostty-internal, matching the pkg-config rename from PR 12214.
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.
Summary
Important
Stacked on #12214. Review that first. (i am targeting
mainso here you will see the full changeset, including 12214Two changes that make the static libghostty archive consumable by external linkers (MSVC link.exe, .NET NativeAOT, Rust, Go, etc.):
Fat static archive on all platforms
The static archive previously only bundled vendored deps on macOS (via libtool). On Windows and Linux the archive contained only the Zig-compiled code, requiring consumers to find and link freetype, harfbuzz, glslang, spirv-cross, simdutf, oniguruma, etc. separately.
Now all platforms produce a single fat archive:
MSVC ubsan suppression for C deps
Zig's ubsan runtime can't be bundled on Windows (LNK4229), leaving _ubsan_handle* symbols unresolved. freetype, glslang, spirv-cross, and highway already suppress ubsan. This adds MSVC-conditional suppression to seven more: harfbuzz, libpng, dcimgui, wuffs, oniguruma, zlib, and stb.
Gated on abi == .msvc so ubsan coverage is preserved on Linux/macOS.
Test plan