| ... | @@ -356,6 +356,16 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { | ... | @@ -356,6 +356,16 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { |
| 356 | if (bad) return error.UnableToWriteArchive; | 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 | fn coffLink(lld: *Lld, arena: Allocator) !void { | 369 | fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 360 | const comp = lld.base.comp; | 370 | const comp = lld.base.comp; |
| 361 | const gpa = comp.gpa; | 371 | const gpa = comp.gpa; |
| ... | @@ -418,6 +428,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -418,6 +428,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 418 | // it calls exit() and does not reset all global data between invocations. | 428 | // it calls exit() and does not reset all global data between invocations. |
| 419 | const linker_command = "lld-link"; | 429 | const linker_command = "lld-link"; |
| 420 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); | 430 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); |
| | 431 | try addCommonArgs(&argv, true); |
| 421 | | 432 | |
| 422 | if (target.isMinGW()) { | 433 | if (target.isMinGW()) { |
| 423 | try argv.append("-lldmingw"); | 434 | try argv.append("-lldmingw"); |
| ... | @@ -836,6 +847,8 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -836,6 +847,8 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 836 | // it calls exit() and does not reset all global data between invocations. | 847 | // it calls exit() and does not reset all global data between invocations. |
| 837 | const linker_command = "ld.lld"; | 848 | const linker_command = "ld.lld"; |
| 838 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); | 849 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); |
| | 850 | try addCommonArgs(&argv, false); |
| | 851 | |
| 839 | if (is_obj) { | 852 | if (is_obj) { |
| 840 | try argv.append("-r"); | 853 | try argv.append("-r"); |
| 841 | } | 854 | } |
| ... | @@ -1401,6 +1414,8 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1401,6 +1414,8 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1401 | // it calls exit() and does not reset all global data between invocations. | 1414 | // it calls exit() and does not reset all global data between invocations. |
| 1402 | const linker_command = "wasm-ld"; | 1415 | const linker_command = "wasm-ld"; |
| 1403 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); | 1416 | try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command }); |
| | 1417 | try addCommonArgs(&argv, false); |
| | 1418 | |
| 1404 | try argv.append("--error-limit=0"); | 1419 | try argv.append("--error-limit=0"); |
| 1405 | | 1420 | |
| 1406 | if (comp.config.lto != .none) { | 1421 | if (comp.config.lto != .none) { |
| ... | @@ -1724,6 +1739,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi | ... | @@ -1724,6 +1739,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi |
| 1724 | if (stderr.len > 0) log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | 1739 | if (stderr.len > 0) log.warn("unexpected LLD stderr:\n{s}", .{stderr}); |
| 1725 | } | 1740 | } |
| 1726 | | 1741 | |
| | 1742 | const builtin = @import("builtin"); |
| 1727 | const std = @import("std"); | 1743 | const std = @import("std"); |
| 1728 | const Io = std.Io; | 1744 | const Io = std.Io; |
| 1729 | const Allocator = std.mem.Allocator; | 1745 | const Allocator = std.mem.Allocator; |