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