diff options
| author | Takeshi Yoneda <takeshi@tetrate.io> | 2021-07-27 08:59:34 +0900 |
|---|---|---|
| committer | Takeshi Yoneda <takeshi@tetrate.io> | 2021-07-27 09:01:00 +0900 |
| commit | 1e20a62126e66d0306a6db01b3a2ffd6b946b9b6 (patch) | |
| tree | f324d0497c78a25144c06f4e2a9c69a2e3a5a658 /lib/std/start.zig | |
| parent | fc105f268149b195ea4a4189da59d40e96e455b4 (diff) | |
| download | zig-1e20a62126e66d0306a6db01b3a2ffd6b946b9b6.tar.gz zig-1e20a62126e66d0306a6db01b3a2ffd6b946b9b6.zip | |
WASI,libc: enable tests.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 1a290a90db..b8e26869f0 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -46,7 +46,9 @@ comptime { } } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { if (builtin.link_libc and @hasDecl(root, "main")) { - if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { + if (native_arch.isWasm()) { + @export(mainWithoutEnv, .{ .name = "main" }); + } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { @export(main, .{ .name = "main" }); } } else if (native_os == .windows) { @@ -420,6 +422,11 @@ fn main(c_argc: i32, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) callconv(.C) return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), c_argv, envp }); } +fn mainWithoutEnv(c_argc: i32, c_argv: [*][*:0]u8) callconv(.C) usize { + std.os.argv = c_argv[0..@intCast(usize, c_argc)]; + return @call(.{ .modifier = .always_inline }, callMain, .{}); +} + // General error message for a malformed return type const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'"; |
