| ... | @@ -28,6 +28,8 @@ comptime { | ... | @@ -28,6 +28,8 @@ comptime { |
| 28 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { | 28 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { |
| 29 | @export(main2, .{ .name = "main" }); | 29 | @export(main2, .{ .name = "main" }); |
| 30 | } | 30 | } |
| | 31 | } else if (builtin.stage2_os == .windows) { |
| | 32 | @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" }); |
| 31 | } else { | 33 | } else { |
| 32 | if (!@hasDecl(root, "_start")) { | 34 | if (!@hasDecl(root, "_start")) { |
| 33 | @export(_start2, .{ .name = "_start" }); | 35 | @export(_start2, .{ .name = "_start" }); |
| ... | @@ -96,6 +98,11 @@ fn callMain2() noreturn { | ... | @@ -96,6 +98,11 @@ fn callMain2() noreturn { |
| 96 | exit2(0); | 98 | exit2(0); |
| 97 | } | 99 | } |
| 98 | | 100 | |
| | 101 | fn wWinMainCRTStartup2() callconv(.C) noreturn { |
| | 102 | root.main(); |
| | 103 | exit2(0); |
| | 104 | } |
| | 105 | |
| 99 | fn exit2(code: usize) noreturn { | 106 | fn exit2(code: usize) noreturn { |
| 100 | switch (native_os) { | 107 | switch (native_os) { |
| 101 | .linux => switch (builtin.stage2_arch) { | 108 | .linux => switch (builtin.stage2_arch) { |
| ... | @@ -148,11 +155,16 @@ fn exit2(code: usize) noreturn { | ... | @@ -148,11 +155,16 @@ fn exit2(code: usize) noreturn { |
| 148 | }, | 155 | }, |
| 149 | else => @compileError("TODO"), | 156 | else => @compileError("TODO"), |
| 150 | }, | 157 | }, |
| | 158 | .windows => { |
| | 159 | ExitProcess(@truncate(u32, code)); |
| | 160 | }, |
| 151 | else => @compileError("TODO"), | 161 | else => @compileError("TODO"), |
| 152 | } | 162 | } |
| 153 | unreachable; | 163 | unreachable; |
| 154 | } | 164 | } |
| 155 | | 165 | |
| | 166 | extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn; |
| | 167 | |
| 156 | //////////////////////////////////////////////////////////////////////////////// | 168 | //////////////////////////////////////////////////////////////////////////////// |
| 157 | | 169 | |
| 158 | fn _DllMainCRTStartup( | 170 | fn _DllMainCRTStartup( |