mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:04:43 +01:00
compiler: fix and simplify DllMainCRTStartup handling
See: https://github.com/llvm/llvm-project/pull/171680
This commit is contained in:
parent
4eb6a3703b
commit
0eb6876aed
3 changed files with 6 additions and 14 deletions
|
|
@ -20,8 +20,9 @@ comptime {
|
|||
_ = root;
|
||||
|
||||
if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
|
||||
if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
|
||||
@export(&_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
|
||||
const dll_main_crt_startup = if (builtin.abi.isGnu()) "DllMainCRTStartup" else "_DllMainCRTStartup";
|
||||
if (native_os == .windows and !@hasDecl(root, dll_main_crt_startup)) {
|
||||
@export(&DllMainCRTStartup, .{ .name = dll_main_crt_startup });
|
||||
}
|
||||
} else if (builtin.output_mode == .Exe or @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,
|
||||
fdwReason: std.os.windows.DWORD,
|
||||
lpReserved: std.os.windows.LPVOID,
|
||||
|
|
|
|||
|
|
@ -1648,6 +1648,7 @@ pub const Object = struct {
|
|||
if (name.eqlSlice("WinMainCRTStartup", ip)) flags.winmain_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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -637,17 +637,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void {
|
|||
try argv.append("-ALTERNATENAME:__image_base__=__ImageBase");
|
||||
}
|
||||
|
||||
if (is_dyn_lib) {
|
||||
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, if (is_dyn_lib) "dllcrt2.obj" else "crt2.obj"));
|
||||
try argv.append(try comp.crtFileAsString(arena, "libmingw32.lib"));
|
||||
} else {
|
||||
try argv.append(switch (comp.config.link_mode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue