authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-23 19:19:06+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-23 20:05:00+02:00
logdbc54ce67cd0e313cbf8687152302c9b31529e34
tree30430179081f2a686b7dc2af3772d81801a43b14
parent3c46da14db296beec186c3df4fe3669f6c99b715
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: move linuxTriple/hurdTuple to std.zig.target, deprecate old ones

These functions don't actually hand out strings that are commonly understood, but rather strings that follow Zig's naming conventions. So namespace them accordingly.

3 files changed, 33 insertions(+), 4 deletions(-)

lib/std/Target.zig+4
...@@ -2146,18 +2146,22 @@ pub fn zigTriple(target: *const Target, allocator: Allocator) Allocator.Error![]...@@ -2146,18 +2146,22 @@ pub fn zigTriple(target: *const Target, allocator: Allocator) Allocator.Error![]
2146 return Query.fromTarget(target).zigTriple(allocator);2146 return Query.fromTarget(target).zigTriple(allocator);
2147}2147}
21482148
2149/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.hurdTupleSimple` instead.
2149pub fn hurdTupleSimple(allocator: Allocator, arch: Cpu.Arch, abi: Abi) ![]u8 {2150pub fn hurdTupleSimple(allocator: Allocator, arch: Cpu.Arch, abi: Abi) ![]u8 {
2150 return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) });2151 return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) });
2151}2152}
21522153
2154/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.hurdTuple` instead.
2153pub fn hurdTuple(target: *const Target, allocator: Allocator) ![]u8 {2155pub fn hurdTuple(target: *const Target, allocator: Allocator) ![]u8 {
2154 return hurdTupleSimple(allocator, target.cpu.arch, target.abi);2156 return hurdTupleSimple(allocator, target.cpu.arch, target.abi);
2155}2157}
21562158
2159/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.linuxTripleSimple` instead.
2157pub fn linuxTripleSimple(allocator: Allocator, arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 {2160pub fn linuxTripleSimple(allocator: Allocator, arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 {
2158 return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) });2161 return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) });
2159}2162}
21602163
2164/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.linuxTriple` instead.
2161pub fn linuxTriple(target: *const Target, allocator: Allocator) ![]u8 {2165pub fn linuxTriple(target: *const Target, allocator: Allocator) ![]u8 {
2162 return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi);2166 return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi);
2163}2167}
lib/std/zig/system/NativePaths.zig+1-1
...@@ -149,7 +149,7 @@ pub fn detect(...@@ -149,7 +149,7 @@ pub fn detect(
149 }149 }
150150
151 if (builtin.os.tag != .windows and builtin.os.tag != .wasi) {151 if (builtin.os.tag != .windows and builtin.os.tag != .wasi) {
152 const triple = try native_target.linuxTriple(arena);152 const triple = try std.zig.target.linuxTriple(arena, native_target);
153153
154 const qual = native_target.ptrBitWidth();154 const qual = native_target.ptrBitWidth();
155155
lib/std/zig/target.zig+28-3
...@@ -143,6 +143,31 @@ pub fn canBuildLibC(target: *const std.Target) bool {...@@ -143,6 +143,31 @@ pub fn canBuildLibC(target: *const std.Target) bool {
143 return false;143 return false;
144}144}
145145
146pub fn hurdTupleSimple(
147 allocator: Allocator,
148 arch: std.Target.Cpu.Arch,
149 abi: std.Target.Abi,
150) ![]u8 {
151 return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) });
152}
153
154pub fn hurdTuple(allocator: Allocator, target: *const std.Target) ![]u8 {
155 return hurdTupleSimple(allocator, target.cpu.arch, target.abi);
156}
157
158pub fn linuxTripleSimple(
159 allocator: Allocator,
160 arch: std.Target.Cpu.Arch,
161 os_tag: std.Target.Os.Tag,
162 abi: std.Target.Abi,
163) ![]u8 {
164 return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) });
165}
166
167pub fn linuxTriple(allocator: Allocator, target: *const std.Target) ![]u8 {
168 return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi);
169}
170
146/// Returns the subdirectory triple to be used to find the correct glibc for the given `arch`, `os`,171/// Returns the subdirectory triple to be used to find the correct glibc for the given `arch`, `os`,
147/// and `abi` in an installation directory created by glibc's `build-many-glibcs.py` script.172/// and `abi` in an installation directory created by glibc's `build-many-glibcs.py` script.
148///173///
...@@ -162,8 +187,8 @@ pub fn glibcRuntimeTriple(...@@ -162,8 +187,8 @@ pub fn glibcRuntimeTriple(
162 }187 }
163188
164 return switch (os) {189 return switch (os) {
165 .hurd => std.Target.hurdTupleSimple(allocator, arch, abi),190 .hurd => hurdTupleSimple(allocator, arch, abi),
166 .linux => std.Target.linuxTripleSimple(allocator, arch, os, abi),191 .linux => linuxTripleSimple(allocator, arch, os, abi),
167 else => unreachable,192 else => unreachable,
168 };193 };
169}194}
...@@ -179,7 +204,7 @@ pub fn muslRuntimeTriple(...@@ -179,7 +204,7 @@ pub fn muslRuntimeTriple(
179) Allocator.Error![]const u8 {204) Allocator.Error![]const u8 {
180 assert(abi.isMusl());205 assert(abi.isMusl());
181206
182 return std.Target.linuxTripleSimple(allocator, arch, .linux, abi);207 return linuxTripleSimple(allocator, arch, .linux, abi);
183}208}
184209
185pub fn osArchName(target: *const std.Target) [:0]const u8 {210pub fn osArchName(target: *const std.Target) [:0]const u8 {