authorgravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-09-01 14:32:02-05:00
committergravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-09-22 13:58:49-05:00
logd6e87da47b61ac31fe93a212d4f47eae55fec492
treed57a5ef5d791385d9b55072f338735a79c8f5ba4
parent3b09262c1252de0d9f946630e701be65bc5b2fc7

Make stage2 start.zig work on Windows


1 files changed, 12 insertions(+), 0 deletions(-)

lib/std/start.zig+12
......@@ -28,6 +28,8 @@ comptime {
2828 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
2929 @export(main2, .{ .name = "main" });
3030 }
31 } else if (builtin.stage2_os == .windows) {
32 @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
3133 } else {
3234 if (!@hasDecl(root, "_start")) {
3335 @export(_start2, .{ .name = "_start" });
......@@ -96,6 +98,11 @@ fn callMain2() noreturn {
9698 exit2(0);
9799}
98100
101fn wWinMainCRTStartup2() callconv(.C) noreturn {
102 root.main();
103 exit2(0);
104}
105
99106fn exit2(code: usize) noreturn {
100107 switch (native_os) {
101108 .linux => switch (builtin.stage2_arch) {
......@@ -148,11 +155,16 @@ fn exit2(code: usize) noreturn {
148155 },
149156 else => @compileError("TODO"),
150157 },
158 .windows => {
159 ExitProcess(@truncate(u32, code));
160 },
151161 else => @compileError("TODO"),
152162 }
153163 unreachable;
154164}
155165
166extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn;
167
156168////////////////////////////////////////////////////////////////////////////////
157169
158170fn _DllMainCRTStartup(