diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-11-05 18:44:12 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-05 18:44:12 -0500 |
| commit | 702b809ea3e9b9dbdc1fd6efe9306442487e7103 (patch) | |
| tree | bd639378ad2931013ff49789aadfc2104093261c /lib/std/start.zig | |
| parent | bec36aa7c028f2eaec94a2358f3e1326fcb9a30c (diff) | |
| parent | c893f837151d4764fd34911376836a01192b4d75 (diff) | |
| download | zig-702b809ea3e9b9dbdc1fd6efe9306442487e7103.tar.gz zig-702b809ea3e9b9dbdc1fd6efe9306442487e7103.zip | |
Merge pull request #17815 from Luukdegram/wasm-no-entry
wasm-linker: implement `-fno-entry` and correctly pass `--shared` and `--pie` when given
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 7925ea9168..ff21ed8187 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -82,11 +82,15 @@ comptime { .reactor => "_initialize", .command => "_start", }; - if (!@hasDecl(root, wasm_start_sym)) { + if (!@hasDecl(root, wasm_start_sym) and @hasDecl(root, "main")) { + // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which + // case it's not required to provide an entrypoint such as main. @export(wasi_start, .{ .name = wasm_start_sym }); } } else if (native_arch.isWasm() and native_os == .freestanding) { - if (!@hasDecl(root, start_sym_name)) @export(wasm_freestanding_start, .{ .name = start_sym_name }); + // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which + // case it's not required to provide an entrypoint such as main. + if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(wasm_freestanding_start, .{ .name = start_sym_name }); } else if (native_os != .other and native_os != .freestanding) { if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name }); } |
