mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-24 05:40:15 +00:00
windows: provide DllMain stub for non-MSVC ABI
Part of preparation for upstreaming a Win32 application runtime (see discussion #2563). This is one of three small build-related fixes that unblock the Windows GNU-ABI library build. When targeting Windows with GNU ABI, the existing `DllMain` declaration falls through to `void` (a type), which Zig stdlib's `start.zig` then attempts to call as a function via `root.DllMain(...)` - producing the compile error "type 'type' not a function". Restructure the conditional so that: - non-Windows builds keep `DllMain = void` - Windows + MSVC keeps the existing CRT-init handler (unchanged) - Windows + non-MSVC gets a no-op `BOOL` handler This unblocks `zig build -Dtarget=native-native-gnu -Dapp-runtime=none` on Windows.
This commit is contained in:
@@ -168,8 +168,7 @@ pub export fn ghostty_string_free(str: String) void {
|
||||
// but not MSVC. No upstream issue tracks this exact gap as of 2026-03-26.
|
||||
// Closest: Codeberg ziglang/zig #30936 (reimplement crt0 code).
|
||||
// Remove this DllMain when Zig handles MSVC DLL CRT init natively.
|
||||
pub const DllMain = if (builtin.os.tag == .windows and
|
||||
builtin.abi == .msvc) struct {
|
||||
pub const DllMain = if (builtin.os.tag != .windows) void else if (builtin.abi == .msvc) struct {
|
||||
const BOOL = std.os.windows.BOOL;
|
||||
const HINSTANCE = std.os.windows.HINSTANCE;
|
||||
const DWORD = std.os.windows.DWORD;
|
||||
@@ -200,7 +199,19 @@ pub const DllMain = if (builtin.os.tag == .windows and
|
||||
else => return TRUE,
|
||||
}
|
||||
}
|
||||
}.handler else void;
|
||||
}.handler else struct {
|
||||
// GNU ABI: provide a no-op DllMain so Zig's start.zig doesn't
|
||||
// try to call a type instead of a function.
|
||||
const BOOL = std.os.windows.BOOL;
|
||||
const HINSTANCE = std.os.windows.HINSTANCE;
|
||||
const DWORD = std.os.windows.DWORD;
|
||||
const LPVOID = std.os.windows.LPVOID;
|
||||
const TRUE = std.os.windows.TRUE;
|
||||
|
||||
pub fn handler(_: HINSTANCE, _: DWORD, _: LPVOID) callconv(.winapi) BOOL {
|
||||
return TRUE;
|
||||
}
|
||||
}.handler;
|
||||
|
||||
test "ghostty_string_s empty string" {
|
||||
const testing = std.testing;
|
||||
|
||||
Reference in New Issue
Block a user