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";...@@ -18,7 +18,6 @@ const start_sym_name = if (native_arch.isMIPS()) "__start" else "_start";
18// Until then, we have simplified logic here for self-hosted. TODO remove this once18// Until then, we have simplified logic here for self-hosted. TODO remove this once
19// self-hosted is capable enough to handle all of the real start.zig logic.19// self-hosted is capable enough to handle all of the real start.zig logic.
20pub const simplified_logic =20pub const simplified_logic =
21 builtin.zig_backend == .stage2_wasm or
22 (builtin.zig_backend == .stage2_x86_64 and (builtin.link_libc or builtin.os.tag == .plan9)) or21 (builtin.zig_backend == .stage2_x86_64 and (builtin.link_libc or builtin.os.tag == .plan9)) or
23 builtin.zig_backend == .stage2_x86 or22 builtin.zig_backend == .stage2_x86 or
24 builtin.zig_backend == .stage2_aarch64 or23 builtin.zig_backend == .stage2_aarch64 or
...@@ -43,8 +42,6 @@ comptime {...@@ -43,8 +42,6 @@ comptime {
43 if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) {42 if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) {
44 @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });43 @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
45 }44 }
46 } else if (builtin.os.tag == .wasi and @hasDecl(root, "main")) {
47 @export(wasiMain2, .{ .name = "_start" });
48 } else if (builtin.os.tag == .opencl) {45 } else if (builtin.os.tag == .opencl) {
49 if (@hasDecl(root, "main"))46 if (@hasDecl(root, "main"))
50 @export(spirvMain2, .{ .name = "main" });47 @export(spirvMain2, .{ .name = "main" });
...@@ -116,22 +113,6 @@ fn callMain2() noreturn {...@@ -116,22 +113,6 @@ fn callMain2() noreturn {
116 exit2(0);113 exit2(0);
117}114}
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
135fn spirvMain2() callconv(.Kernel) void {116fn spirvMain2() callconv(.Kernel) void {
136 root.main();117 root.main();
137}118}
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...@@ -26,10 +26,10 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2626
27 const check_lib = lib.checkObject();27 const check_lib = lib.checkObject();
28 check_lib.checkStart("Section type");28 check_lib.checkStart("Section type");
29 // only 2 entries, although we have 3 functions.29 // only 3 entries, although we have more functions.
30 // This is to test functions with the same function signature30 // This is to test functions with the same function signature
31 // have their types deduplicated.31 // have their types deduplicated.
32 check_lib.checkNext("entries 2");32 check_lib.checkNext("entries 3");
33 check_lib.checkNext("params 1");33 check_lib.checkNext("params 1");
34 check_lib.checkNext("type i32");34 check_lib.checkNext("type i32");
35 check_lib.checkNext("returns 1");35 check_lib.checkNext("returns 1");