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:17:51-07:00
log5b6cbd2e7cd00b19bdcfdeefc9b5d378ce8867a6
tree68d9d3301645d31382da1ade3e7d4a8e65886dda
parentcb63ecd6e9a9c539caf0a04278618f55b9d46bba

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
...@@ -1551,16 +1551,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {...@@ -1551,16 +1551,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
1551 }1551 }
15521552
1553 // Shared libraries.1553 // Shared libraries.
1554 const system_libs = self.base.options.system_libs.items();1554 if (is_exe_or_dyn_lib) {
1555 try argv.ensureCapacity(argv.items.len + system_libs.len);1555 const system_libs = self.base.options.system_libs.items();
1556 for (system_libs) |entry| {1556 try argv.ensureCapacity(argv.items.len + system_libs.len);
1557 const link_lib = entry.key;1557 for (system_libs) |entry| {
1558 // By this time, we depend on these libs being dynamically linked libraries and not static libraries1558 const link_lib = entry.key;
1559 // (the check for that needs to be earlier), but they could be full paths to .so files, in which1559 // By this time, we depend on these libs being dynamically linked libraries and not static libraries
1560 // case we want to avoid prepending "-l".1560 // (the check for that needs to be earlier), but they could be full paths to .so files, in which
1561 const ext = Compilation.classifyFileExt(link_lib);1561 // case we want to avoid prepending "-l".
1562 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});1562 const ext = Compilation.classifyFileExt(link_lib);
1563 argv.appendAssumeCapacity(arg);1563 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});
1564 argv.appendAssumeCapacity(arg);
1565 }
1564 }1566 }
15651567
1566 if (!is_obj) {1568 if (!is_obj) {