From 5d922226218802fbe9e147c45dd4908e82c731aa Mon Sep 17 00:00:00 2001 From: Alessandro De Blasis Date: Fri, 27 Mar 2026 04:18:16 +0100 Subject: [PATCH] windows: address review feedback on DLL CRT init PR Use b.allocator instead of b.graph.arena for SDK detection and path formatting -- b.allocator is the public API, b.graph.arena is an internal field. Move test_dll_init.c from windows/Ghostty.Tests/ to test/windows/ with a README. Test infrastructure belongs under test/, not the Windows app directory. --- src/build/GhosttyLib.zig | 4 +-- test/windows/README.md | 28 +++++++++++++++++++ .../windows}/test_dll_init.c | 0 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/windows/README.md rename {windows/Ghostty.Tests => test/windows}/test_dll_init.c (100%) diff --git a/src/build/GhosttyLib.zig b/src/build/GhosttyLib.zig index 498f24645..4e15fbbf4 100644 --- a/src/build/GhosttyLib.zig +++ b/src/build/GhosttyLib.zig @@ -109,7 +109,7 @@ pub fn initShared( // ucrt.lib is in the Windows SDK 'ucrt' dir. Detect the SDK // installation and add the UCRT library path. const arch = deps.config.target.result.cpu.arch; - const sdk = std.zig.WindowsSdk.find(b.graph.arena, arch) catch null; + const sdk = std.zig.WindowsSdk.find(b.allocator, arch) catch null; if (sdk) |s| { if (s.windows10sdk) |w10| { const arch_str: []const u8 = switch (arch) { @@ -119,7 +119,7 @@ pub fn initShared( else => "x64", }; const ucrt_lib_path = std.fmt.allocPrint( - b.graph.arena, + b.allocator, "{s}\\Lib\\{s}\\ucrt\\{s}", .{ w10.path, w10.version, arch_str }, ) catch null; diff --git a/test/windows/README.md b/test/windows/README.md new file mode 100644 index 000000000..ed0500fb0 --- /dev/null +++ b/test/windows/README.md @@ -0,0 +1,28 @@ +# Windows Tests + +Manual test programs for Windows-specific functionality. + +## test_dll_init.c + +Regression test for the DLL CRT initialization fix. Loads ghostty.dll +at runtime and calls ghostty_info + ghostty_init to verify the MSVC C +runtime is properly initialized. + +### Build + +``` +zig cc test_dll_init.c -o test_dll_init.exe -target native-native-msvc +``` + +### Run + +``` +copy ..\..\zig-out\lib\ghostty.dll . && test_dll_init.exe +``` + +Expected output (after the CRT fix): + +``` +ghostty_info: +ghostty_init: 0 +``` diff --git a/windows/Ghostty.Tests/test_dll_init.c b/test/windows/test_dll_init.c similarity index 100% rename from windows/Ghostty.Tests/test_dll_init.c rename to test/windows/test_dll_init.c