| ... | @@ -6040,7 +6040,7 @@ test "classifyFileExt" { | ... | @@ -6040,7 +6040,7 @@ test "classifyFileExt" { |
| 6040 | } | 6040 | } |
| 6041 | | 6041 | |
| 6042 | pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const u8) !Path { | 6042 | pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const u8) !Path { |
| 6043 | return (try crtFilePath(comp, basename)) orelse { | 6043 | return (try crtFilePath(&comp.crt_files, basename)) orelse { |
| 6044 | const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable; | 6044 | const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable; |
| 6045 | const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCrtDir; | 6045 | const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCrtDir; |
| 6046 | const full_path = try std.fs.path.join(arena, &[_][]const u8{ crt_dir_path, basename }); | 6046 | const full_path = try std.fs.path.join(arena, &[_][]const u8{ crt_dir_path, basename }); |
| ... | @@ -6053,8 +6053,8 @@ pub fn crtFileAsString(comp: *Compilation, arena: Allocator, basename: []const u | ... | @@ -6053,8 +6053,8 @@ pub fn crtFileAsString(comp: *Compilation, arena: Allocator, basename: []const u |
| 6053 | return path.toString(arena); | 6053 | return path.toString(arena); |
| 6054 | } | 6054 | } |
| 6055 | | 6055 | |
| 6056 | pub fn crtFilePath(comp: *Compilation, basename: []const u8) Allocator.Error!?Path { | 6056 | fn crtFilePath(crt_files: *std.StringHashMapUnmanaged(CrtFile), basename: []const u8) Allocator.Error!?Path { |
| 6057 | const crt_file = comp.crt_files.get(basename) orelse return null; | 6057 | const crt_file = crt_files.get(basename) orelse return null; |
| 6058 | return crt_file.full_object_path; | 6058 | return crt_file.full_object_path; |
| 6059 | } | 6059 | } |
| 6060 | | 6060 | |
| ... | @@ -6462,21 +6462,31 @@ pub fn getCrtPaths( | ... | @@ -6462,21 +6462,31 @@ pub fn getCrtPaths( |
| 6462 | arena: Allocator, | 6462 | arena: Allocator, |
| 6463 | ) error{ OutOfMemory, LibCInstallationMissingCrtDir }!LibCInstallation.CrtPaths { | 6463 | ) error{ OutOfMemory, LibCInstallationMissingCrtDir }!LibCInstallation.CrtPaths { |
| 6464 | const target = comp.root_mod.resolved_target.result; | 6464 | const target = comp.root_mod.resolved_target.result; |
| | 6465 | return getCrtPathsInner(arena, target, comp.config, comp.libc_installation, &comp.crt_files); |
| | 6466 | } |
| | 6467 | |
| | 6468 | fn getCrtPathsInner( |
| | 6469 | arena: Allocator, |
| | 6470 | target: std.Target, |
| | 6471 | config: Config, |
| | 6472 | libc_installation: ?*const LibCInstallation, |
| | 6473 | crt_files: *std.StringHashMapUnmanaged(CrtFile), |
| | 6474 | ) error{ OutOfMemory, LibCInstallationMissingCrtDir }!LibCInstallation.CrtPaths { |
| 6465 | const basenames = LibCInstallation.CrtBasenames.get(.{ | 6475 | const basenames = LibCInstallation.CrtBasenames.get(.{ |
| 6466 | .target = target, | 6476 | .target = target, |
| 6467 | .link_libc = comp.config.link_libc, | 6477 | .link_libc = config.link_libc, |
| 6468 | .output_mode = comp.config.output_mode, | 6478 | .output_mode = config.output_mode, |
| 6469 | .link_mode = comp.config.link_mode, | 6479 | .link_mode = config.link_mode, |
| 6470 | .pie = comp.config.pie, | 6480 | .pie = config.pie, |
| 6471 | }); | 6481 | }); |
| 6472 | if (comp.libc_installation) |lci| return lci.resolveCrtPaths(arena, basenames, target); | 6482 | if (libc_installation) |lci| return lci.resolveCrtPaths(arena, basenames, target); |
| 6473 | | 6483 | |
| 6474 | return .{ | 6484 | return .{ |
| 6475 | .crt0 = if (basenames.crt0) |basename| try comp.crtFilePath(basename) else null, | 6485 | .crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null, |
| 6476 | .crti = if (basenames.crti) |basename| try comp.crtFilePath(basename) else null, | 6486 | .crti = if (basenames.crti) |basename| try crtFilePath(crt_files, basename) else null, |
| 6477 | .crtbegin = if (basenames.crtbegin) |basename| try comp.crtFilePath(basename) else null, | 6487 | .crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null, |
| 6478 | .crtend = if (basenames.crtend) |basename| try comp.crtFilePath(basename) else null, | 6488 | .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null, |
| 6479 | .crtn = if (basenames.crtn) |basename| try comp.crtFilePath(basename) else null, | 6489 | .crtn = if (basenames.crtn) |basename| try crtFilePath(crt_files, basename) else null, |
| 6480 | }; | 6490 | }; |
| 6481 | } | 6491 | } |
| 6482 | | 6492 | |