| ... | @@ -1221,13 +1221,26 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { | ... | @@ -1221,13 +1221,26 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 1221 | try argv.append(comp.compiler_rt_static_lib.?.full_object_path); | 1221 | try argv.append(comp.compiler_rt_static_lib.?.full_object_path); |
| 1222 | } | 1222 | } |
| 1223 | | 1223 | |
| | 1224 | try argv.ensureUnusedCapacity(self.base.options.system_libs.count()); |
| 1224 | for (self.base.options.system_libs.keys()) |key| { | 1225 | for (self.base.options.system_libs.keys()) |key| { |
| 1225 | const lib_basename = try allocPrint(arena, "{s}.lib", .{key}); | 1226 | const lib_basename = try allocPrint(arena, "{s}.lib", .{key}); |
| 1226 | if (comp.crt_files.get(lib_basename)) |crt_file| { | 1227 | if (comp.crt_files.get(lib_basename)) |crt_file| { |
| 1227 | try argv.append(crt_file.full_object_path); | 1228 | argv.appendAssumeCapacity(crt_file.full_object_path); |
| 1228 | } else { | 1229 | continue; |
| 1229 | try argv.append(lib_basename); | 1230 | } |
| | 1231 | if (try self.findLib(arena, lib_basename)) |full_path| { |
| | 1232 | argv.appendAssumeCapacity(full_path); |
| | 1233 | continue; |
| | 1234 | } |
| | 1235 | if (target.abi.isGnu()) { |
| | 1236 | const fallback_name = try allocPrint(arena, "lib{s}.dll.a", .{key}); |
| | 1237 | if (try self.findLib(arena, fallback_name)) |full_path| { |
| | 1238 | argv.appendAssumeCapacity(full_path); |
| | 1239 | continue; |
| | 1240 | } |
| 1230 | } | 1241 | } |
| | 1242 | log.err("DLL import library for -l{s} not found", .{key}); |
| | 1243 | return error.DllImportLibraryNotFound; |
| 1231 | } | 1244 | } |
| 1232 | | 1245 | |
| 1233 | if (self.base.options.verbose_link) { | 1246 | if (self.base.options.verbose_link) { |
| ... | @@ -1309,6 +1322,18 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { | ... | @@ -1309,6 +1322,18 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 1309 | } | 1322 | } |
| 1310 | } | 1323 | } |
| 1311 | | 1324 | |
| | 1325 | fn findLib(self: *Coff, arena: *Allocator, name: []const u8) !?[]const u8 { |
| | 1326 | for (self.base.options.lib_dirs) |lib_dir| { |
| | 1327 | const full_path = try fs.path.join(arena, &.{ lib_dir, name }); |
| | 1328 | fs.cwd().access(full_path, .{}) catch |err| switch (err) { |
| | 1329 | error.FileNotFound => continue, |
| | 1330 | else => |e| return e, |
| | 1331 | }; |
| | 1332 | return full_path; |
| | 1333 | } |
| | 1334 | return null; |
| | 1335 | } |
| | 1336 | |
| 1312 | pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 { | 1337 | pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 { |
| 1313 | assert(self.llvm_object == null); | 1338 | assert(self.llvm_object == null); |
| 1314 | return self.text_section_virtual_address + decl.link.coff.text_offset; | 1339 | return self.text_section_virtual_address + decl.link.coff.text_offset; |