authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-04-16 22:16:53+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-16 22:16:53+02:00
log7fad555e5e16e6cb71554981394387a0622093b0
treeeefa80f90af7d6e97716b291361a077b7584164e
parentb0186f31002760c9940d8c06c2ac7baa9d52f404
parent3ad092e1e7e007e53b4dc42c549cd6460ebdf8a5
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15271 from Luukdegram/wasm-start

wasm: no longer use simplified `start.zig` logic

2 files changed, 2 insertions(+), 21 deletions(-)

lib/std/start.zig-19
......@@ -18,7 +18,6 @@ const start_sym_name = if (native_arch.isMIPS()) "__start" else "_start";
1818// Until then, we have simplified logic here for self-hosted. TODO remove this once
1919// self-hosted is capable enough to handle all of the real start.zig logic.
2020pub const simplified_logic =
21 builtin.zig_backend == .stage2_wasm or
2221 (builtin.zig_backend == .stage2_x86_64 and (builtin.link_libc or builtin.os.tag == .plan9)) or
2322 builtin.zig_backend == .stage2_x86 or
2423 builtin.zig_backend == .stage2_aarch64 or
......@@ -43,8 +42,6 @@ comptime {
4342 if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) {
4443 @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
4544 }
46 } else if (builtin.os.tag == .wasi and @hasDecl(root, "main")) {
47 @export(wasiMain2, .{ .name = "_start" });
4845 } else if (builtin.os.tag == .opencl) {
4946 if (@hasDecl(root, "main"))
5047 @export(spirvMain2, .{ .name = "main" });
......@@ -116,22 +113,6 @@ fn callMain2() noreturn {
116113 exit2(0);
117114}
118115
119fn wasiMain2() callconv(.C) noreturn {
120 switch (@typeInfo(@typeInfo(@TypeOf(root.main)).Fn.return_type.?)) {
121 .Void => {
122 root.main();
123 std.os.wasi.proc_exit(0);
124 },
125 .Int => |info| {
126 if (info.bits != 8 or info.signedness == .signed) {
127 @compileError(bad_main_ret);
128 }
129 std.os.wasi.proc_exit(root.main());
130 },
131 else => @compileError("Bad return type main"),
132 }
133}
134
135116fn spirvMain2() callconv(.Kernel) void {
136117 root.main();
137118}
test/link/wasm/type/build.zig+2-2
......@@ -26,10 +26,10 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2626
2727 const check_lib = lib.checkObject();
2828 check_lib.checkStart("Section type");
29 // only 2 entries, although we have 3 functions.
29 // only 3 entries, although we have more functions.
3030 // This is to test functions with the same function signature
3131 // have their types deduplicated.
32 check_lib.checkNext("entries 2");
32 check_lib.checkNext("entries 3");
3333 check_lib.checkNext("params 1");
3434 check_lib.checkNext("type i32");
3535 check_lib.checkNext("returns 1");