aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/special/bootstrap.zig10
-rw-r--r--std/special/c.zig2
2 files changed, 8 insertions, 4 deletions
diff --git a/std/special/bootstrap.zig b/std/special/bootstrap.zig
index e6505c836b..e8f943b78c 100644
--- a/std/special/bootstrap.zig
+++ b/std/special/bootstrap.zig
@@ -25,21 +25,25 @@ nakedcc fn _start() noreturn {
}
switch (builtin.arch) {
- builtin.Arch.x86_64 => {
+ .x86_64 => {
argc_ptr = asm ("lea (%%rsp), %[argc]"
: [argc] "=r" (-> [*]usize)
);
},
- builtin.Arch.i386 => {
+ .i386 => {
argc_ptr = asm ("lea (%%esp), %[argc]"
: [argc] "=r" (-> [*]usize)
);
},
- builtin.Arch.aarch64, builtin.Arch.aarch64_be => {
+ .aarch64, .aarch64_be => {
argc_ptr = asm ("mov %[argc], sp"
: [argc] "=r" (-> [*]usize)
);
},
+ .wasm32, .wasm64 => {
+ _ = callMain();
+ while (true) {}
+ },
else => @compileError("unsupported arch"),
}
// If LLVM inlines stack variables into _start, they will overwrite
diff --git a/std/special/c.zig b/std/special/c.zig
index d5de52a6a3..281e177469 100644
--- a/std/special/c.zig
+++ b/std/special/c.zig
@@ -11,7 +11,7 @@ const maxInt = std.math.maxInt;
const is_wasm = switch (builtin.arch) { .wasm32, .wasm64 => true, else => false};
const is_freestanding = switch (builtin.os) { .freestanding => true, else => false };
comptime {
- if (is_freestanding and is_wasm) {
+ if (is_freestanding and is_wasm and builtin.link_libc) {
@export("_start", wasm_start, .Strong);
}
}