| ... | ... | @@ -574,7 +574,6 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 574 | 574 | null; |
| 575 | 575 | |
| 576 | 576 | const target = self.base.options.target; |
| 577 | | const link_in_crt = self.base.options.link_libc and self.base.options.output_mode == .Exe; |
| 578 | 577 | |
| 579 | 578 | const id_symlink_basename = "lld.id"; |
| 580 | 579 | |
| ... | ... | @@ -653,8 +652,6 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 653 | 652 | try fs.cwd().copyFile(the_object_path, fs.cwd(), full_out_path, .{}); |
| 654 | 653 | } |
| 655 | 654 | } else { |
| 656 | | const is_obj = self.base.options.output_mode == .Obj; |
| 657 | | |
| 658 | 655 | // Create an LLD command line and invoke it. |
| 659 | 656 | var argv = std.ArrayList([]const u8).init(self.base.allocator); |
| 660 | 657 | defer argv.deinit(); |
| ... | ... | @@ -662,10 +659,6 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 662 | 659 | // This is necessary because LLD does not behave properly as a library - |
| 663 | 660 | // it calls exit() and does not reset all global data between invocations. |
| 664 | 661 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, "wasm-ld" }); |
| 665 | | if (is_obj) { |
| 666 | | try argv.append("-r"); |
| 667 | | } |
| 668 | | |
| 669 | 662 | try argv.append("-error-limit=0"); |
| 670 | 663 | |
| 671 | 664 | if (self.base.options.lto) { |
| ... | ... | @@ -697,25 +690,29 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 697 | 690 | full_out_path, |
| 698 | 691 | }); |
| 699 | 692 | |
| 700 | | if (link_in_crt) { |
| 701 | | // TODO work out if we want standard crt, a reactor or a command |
| 702 | | try argv.append(try comp.get_libc_crt_file(arena, "crt1.o")); |
| 703 | | } |
| 704 | | |
| 705 | | if (!is_obj) { |
| 706 | | const system_libs = self.base.options.system_libs.keys(); |
| 707 | | for (system_libs) |link_lib| { |
| 708 | | try argv.append(try std.fmt.allocPrint(arena, "-l{s}", .{link_lib})); |
| 693 | if (target.os.tag == .wasi) { |
| 694 | if (self.base.options.link_libc and self.base.options.output_mode == .Exe) { |
| 695 | // TODO work out if we want standard crt, a reactor or a command |
| 696 | try argv.append(try comp.get_libc_crt_file(arena, "crt1.o")); |
| 709 | 697 | } |
| 710 | 698 | |
| 711 | | const wasi_emulated_libs = self.base.options.wasi_emulated_libs; |
| 712 | | for (wasi_emulated_libs) |lib_name| { |
| 713 | | const full_lib_name = try std.fmt.allocPrint(arena, "lib{s}.a", .{lib_name}); |
| 714 | | try argv.append(try comp.get_libc_crt_file(arena, full_lib_name)); |
| 715 | | } |
| 699 | const is_exe_or_dyn_lib = self.base.options.output_mode == .Exe or |
| 700 | (self.base.options.output_mode == .Lib and self.base.options.link_mode == .Dynamic); |
| 701 | if (is_exe_or_dyn_lib) { |
| 702 | const system_libs = self.base.options.system_libs.keys(); |
| 703 | for (system_libs) |link_lib| { |
| 704 | try argv.append(try std.fmt.allocPrint(arena, "-l{s}", .{link_lib})); |
| 705 | } |
| 716 | 706 | |
| 717 | | if (self.base.options.link_libc) { |
| 718 | | try argv.append(try comp.get_libc_crt_file(arena, "libc.a")); |
| 707 | const wasi_emulated_libs = self.base.options.wasi_emulated_libs; |
| 708 | for (wasi_emulated_libs) |lib_name| { |
| 709 | const full_lib_name = try std.fmt.allocPrint(arena, "lib{s}.a", .{lib_name}); |
| 710 | try argv.append(try comp.get_libc_crt_file(arena, full_lib_name)); |
| 711 | } |
| 712 | |
| 713 | if (self.base.options.link_libc) { |
| 714 | try argv.append(try comp.get_libc_crt_file(arena, "libc.a")); |
| 715 | } |
| 719 | 716 | } |
| 720 | 717 | } |
| 721 | 718 | |