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![]
21462146 return Query.fromTarget(target).zigTriple(allocator);
21472147}
21482148
2149/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.hurdTupleSimple` instead.
21492150pub fn hurdTupleSimple(allocator: Allocator, arch: Cpu.Arch, abi: Abi) ![]u8 {
21502151 return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) });
21512152}
21522153
2154/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.hurdTuple` instead.
21532155pub fn hurdTuple(target: *const Target, allocator: Allocator) ![]u8 {
21542156 return hurdTupleSimple(allocator, target.cpu.arch, target.abi);
21552157}
21562158
2159/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.linuxTripleSimple` instead.
21572160pub fn linuxTripleSimple(allocator: Allocator, arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 {
21582161 return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) });
21592162}
21602163
2164/// Deprecated; to be removed in 0.18.0. Use `std.zig.target.linuxTriple` instead.
21612165pub fn linuxTriple(target: *const Target, allocator: Allocator) ![]u8 {
21622166 return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi);
21632167}
lib/std/zig/system/NativePaths.zig+1-1
......@@ -149,7 +149,7 @@ pub fn detect(
149149 }
150150
151151 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
154154 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 {
143143 return false;
144144}
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
146171/// Returns the subdirectory triple to be used to find the correct glibc for the given `arch`, `os`,
147172/// and `abi` in an installation directory created by glibc's `build-many-glibcs.py` script.
148173///
......@@ -162,8 +187,8 @@ pub fn glibcRuntimeTriple(
162187 }
163188
164189 return switch (os) {
165 .hurd => std.Target.hurdTupleSimple(allocator, arch, abi),
166 .linux => std.Target.linuxTripleSimple(allocator, arch, os, abi),
190 .hurd => hurdTupleSimple(allocator, arch, abi),
191 .linux => linuxTripleSimple(allocator, arch, os, abi),
167192 else => unreachable,
168193 };
169194}
......@@ -179,7 +204,7 @@ pub fn muslRuntimeTriple(
179204) Allocator.Error![]const u8 {
180205 assert(abi.isMusl());
181206
182 return std.Target.linuxTripleSimple(allocator, arch, .linux, abi);
207 return linuxTripleSimple(allocator, arch, .linux, abi);
183208}
184209
185210pub fn osArchName(target: *const std.Target) [:0]const u8 {