authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-02 20:17:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-02 20:25:03-07:00
logff802cc996e916ef72efbb6ac6cfb17af206df90
tree28f6f4f9535faff8c45360e31e3d1d46a33ac5b1
parent0ac43154ebf0979672dde2211ee56663a6b0b338

stage2: don't pass -l arguments when building .a or .o files

See #7094

1 files changed, 12 insertions(+), 10 deletions(-)

src/link/Elf.zig+12-10
...@@ -1544,16 +1544,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {...@@ -1544,16 +1544,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
1544 }1544 }
15451545
1546 // Shared libraries.1546 // Shared libraries.
1547 const system_libs = self.base.options.system_libs.items();1547 if (is_exe_or_dyn_lib) {
1548 try argv.ensureCapacity(argv.items.len + system_libs.len);1548 const system_libs = self.base.options.system_libs.items();
1549 for (system_libs) |entry| {1549 try argv.ensureCapacity(argv.items.len + system_libs.len);
1550 const link_lib = entry.key;1550 for (system_libs) |entry| {
1551 // By this time, we depend on these libs being dynamically linked libraries and not static libraries1551 const link_lib = entry.key;
1552 // (the check for that needs to be earlier), but they could be full paths to .so files, in which1552 // By this time, we depend on these libs being dynamically linked libraries and not static libraries
1553 // case we want to avoid prepending "-l".1553 // (the check for that needs to be earlier), but they could be full paths to .so files, in which
1554 const ext = Compilation.classifyFileExt(link_lib);1554 // case we want to avoid prepending "-l".
1555 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});1555 const ext = Compilation.classifyFileExt(link_lib);
1556 argv.appendAssumeCapacity(arg);1556 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});
1557 argv.appendAssumeCapacity(arg);
1558 }
1557 }1559 }
15581560
1559 if (!is_obj) {1561 if (!is_obj) {