From 6d5002028a2fe71b67d8106b30c6602bc8e44121 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 19 May 2021 21:59:21 +0200 Subject: cc,wasi: link compiled WASI libc with wasm-ld --- src/link/Wasm.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/link/Wasm.zig') diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 41b08b09d6..8e296b2b6a 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -573,6 +573,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { null; const target = self.base.options.target; + const link_in_crt = self.base.options.link_libc and self.base.options.output_mode == .Exe; const id_symlink_basename = "lld.id"; @@ -695,6 +696,18 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { full_out_path, }); + if (link_in_crt) { + // TODO work out if we want standard crt, a reactor or a command + try argv.append(try comp.get_libc_crt_file(arena, "crt.o.wasm")); + } + + if (!is_obj and self.base.options.link_libc) { + try argv.append(try comp.get_libc_crt_file(arena, switch (self.base.options.link_mode) { + .Static => "libc.a", + .Dynamic => unreachable, + })); + } + // Positional arguments to the linker such as object files. try argv.appendSlice(self.base.options.objects); -- cgit v1.2.3