| ... | ... | @@ -483,7 +483,7 @@ pub const CrossTarget = struct { |
| 483 | 483 | (self.cpu_model == .native or self.cpu_model == .determined_by_cpu_arch) and |
| 484 | 484 | self.cpu_features_sub.isEmpty() and self.cpu_features_add.isEmpty() and |
| 485 | 485 | self.os_tag == null and self.os_version_min == null and self.os_version_max == null and |
| 486 | | self.abi == null and self.dynamic_linker.get() == null; |
| 486 | self.abi == null and self.dynamic_linker.get() == null and self.glibc_version == null; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | pub fn zigTriple(self: CrossTarget, allocator: *mem.Allocator) error{OutOfMemory}![:0]u8 { |
| ... | ... | @@ -514,13 +514,10 @@ pub const CrossTarget = struct { |
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | | if (self.abi) |abi| { |
| 517 | if (self.glibc_version) |v| { |
| 518 | try result.print("-{}.{}", .{ @tagName(self.getAbi()), v }); |
| 519 | } else if (self.abi) |abi| { |
| 518 | 520 | try result.print("-{}", .{@tagName(abi)}); |
| 519 | | if (self.glibc_version) |v| { |
| 520 | | try result.print(".{}", .{v}); |
| 521 | | } |
| 522 | | } else { |
| 523 | | assert(self.glibc_version == null); |
| 524 | 521 | } |
| 525 | 522 | |
| 526 | 523 | return result.toOwnedSlice(); |
| ... | ... | @@ -643,7 +640,7 @@ pub const CrossTarget = struct { |
| 643 | 640 | return Target.isGnuLibC_os_tag_abi(self.getOsTag(), self.getAbi()); |
| 644 | 641 | } |
| 645 | 642 | |
| 646 | | pub fn setGnuLibCVersion(self: CrossTarget, major: u32, minor: u32, patch: u32) void { |
| 643 | pub fn setGnuLibCVersion(self: *CrossTarget, major: u32, minor: u32, patch: u32) void { |
| 647 | 644 | assert(self.isGnuLibC()); |
| 648 | 645 | self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch }; |
| 649 | 646 | } |
| ... | ... | @@ -747,6 +744,14 @@ pub const CrossTarget = struct { |
| 747 | 744 | }; |
| 748 | 745 | |
| 749 | 746 | test "CrossTarget.parse" { |
| 747 | if (Target.current.isGnuLibC()) { |
| 748 | var cross_target = try CrossTarget.parse(.{}); |
| 749 | cross_target.setGnuLibCVersion(2, 1, 1); |
| 750 | |
| 751 | const text = try cross_target.zigTriple(std.testing.allocator); |
| 752 | defer std.testing.allocator.free(text); |
| 753 | std.testing.expectEqualSlices(u8, "native-native-gnu.2.1.1", text); |
| 754 | } |
| 750 | 755 | { |
| 751 | 756 | const cross_target = try CrossTarget.parse(.{ |
| 752 | 757 | .arch_os_abi = "aarch64-linux", |