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

See #7094
This commit is contained in:
Andrew Kelley 2020-12-02 20:17:51 -07:00
parent cb63ecd6e9
commit 5b6cbd2e7c

View File

@ -1551,16 +1551,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
} }
// Shared libraries. // Shared libraries.
const system_libs = self.base.options.system_libs.items(); if (is_exe_or_dyn_lib) {
try argv.ensureCapacity(argv.items.len + system_libs.len); const system_libs = self.base.options.system_libs.items();
for (system_libs) |entry| { try argv.ensureCapacity(argv.items.len + system_libs.len);
const link_lib = entry.key; for (system_libs) |entry| {
// By this time, we depend on these libs being dynamically linked libraries and not static libraries const link_lib = entry.key;
// (the check for that needs to be earlier), but they could be full paths to .so files, in which // By this time, we depend on these libs being dynamically linked libraries and not static libraries
// case we want to avoid prepending "-l". // (the check for that needs to be earlier), but they could be full paths to .so files, in which
const ext = Compilation.classifyFileExt(link_lib); // case we want to avoid prepending "-l".
const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib}); const ext = Compilation.classifyFileExt(link_lib);
argv.appendAssumeCapacity(arg); const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});
argv.appendAssumeCapacity(arg);
}
} }
if (!is_obj) { if (!is_obj) {