| ... | @@ -23,6 +23,10 @@ comptime { | ... | @@ -23,6 +23,10 @@ comptime { |
| 23 | const dll_main_crt_startup = if (builtin.abi.isGnu()) "DllMainCRTStartup" else "_DllMainCRTStartup"; | 23 | const dll_main_crt_startup = if (builtin.abi.isGnu()) "DllMainCRTStartup" else "_DllMainCRTStartup"; |
| 24 | if (native_os == .windows and !builtin.link_libc and !@hasDecl(root, dll_main_crt_startup)) { | 24 | if (native_os == .windows and !builtin.link_libc and !@hasDecl(root, dll_main_crt_startup)) { |
| 25 | @export(&DllMainCRTStartup, .{ .name = dll_main_crt_startup }); | 25 | @export(&DllMainCRTStartup, .{ .name = dll_main_crt_startup }); |
| | 26 | } else if (native_os == .windows and builtin.link_libc and @hasDecl(root, "DllMain")) { |
| | 27 | if (!@typeInfo(@TypeOf(root.DllMain)).@"fn".calling_convention.eql(.winapi)) { |
| | 28 | @export(&DllMain, .{ .name = "DllMain" }); |
| | 29 | } |
| 26 | } | 30 | } |
| 27 | } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { | 31 | } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { |
| 28 | if (builtin.link_libc and @hasDecl(root, "main")) { | 32 | if (builtin.link_libc and @hasDecl(root, "main")) { |
| ... | @@ -88,6 +92,14 @@ fn DllMainCRTStartup( | ... | @@ -88,6 +92,14 @@ fn DllMainCRTStartup( |
| 88 | return .TRUE; | 92 | return .TRUE; |
| 89 | } | 93 | } |
| 90 | | 94 | |
| | 95 | fn DllMain( |
| | 96 | hinstDLL: std.os.windows.HINSTANCE, |
| | 97 | fdwReason: std.os.windows.DWORD, |
| | 98 | lpReserved: std.os.windows.LPVOID, |
| | 99 | ) callconv(.winapi) std.os.windows.BOOL { |
| | 100 | return root.DllMain(hinstDLL, fdwReason, lpReserved); |
| | 101 | } |
| | 102 | |
| 91 | fn wasm_freestanding_start() callconv(.c) void { | 103 | fn wasm_freestanding_start() callconv(.c) void { |
| 92 | // This is marked inline because for some reason LLVM in | 104 | // This is marked inline because for some reason LLVM in |
| 93 | // release mode fails to inline it, and we want fewer call frames in stack traces. | 105 | // release mode fails to inline it, and we want fewer call frames in stack traces. |