authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 19:18:27-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 19:18:27-05:00
loge683eee415bc4362f9c0e095ceecebe577c47d06
treef306e0d10ab872c5839f1dd3211687cd5aa18bf3
parent4bc893c346aa45972ae884188388269b66efc3b9
signature Commit is signed but in an unrecognized format.

fix CrossTarget.isNative, setGnuLibCVersion, zigTriple


1 files changed, 13 insertions(+), 8 deletions(-)

lib/std/zig/cross_target.zig+13-8
......@@ -483,7 +483,7 @@ pub const CrossTarget = struct {
483483 (self.cpu_model == .native or self.cpu_model == .determined_by_cpu_arch) and
484484 self.cpu_features_sub.isEmpty() and self.cpu_features_add.isEmpty() and
485485 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;
487487 }
488488
489489 pub fn zigTriple(self: CrossTarget, allocator: *mem.Allocator) error{OutOfMemory}![:0]u8 {
......@@ -514,13 +514,10 @@ pub const CrossTarget = struct {
514514 }
515515 }
516516
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| {
518520 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);
524521 }
525522
526523 return result.toOwnedSlice();
......@@ -643,7 +640,7 @@ pub const CrossTarget = struct {
643640 return Target.isGnuLibC_os_tag_abi(self.getOsTag(), self.getAbi());
644641 }
645642
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 {
647644 assert(self.isGnuLibC());
648645 self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch };
649646 }
......@@ -747,6 +744,14 @@ pub const CrossTarget = struct {
747744};
748745
749746test "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 }
750755 {
751756 const cross_target = try CrossTarget.parse(.{
752757 .arch_os_abi = "aarch64-linux",