diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-12-02 20:17:51 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-12-02 20:17:51 -0700 |
| commit | 5b6cbd2e7cd00b19bdcfdeefc9b5d378ce8867a6 (patch) | |
| tree | 68d9d3301645d31382da1ade3e7d4a8e65886dda /src/link | |
| parent | cb63ecd6e9a9c539caf0a04278618f55b9d46bba (diff) | |
| download | zig-5b6cbd2e7cd00b19bdcfdeefc9b5d378ce8867a6.tar.gz zig-5b6cbd2e7cd00b19bdcfdeefc9b5d378ce8867a6.zip | |
stage2: don't pass -l arguments when building .a or .o files
See #7094
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Elf.zig | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 66542027e1..1e95f3fa71 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1551,16 +1551,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { } // Shared libraries. - const system_libs = self.base.options.system_libs.items(); - try argv.ensureCapacity(argv.items.len + system_libs.len); - for (system_libs) |entry| { - const link_lib = entry.key; - // By this time, we depend on these libs being dynamically linked libraries and not static libraries - // (the check for that needs to be earlier), but they could be full paths to .so files, in which - // case we want to avoid prepending "-l". - const ext = Compilation.classifyFileExt(link_lib); - const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib}); - argv.appendAssumeCapacity(arg); + if (is_exe_or_dyn_lib) { + const system_libs = self.base.options.system_libs.items(); + try argv.ensureCapacity(argv.items.len + system_libs.len); + for (system_libs) |entry| { + const link_lib = entry.key; + // By this time, we depend on these libs being dynamically linked libraries and not static libraries + // (the check for that needs to be earlier), but they could be full paths to .so files, in which + // case we want to avoid prepending "-l". + const ext = Compilation.classifyFileExt(link_lib); + const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib}); + argv.appendAssumeCapacity(arg); + } } if (!is_obj) { |
