Repository navigation
build: add ghostty-internal pkg-config modules (shared + static) - #12214
Conversation
|
If this one lands, next one would be to create a "fat archive" for windows as well. I will 90% hit a wall with NativeAOT on windows with winui3 but regardless, that's something MS is supposedly working on. UpdateI hit the wall eventually but found workarounds and managed to get a single executable for Ghostty Windows! I filed an issue upstream for anyone else bumping into the same problem: microsoft/WindowsAppSDK#6394 |
|
Lets rename these to
|
mitchellh
left a comment
There was a problem hiding this comment.
Blocked on some naming.
b2935cb to
66ffe8f
Compare
66ffe8f to
dd04856
Compare
| return if (os_tag == .windows) | ||
| "ghostty-static.lib" | ||
| else | ||
| "libghostty.a"; |
There was a problem hiding this comment.
Let's rename this too. And anywhere else we write it out, let's use this PR to fix it up.
There was a problem hiding this comment.
I hope I didn't miss/mess up anything :)
Rename the internal library's install names to match the new ghostty-internal pkg-config module convention: ghostty.dll -> ghostty-internal.dll ghostty-static.lib -> ghostty-internal-static.lib libghostty.so -> ghostty-internal.so libghostty.a -> ghostty-internal.a This is the glue library between Ghostty's app shells and the GUI core, historically (mis)named "libghostty". It is not the public libghostty-vt API.
Switch the shared ghostty-internal.pc Libs: line from -lghostty to a
direct ${libdir}/<file> path, matching what the -static module already
does. The name-per-OS helpers now emit:
shared: ghostty-internal.dll (Windows) / ghostty-internal.so (other)
static: ghostty-internal-static.lib (Windows) / ghostty-internal.a
Direct paths sidestep the GNU-ld -l<name> search template, which
expects libghostty-internal.so/.a on Unix - we drop the lib prefix to
match the ghostty-internal pkg-config module name.
Also update the LipoStep out_name for the macOS universal static
archive to ghostty-internal.a for consistency.
The internal glue DLL was renamed from ghostty.dll to ghostty-internal.dll. Update the LoadLibraryA call and the comment block so this regression test still exercises the right artifact.
Match the dll filename rename so the copy/run instructions stay accurate.
## Summary > [!IMPORTANT] > Stacked on #12214. Review that first. (i am targeting `main` so here you will see the full changeset, including 12214 Two 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: - macOS: libtool (unchanged) - Windows: zig ar qcL --format=coff (MSVC's lib.exe can't read Zig-produced GNU-format archives, so we use the bundled LLVM archiver) - Linux: ar -M with MRI scripts (same approach as libghostty-vt) **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 - [x] zig build produces a fat ghostty-static.lib (~230MB) with ~200 object files - [x] MSVC's lib /LIST can read the archive - [x] .NET NativeAOT consumer resolves all symbols (0 unresolved) - [x] Linux/macOS builds unaffected (ubsan remains enabled)
Summary
Mirror the
libghostty-vt-staticpkg-config pattern from #12210 for the internal library.ghostty-internal.pc(shared,-lghostty) andghostty-internal-static.pc(static, direct archive reference) so consumers can discover either variant via pkg-configghostty-internalto distinguish from the publiclibghostty-vtAPIghostty-static.libon Windows,libghostty.aelsewhere)GhosttyLib.install()Test plan
zig buildsucceeds (default target)ghostty-internal.pcandghostty-internal-static.pcappear inzig-out/share/pkgconfig/.pcpoints atghostty-static.lib(Windows) /libghostty.a(Unix).pcuses standard-L -lflagslibghostty-vtpkg-config files are unaffected