| ... | ... | @@ -1392,11 +1392,33 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1392 | 1392 | if (self.base.options.libc_installation) |lc| { |
| 1393 | 1393 | const flags = target_util.libcFullLinkFlags(target); |
| 1394 | 1394 | try system_libs.ensureUnusedCapacity(flags.len); |
| 1395 | |
| 1396 | var test_path = std.ArrayList(u8).init(arena); |
| 1397 | var checked_paths = std.ArrayList([]const u8).init(arena); |
| 1398 | |
| 1395 | 1399 | for (flags) |flag| { |
| 1396 | | const lib_path = try std.fmt.allocPrint(arena, "{s}{c}lib{s}.so", .{ |
| 1397 | | lc.crt_dir.?, fs.path.sep, flag["-l".len..], |
| 1398 | | }); |
| 1399 | | system_libs.appendAssumeCapacity(.{ .path = lib_path }); |
| 1400 | checked_paths.clearRetainingCapacity(); |
| 1401 | const lib_name = flag["-l".len..]; |
| 1402 | |
| 1403 | success: { |
| 1404 | if (!self.isStatic()) { |
| 1405 | if (try self.accessLibPath(&test_path, &checked_paths, lc.crt_dir.?, lib_name, .Dynamic)) |
| 1406 | break :success; |
| 1407 | } |
| 1408 | if (try self.accessLibPath(&test_path, &checked_paths, lc.crt_dir.?, lib_name, .Static)) |
| 1409 | break :success; |
| 1410 | |
| 1411 | try self.reportMissingLibraryError( |
| 1412 | checked_paths.items, |
| 1413 | "missing system library: '{s}' was not found", |
| 1414 | .{lib_name}, |
| 1415 | ); |
| 1416 | |
| 1417 | continue; |
| 1418 | } |
| 1419 | |
| 1420 | const resolved_path = try arena.dupe(u8, test_path.items); |
| 1421 | system_libs.appendAssumeCapacity(.{ .path = resolved_path }); |
| 1400 | 1422 | } |
| 1401 | 1423 | } else if (target.isGnuLibC()) { |
| 1402 | 1424 | try system_libs.ensureUnusedCapacity(glibc.libs.len + 1); |
| ... | ... | @@ -1422,10 +1444,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1422 | 1444 | |
| 1423 | 1445 | for (system_libs.items) |lib| { |
| 1424 | 1446 | var parse_ctx: ParseErrorCtx = .{ .detected_cpu_arch = undefined }; |
| 1425 | | const in_file = std.fs.cwd().openFile(lib.path, .{}) catch |err| { |
| 1426 | | try self.handleAndReportParseError(lib.path, err, &parse_ctx); |
| 1427 | | continue; |
| 1428 | | }; |
| 1447 | const in_file = try std.fs.cwd().openFile(lib.path, .{}); |
| 1429 | 1448 | defer in_file.close(); |
| 1430 | 1449 | self.parseLibrary(in_file, lib, false, &parse_ctx) catch |err| |
| 1431 | 1450 | try self.handleAndReportParseError(lib.path, err, &parse_ctx); |
| ... | ... | @@ -1832,15 +1851,6 @@ fn parseLdScript(self: *Elf, in_file: std.fs.File, lib: SystemLib, ctx: *ParseEr |
| 1832 | 1851 | if (try self.accessLibPath(&test_path, &checked_paths, lib_dir, lib_name, .Static)) |
| 1833 | 1852 | break :success; |
| 1834 | 1853 | } |
| 1835 | | |
| 1836 | | try self.reportMissingLibraryError( |
| 1837 | | checked_paths.items, |
| 1838 | | "missing library dependency: GNU ld script '{s}' requires '{s}', but file not found", |
| 1839 | | .{ |
| 1840 | | lib.path, |
| 1841 | | scr_obj.path, |
| 1842 | | }, |
| 1843 | | ); |
| 1844 | 1854 | } else { |
| 1845 | 1855 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; |
| 1846 | 1856 | if (fs.realpath(scr_obj.path, &buffer)) |path| { |
| ... | ... | @@ -1854,16 +1864,17 @@ fn parseLdScript(self: *Elf, in_file: std.fs.File, lib: SystemLib, ctx: *ParseEr |
| 1854 | 1864 | if (try self.accessLibPath(&test_path, &checked_paths, lib_dir, scr_obj.path, null)) |
| 1855 | 1865 | break :success; |
| 1856 | 1866 | } |
| 1857 | | |
| 1858 | | try self.reportMissingLibraryError( |
| 1859 | | checked_paths.items, |
| 1860 | | "missing library dependency: GNU ld script '{s}' requires '{s}', but file not found", |
| 1861 | | .{ |
| 1862 | | lib.path, |
| 1863 | | scr_obj.path, |
| 1864 | | }, |
| 1865 | | ); |
| 1866 | 1867 | } |
| 1868 | |
| 1869 | try self.reportMissingLibraryError( |
| 1870 | checked_paths.items, |
| 1871 | "missing library dependency: GNU ld script '{s}' requires '{s}', but file not found", |
| 1872 | .{ |
| 1873 | lib.path, |
| 1874 | scr_obj.path, |
| 1875 | }, |
| 1876 | ); |
| 1877 | continue; |
| 1867 | 1878 | } |
| 1868 | 1879 | |
| 1869 | 1880 | const full_path = test_path.items; |