From 8c1c67bdd0a636006e7ddbc14da8c2484b131df7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 11 Nov 2022 22:59:39 -0700 Subject: [PATCH] stage2: take advantage of the new WasmAllocator --- src/main.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 784cf3b29c..c8ac670d10 100644 --- a/src/main.zig +++ b/src/main.zig @@ -152,8 +152,14 @@ var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{ pub fn main() anyerror!void { crash_report.initialize(); - const use_gpa = build_options.force_gpa or !builtin.link_libc; + const use_gpa = (build_options.force_gpa or !builtin.link_libc) and builtin.os.tag != .wasi; const gpa = gpa: { + if (builtin.os.tag == .wasi) { + break :gpa Allocator{ + .ptr = undefined, + .vtable = &std.heap.WasmAllocator.vtable, + }; + } if (use_gpa) { break :gpa general_purpose_allocator.allocator(); }