| ... | ... | @@ -356,6 +356,16 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { |
| 356 | 356 | if (bad) return error.UnableToWriteArchive; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | fn addCommonArgs(argv: *std.array_list.Managed([]const u8), coff: bool) !void { |
| 360 | if (builtin.os.tag == .netbsd) { |
| 361 | // NetBSD 10.1's `malloc` appears to have some nasty bugs that occur |
| 362 | // when doing parallel linking in LLD, manifesting as input and/or |
| 363 | // output section memory randomly being unmapped. So just don't do |
| 364 | // parallel linking for now. |
| 365 | try argv.append(if (coff) "-threads:1" else "--threads=1"); |
| 366 | } |
| 367 | } |
| 368 | |
| 359 | 369 | fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 360 | 370 | const comp = lld.base.comp; |
| 361 | 371 | const gpa = comp.gpa; |
| ... | ... | @@ -418,6 +428,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 418 | 428 | // it calls exit() and does not reset all global data between invocations. |
| 419 | 429 | const linker_command = "lld-link"; |
| 420 | 430 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); |
| 431 | try addCommonArgs(&argv, true); |
| 421 | 432 | |
| 422 | 433 | if (target.isMinGW()) { |
| 423 | 434 | try argv.append("-lldmingw"); |
| ... | ... | @@ -836,6 +847,8 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 836 | 847 | // it calls exit() and does not reset all global data between invocations. |
| 837 | 848 | const linker_command = "ld.lld"; |
| 838 | 849 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); |
| 850 | try addCommonArgs(&argv, false); |
| 851 | |
| 839 | 852 | if (is_obj) { |
| 840 | 853 | try argv.append("-r"); |
| 841 | 854 | } |
| ... | ... | @@ -1401,6 +1414,8 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1401 | 1414 | // it calls exit() and does not reset all global data between invocations. |
| 1402 | 1415 | const linker_command = "wasm-ld"; |
| 1403 | 1416 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); |
| 1417 | try addCommonArgs(&argv, false); |
| 1418 | |
| 1404 | 1419 | try argv.append("--error-limit=0"); |
| 1405 | 1420 | |
| 1406 | 1421 | if (comp.config.lto != .none) { |
| ... | ... | @@ -1724,6 +1739,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi |
| 1724 | 1739 | if (stderr.len > 0) log.warn("unexpected LLD stderr:\n{s}", .{stderr}); |
| 1725 | 1740 | } |
| 1726 | 1741 | |
| 1742 | const builtin = @import("builtin"); |
| 1727 | 1743 | const std = @import("std"); |
| 1728 | 1744 | const Io = std.Io; |
| 1729 | 1745 | const Allocator = std.mem.Allocator; |