build: fix static libghostty-vt linking on Windows

This PR fixes static linking for libghostty-vt on Windows by propagating
a couple of missing dependencies (discovered while running Neovim's Zig
build, see
https://github.com/neovim/neovim/actions/runs/30130848061/job/89604799965?pr=39773).
This commit is contained in:
Riccardo Mazzarini
2026-07-25 11:48:26 +02:00
committed by Mitchell Hashimoto
parent 40ab02e338
commit 1fe1b2d23c
3 changed files with 13 additions and 0 deletions

View File

@@ -742,6 +742,10 @@ jobs:
- name: Build libghostty-vt
run: zig build -Demit-lib-vt
- name: Test static linking
working-directory: example/c-vt-static
run: zig build
build-libghostty-windows-gnu:
runs-on: namespace-profile-ghostty-windows
timeout-minutes: 45

View File

@@ -14,6 +14,7 @@ pub fn build(b: *std.Build) void {
.root = b.path("src"),
.files = &.{"main.c"},
});
exe_mod.addCMacro("GHOSTTY_STATIC", "");
// You'll want to use a lazy dependency here so that ghostty is only
// downloaded if you actually need it.

View File

@@ -247,6 +247,14 @@ fn initLib(
// Zig's ubsan emits /exclude-symbols linker directives that
// are incompatible with the MSVC linker (LNK4229).
lib.bundle_ubsan_rt = false;
if (kind == .static) {
// compiler_rt expects ntdll to provide _fltused when libc is
// linked, and the Zig standard library uses other NT and kernel32
// symbols.
lib.root_module.linkSystemLibrary("ntdll", .{});
lib.root_module.linkSystemLibrary("kernel32", .{});
}
}
if (lib.rootModuleTarget().abi.isAndroid()) {