| ... | @@ -29,7 +29,7 @@ pub fn appendToolPath(self: *const GCCDetector, tc: *Toolchain) !void { | ... | @@ -29,7 +29,7 @@ pub fn appendToolPath(self: *const GCCDetector, tc: *Toolchain) !void { |
| 29 | }, .program); | 29 | }, .program); |
| 30 | } | 30 | } |
| 31 | | 31 | |
| 32 | fn addDefaultGCCPrefixes(prefixes: *PathPrefixes, tc: *const Toolchain) !void { | 32 | fn addDefaultGCCPrefixes(prefixes: *std.ArrayListUnmanaged([]const u8), tc: *const Toolchain) !void { |
| 33 | const sysroot = tc.getSysroot(); | 33 | const sysroot = tc.getSysroot(); |
| 34 | const target = tc.getTarget(); | 34 | const target = tc.getTarget(); |
| 35 | if (sysroot.len == 0 and target.os.tag == .linux and tc.filesystem.exists("/opt/rh")) { | 35 | if (sysroot.len == 0 and target.os.tag == .linux and tc.filesystem.exists("/opt/rh")) { |
| ... | @@ -57,14 +57,12 @@ fn addDefaultGCCPrefixes(prefixes: *PathPrefixes, tc: *const Toolchain) !void { | ... | @@ -57,14 +57,12 @@ fn addDefaultGCCPrefixes(prefixes: *PathPrefixes, tc: *const Toolchain) !void { |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | | 59 | |
| 60 | const PathPrefixes = std.BoundedArray([]const u8, 16); | | |
| 61 | | | |
| 62 | fn collectLibDirsAndTriples( | 60 | fn collectLibDirsAndTriples( |
| 63 | tc: *Toolchain, | 61 | tc: *Toolchain, |
| 64 | lib_dirs: *PathPrefixes, | 62 | lib_dirs: *std.ArrayListUnmanaged([]const u8), |
| 65 | triple_aliases: *PathPrefixes, | 63 | triple_aliases: *std.ArrayListUnmanaged([]const u8), |
| 66 | biarch_libdirs: *PathPrefixes, | 64 | biarch_libdirs: *std.ArrayListUnmanaged([]const u8), |
| 67 | biarch_triple_aliases: *PathPrefixes, | 65 | biarch_triple_aliases: *std.ArrayListUnmanaged([]const u8), |
| 68 | ) !void { | 66 | ) !void { |
| 69 | const AArch64LibDirs: [2][]const u8 = .{ "/lib64", "/lib" }; | 67 | const AArch64LibDirs: [2][]const u8 = .{ "/lib64", "/lib" }; |
| 70 | const AArch64Triples: [4][]const u8 = .{ "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", "aarch64-suse-linux" }; | 68 | const AArch64Triples: [4][]const u8 = .{ "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", "aarch64-suse-linux" }; |
| ... | @@ -408,10 +406,18 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { | ... | @@ -408,10 +406,18 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { |
| 408 | else | 406 | else |
| 409 | target_util.get32BitArchVariant(target); | 407 | target_util.get32BitArchVariant(target); |
| 410 | | 408 | |
| 411 | var candidate_lib_dirs: PathPrefixes = .{}; | 409 | var candidate_lib_dirs_buffer: [16][]const u8 = undefined; |
| 412 | var candidate_triple_aliases: PathPrefixes = .{}; | 410 | var candidate_lib_dirs = std.ArrayListUnmanaged([]const u8).initBuffer(&candidate_lib_dirs_buffer); |
| 413 | var candidate_biarch_lib_dirs: PathPrefixes = .{}; | 411 | |
| 414 | var candidate_biarch_triple_aliases: PathPrefixes = .{}; | 412 | var candidate_triple_aliases_buffer: [16][]const u8 = undefined; |
| | 413 | var candidate_triple_aliases = std.ArrayListUnmanaged([]const u8).initBuffer(&candidate_triple_aliases_buffer); |
| | 414 | |
| | 415 | var candidate_biarch_lib_dirs_buffer: [16][]const u8 = undefined; |
| | 416 | var candidate_biarch_lib_dirs = std.ArrayListUnmanaged([]const u8).initBuffer(&candidate_biarch_lib_dirs_buffer); |
| | 417 | |
| | 418 | var candidate_biarch_triple_aliases_buffer: [16][]const u8 = undefined; |
| | 419 | var candidate_biarch_triple_aliases = std.ArrayListUnmanaged([]const u8).initBuffer(&candidate_biarch_triple_aliases_buffer); |
| | 420 | |
| 415 | try collectLibDirsAndTriples( | 421 | try collectLibDirsAndTriples( |
| 416 | tc, | 422 | tc, |
| 417 | &candidate_lib_dirs, | 423 | &candidate_lib_dirs, |
| ... | @@ -433,7 +439,8 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { | ... | @@ -433,7 +439,8 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { |
| 433 | } | 439 | } |
| 434 | } | 440 | } |
| 435 | | 441 | |
| 436 | var prefixes: PathPrefixes = .{}; | 442 | var prefixes_buf: [16][]const u8 = undefined; |
| | 443 | var prefixes = std.ArrayListUnmanaged([]const u8).initBuffer(&prefixes_buf); |
| 437 | const gcc_toolchain_dir = gccToolchainDir(tc); | 444 | const gcc_toolchain_dir = gccToolchainDir(tc); |
| 438 | if (gcc_toolchain_dir.len != 0) { | 445 | if (gcc_toolchain_dir.len != 0) { |
| 439 | const adjusted = if (gcc_toolchain_dir[gcc_toolchain_dir.len - 1] == '/') | 446 | const adjusted = if (gcc_toolchain_dir[gcc_toolchain_dir.len - 1] == '/') |
| ... | @@ -455,10 +462,10 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { | ... | @@ -455,10 +462,10 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { |
| 455 | } | 462 | } |
| 456 | | 463 | |
| 457 | const v0 = GCCVersion.parse("0.0.0"); | 464 | const v0 = GCCVersion.parse("0.0.0"); |
| 458 | for (prefixes.constSlice()) |prefix| { | 465 | for (prefixes.items) |prefix| { |
| 459 | if (!tc.filesystem.exists(prefix)) continue; | 466 | if (!tc.filesystem.exists(prefix)) continue; |
| 460 | | 467 | |
| 461 | for (candidate_lib_dirs.constSlice()) |suffix| { | 468 | for (candidate_lib_dirs.items) |suffix| { |
| 462 | defer fib.reset(); | 469 | defer fib.reset(); |
| 463 | const lib_dir = std.fs.path.join(fib.allocator(), &.{ prefix, suffix }) catch continue; | 470 | const lib_dir = std.fs.path.join(fib.allocator(), &.{ prefix, suffix }) catch continue; |
| 464 | if (!tc.filesystem.exists(lib_dir)) continue; | 471 | if (!tc.filesystem.exists(lib_dir)) continue; |
| ... | @@ -467,17 +474,17 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { | ... | @@ -467,17 +474,17 @@ pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { |
| 467 | const gcc_cross_dir_exists = tc.filesystem.joinedExists(&.{ lib_dir, "/gcc-cross" }); | 474 | const gcc_cross_dir_exists = tc.filesystem.joinedExists(&.{ lib_dir, "/gcc-cross" }); |
| 468 | | 475 | |
| 469 | try self.scanLibDirForGCCTriple(tc, target, lib_dir, triple_str, false, gcc_dir_exists, gcc_cross_dir_exists); | 476 | try self.scanLibDirForGCCTriple(tc, target, lib_dir, triple_str, false, gcc_dir_exists, gcc_cross_dir_exists); |
| 470 | for (candidate_triple_aliases.constSlice()) |candidate| { | 477 | for (candidate_triple_aliases.items) |candidate| { |
| 471 | try self.scanLibDirForGCCTriple(tc, target, lib_dir, candidate, false, gcc_dir_exists, gcc_cross_dir_exists); | 478 | try self.scanLibDirForGCCTriple(tc, target, lib_dir, candidate, false, gcc_dir_exists, gcc_cross_dir_exists); |
| 472 | } | 479 | } |
| 473 | } | 480 | } |
| 474 | for (candidate_biarch_lib_dirs.constSlice()) |suffix| { | 481 | for (candidate_biarch_lib_dirs.items) |suffix| { |
| 475 | const lib_dir = std.fs.path.join(fib.allocator(), &.{ prefix, suffix }) catch continue; | 482 | const lib_dir = std.fs.path.join(fib.allocator(), &.{ prefix, suffix }) catch continue; |
| 476 | if (!tc.filesystem.exists(lib_dir)) continue; | 483 | if (!tc.filesystem.exists(lib_dir)) continue; |
| 477 | | 484 | |
| 478 | const gcc_dir_exists = tc.filesystem.joinedExists(&.{ lib_dir, "/gcc" }); | 485 | const gcc_dir_exists = tc.filesystem.joinedExists(&.{ lib_dir, "/gcc" }); |
| 479 | const gcc_cross_dir_exists = tc.filesystem.joinedExists(&.{ lib_dir, "/gcc-cross" }); | 486 | const gcc_cross_dir_exists = tc.filesystem.joinedExists(&.{ lib_dir, "/gcc-cross" }); |
| 480 | for (candidate_biarch_triple_aliases.constSlice()) |candidate| { | 487 | for (candidate_biarch_triple_aliases.items) |candidate| { |
| 481 | try self.scanLibDirForGCCTriple(tc, target, lib_dir, candidate, true, gcc_dir_exists, gcc_cross_dir_exists); | 488 | try self.scanLibDirForGCCTriple(tc, target, lib_dir, candidate, true, gcc_dir_exists, gcc_cross_dir_exists); |
| 482 | } | 489 | } |
| 483 | } | 490 | } |