mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
compiler: fix and simplify DllMainCRTStartup handling
See: https://github.com/llvm/llvm-project/pull/171680
This commit is contained in:
+4
-3
@@ -20,8 +20,9 @@ comptime {
|
|||||||
_ = root;
|
_ = root;
|
||||||
|
|
||||||
if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
|
if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
|
||||||
if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
|
const dll_main_crt_startup = if (builtin.abi.isGnu()) "DllMainCRTStartup" else "_DllMainCRTStartup";
|
||||||
@export(&_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
|
if (native_os == .windows and !builtin.link_libc and !@hasDecl(root, dll_main_crt_startup)) {
|
||||||
|
@export(&DllMainCRTStartup, .{ .name = dll_main_crt_startup });
|
||||||
}
|
}
|
||||||
} else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
|
} else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
|
||||||
if (builtin.link_libc and @hasDecl(root, "main")) {
|
if (builtin.link_libc and @hasDecl(root, "main")) {
|
||||||
@@ -71,7 +72,7 @@ comptime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _DllMainCRTStartup(
|
fn DllMainCRTStartup(
|
||||||
hinstDLL: std.os.windows.HINSTANCE,
|
hinstDLL: std.os.windows.HINSTANCE,
|
||||||
fdwReason: std.os.windows.DWORD,
|
fdwReason: std.os.windows.DWORD,
|
||||||
lpReserved: std.os.windows.LPVOID,
|
lpReserved: std.os.windows.LPVOID,
|
||||||
|
|||||||
@@ -1746,6 +1746,7 @@ pub const Object = struct {
|
|||||||
if (name.eqlSlice("WinMainCRTStartup", ip)) flags.winmain_crt_startup = true;
|
if (name.eqlSlice("WinMainCRTStartup", ip)) flags.winmain_crt_startup = true;
|
||||||
if (name.eqlSlice("wWinMainCRTStartup", ip)) flags.wwinmain_crt_startup = true;
|
if (name.eqlSlice("wWinMainCRTStartup", ip)) flags.wwinmain_crt_startup = true;
|
||||||
if (name.eqlSlice("DllMainCRTStartup", ip)) flags.dllmain_crt_startup = true;
|
if (name.eqlSlice("DllMainCRTStartup", ip)) flags.dllmain_crt_startup = true;
|
||||||
|
if (name.eqlSlice("_DllMainCRTStartup", ip)) flags.dllmain_crt_startup = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-11
@@ -637,17 +637,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void {
|
|||||||
try argv.append("-ALTERNATENAME:__image_base__=__ImageBase");
|
try argv.append("-ALTERNATENAME:__image_base__=__ImageBase");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dyn_lib) {
|
try argv.append(try comp.crtFileAsString(arena, if (is_dyn_lib) "dllcrt2.obj" else "crt2.obj"));
|
||||||
try argv.append(try comp.crtFileAsString(arena, "dllcrt2.obj"));
|
|
||||||
if (target.cpu.arch == .x86) {
|
|
||||||
try argv.append("-ALTERNATENAME:__DllMainCRTStartup@12=_DllMainCRTStartup@12");
|
|
||||||
} else {
|
|
||||||
try argv.append("-ALTERNATENAME:_DllMainCRTStartup=DllMainCRTStartup");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try argv.append(try comp.crtFileAsString(arena, "crt2.obj"));
|
|
||||||
}
|
|
||||||
|
|
||||||
try argv.append(try comp.crtFileAsString(arena, "libmingw32.lib"));
|
try argv.append(try comp.crtFileAsString(arena, "libmingw32.lib"));
|
||||||
} else {
|
} else {
|
||||||
try argv.append(switch (comp.config.link_mode) {
|
try argv.append(switch (comp.config.link_mode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user