| ... | @@ -65,9 +65,16 @@ comptime { | ... | @@ -65,9 +65,16 @@ comptime { |
| 65 | } | 65 | } |
| 66 | } else if (native_os == .uefi) { | 66 | } else if (native_os == .uefi) { |
| 67 | if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" }); | 67 | if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" }); |
| 68 | } else if (native_arch.isWasm()) { | 68 | } else if (native_os == .wasi) { |
| 69 | const wasm_start_sym = if (builtin.wasi_exec_model == .reactor) "_initialize" else "_start"; | 69 | const wasm_start_sym = switch (builtin.wasi_exec_model) { |
| 70 | if (!@hasDecl(root, wasm_start_sym)) @export(wasm_start, .{ .name = wasm_start_sym }); | 70 | .reactor => "_initialize", |
| | 71 | .command => "_start", |
| | 72 | }; |
| | 73 | if (!@hasDecl(root, wasm_start_sym)) { |
| | 74 | @export(wasi_start, .{ .name = wasm_start_sym }); |
| | 75 | } |
| | 76 | } else if (native_arch.isWasm() and native_os == .freestanding) { |
| | 77 | if (!@hasDecl(root, start_sym_name)) @export(wasm_freestanding_start, .{ .name = start_sym_name }); |
| 71 | } else if (native_os != .other and native_os != .freestanding) { | 78 | } else if (native_os != .other and native_os != .freestanding) { |
| 72 | if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name }); | 79 | if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name }); |
| 73 | } | 80 | } |
| ... | @@ -136,20 +143,18 @@ fn _DllMainCRTStartup( | ... | @@ -136,20 +143,18 @@ fn _DllMainCRTStartup( |
| 136 | return std.os.windows.TRUE; | 143 | return std.os.windows.TRUE; |
| 137 | } | 144 | } |
| 138 | | 145 | |
| 139 | fn wasm_start() callconv(.C) void { | 146 | fn wasm_freestanding_start() callconv(.C) void { |
| 140 | // The entrypoint is marked inline because for some reason LLVM in release mode fails to inline it, | 147 | // This is marked inline because for some reason LLVM in |
| 141 | // and we want fewer call frames in stack traces. | 148 | // release mode fails to inline it, and we want fewer call frames in stack traces. |
| 142 | switch (native_os) { | 149 | _ = @call(.{ .modifier = .always_inline }, callMain, .{}); |
| 143 | .freestanding => { | 150 | } |
| 144 | _ = @call(.{ .modifier = .always_inline }, callMain, .{}); | 151 | |
| 145 | }, | 152 | fn wasi_start() callconv(.C) void { |
| 146 | .wasi => { | 153 | // The function call is marked inline because for some reason LLVM in |
| 147 | switch (builtin.wasi_exec_model) { | 154 | // release mode fails to inline it, and we want fewer call frames in stack traces. |
| 148 | .reactor => _ = @call(.{ .modifier = .always_inline }, callMain, .{}), | 155 | switch (builtin.wasi_exec_model) { |
| 149 | .command => std.os.wasi.proc_exit(@call(.{ .modifier = .always_inline }, callMain, .{})), | 156 | .reactor => _ = @call(.{ .modifier = .always_inline }, callMain, .{}), |
| 150 | } | 157 | .command => std.os.wasi.proc_exit(@call(.{ .modifier = .always_inline }, callMain, .{})), |
| 151 | }, | | |
| 152 | else => @compileError("unsupported OS"), | | |
| 153 | } | 158 | } |
| 154 | } | 159 | } |
| 155 | | 160 | |