authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-03 15:32:33+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-04 07:19:11+01:00
log814a41b48f157fff1f48c4a14e92142d1e6e5748
tree4b23737f048c6f574a4e285bfd793a023f3c37d7
parent3054486d1dedd49553680da2c074d1ab413797fd

link.Coff: Pass -lldmingw to LLD earlier and regardless of -lc.

The -lldmingw option affects a lot of logic throughout LLD. We need to pass it for *-windows-gnu even when we're not actually linking MinGW since we're still using the MinGW ABI with all that that entails. (One particular problem we would run into is missing handling of stdcall-decorated symbols for 32-bit x86.) Also, various other LLD options are sensitive to this option, so it's best to pass it as early as possible. Closes #11817.

1 files changed, 4 insertions(+), 2 deletions(-)

src/link/Coff.zig+4-2
...@@ -1832,6 +1832,10 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:...@@ -1832,6 +1832,10 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
1832 const linker_command = "lld-link";1832 const linker_command = "lld-link";
1833 try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command });1833 try argv.appendSlice(&[_][]const u8{ comp.self_exe_path.?, linker_command });
18341834
1835 if (target.isMinGW()) {
1836 try argv.append("-lldmingw");
1837 }
1838
1835 try argv.append("-ERRORLIMIT:0");1839 try argv.append("-ERRORLIMIT:0");
1836 try argv.append("-NOLOGO");1840 try argv.append("-NOLOGO");
1837 if (comp.config.debug_format != .strip) {1841 if (comp.config.debug_format != .strip) {
...@@ -2053,8 +2057,6 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:...@@ -2053,8 +2057,6 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
2053 .win32 => {2057 .win32 => {
2054 if (link_in_crt) {2058 if (link_in_crt) {
2055 if (target.abi.isGnu()) {2059 if (target.abi.isGnu()) {
2056 try argv.append("-lldmingw");
2057
2058 if (target.cpu.arch == .x86) {2060 if (target.cpu.arch == .x86) {
2059 try argv.append("-ALTERNATENAME:__image_base__=___ImageBase");2061 try argv.append("-ALTERNATENAME:__image_base__=___ImageBase");
2060 } else {2062 } else {