mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-08 06:44:27 +00:00
fix CrossTarget.isNative, setGnuLibCVersion, zigTriple
This commit is contained in:
parent
4bc893c346
commit
e683eee415
1 changed files with 13 additions and 8 deletions
|
|
@ -483,7 +483,7 @@ pub const CrossTarget = struct {
|
|||
(self.cpu_model == .native or self.cpu_model == .determined_by_cpu_arch) and
|
||||
self.cpu_features_sub.isEmpty() and self.cpu_features_add.isEmpty() and
|
||||
self.os_tag == null and self.os_version_min == null and self.os_version_max == null and
|
||||
self.abi == null and self.dynamic_linker.get() == null;
|
||||
self.abi == null and self.dynamic_linker.get() == null and self.glibc_version == null;
|
||||
}
|
||||
|
||||
pub fn zigTriple(self: CrossTarget, allocator: *mem.Allocator) error{OutOfMemory}![:0]u8 {
|
||||
|
|
@ -514,13 +514,10 @@ pub const CrossTarget = struct {
|
|||
}
|
||||
}
|
||||
|
||||
if (self.abi) |abi| {
|
||||
try result.print("-{}", .{@tagName(abi)});
|
||||
if (self.glibc_version) |v| {
|
||||
try result.print(".{}", .{v});
|
||||
}
|
||||
} else {
|
||||
assert(self.glibc_version == null);
|
||||
try result.print("-{}.{}", .{ @tagName(self.getAbi()), v });
|
||||
} else if (self.abi) |abi| {
|
||||
try result.print("-{}", .{@tagName(abi)});
|
||||
}
|
||||
|
||||
return result.toOwnedSlice();
|
||||
|
|
@ -643,7 +640,7 @@ pub const CrossTarget = struct {
|
|||
return Target.isGnuLibC_os_tag_abi(self.getOsTag(), self.getAbi());
|
||||
}
|
||||
|
||||
pub fn setGnuLibCVersion(self: CrossTarget, major: u32, minor: u32, patch: u32) void {
|
||||
pub fn setGnuLibCVersion(self: *CrossTarget, major: u32, minor: u32, patch: u32) void {
|
||||
assert(self.isGnuLibC());
|
||||
self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch };
|
||||
}
|
||||
|
|
@ -747,6 +744,14 @@ pub const CrossTarget = struct {
|
|||
};
|
||||
|
||||
test "CrossTarget.parse" {
|
||||
if (Target.current.isGnuLibC()) {
|
||||
var cross_target = try CrossTarget.parse(.{});
|
||||
cross_target.setGnuLibCVersion(2, 1, 1);
|
||||
|
||||
const text = try cross_target.zigTriple(std.testing.allocator);
|
||||
defer std.testing.allocator.free(text);
|
||||
std.testing.expectEqualSlices(u8, "native-native-gnu.2.1.1", text);
|
||||
}
|
||||
{
|
||||
const cross_target = try CrossTarget.parse(.{
|
||||
.arch_os_abi = "aarch64-linux",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue