aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/start.zig')
-rw-r--r--lib/std/start.zig8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig
index 7ed59a4675..29fdb3b031 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 });
}