mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.Target: Move osArchName() and Cpu.Arch.archName() to std.zig.target.
These deal with how Zig stores OS headers in `lib/libc/include` and so don't really belong in std.Target.
This commit is contained in:
parent
ce8c61b0fc
commit
e62352611f
4 changed files with 19 additions and 23 deletions
|
|
@ -218,23 +218,6 @@ pub const Os = struct {
|
|||
.windows => .windows,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn archName(tag: Tag, arch: Cpu.Arch) [:0]const u8 {
|
||||
return switch (tag) {
|
||||
.linux => switch (arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => "arm",
|
||||
.aarch64, .aarch64_be => "aarch64",
|
||||
.loongarch32, .loongarch64 => "loongarch",
|
||||
.mips, .mipsel, .mips64, .mips64el => "mips",
|
||||
.powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc",
|
||||
.riscv32, .riscv64 => "riscv",
|
||||
.sparc, .sparc64 => "sparc",
|
||||
.x86, .x86_64 => "x86",
|
||||
else => @tagName(arch),
|
||||
},
|
||||
else => @tagName(arch),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/// Based on NTDDI version constants from
|
||||
|
|
@ -3357,10 +3340,6 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn osArchName(target: std.Target) [:0]const u8 {
|
||||
return target.os.tag.archName(target.cpu.arch);
|
||||
}
|
||||
|
||||
const Target = @This();
|
||||
const std = @import("std.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ pub fn detectFromBuilding(
|
|||
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{s}",
|
||||
.{ zig_lib_dir, generic_name },
|
||||
);
|
||||
const generic_arch_name = target.osArchName();
|
||||
const generic_arch_name = std.zig.target.osArchName(target);
|
||||
const arch_os_include_dir = try std.fmt.allocPrint(
|
||||
arena,
|
||||
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-any",
|
||||
|
|
|
|||
|
|
@ -129,6 +129,23 @@ pub fn glibcRuntimeTriple(
|
|||
};
|
||||
}
|
||||
|
||||
pub fn osArchName(target: std.Target) [:0]const u8 {
|
||||
return switch (target.os.tag) {
|
||||
.linux => switch (target.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => "arm",
|
||||
.aarch64, .aarch64_be => "aarch64",
|
||||
.loongarch32, .loongarch64 => "loongarch",
|
||||
.mips, .mipsel, .mips64, .mips64el => "mips",
|
||||
.powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc",
|
||||
.riscv32, .riscv64 => "riscv",
|
||||
.sparc, .sparc64 => "sparc",
|
||||
.x86, .x86_64 => "x86",
|
||||
else => @tagName(target.cpu.arch),
|
||||
},
|
||||
else => @tagName(target.cpu.arch),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn muslArchName(arch: std.Target.Cpu.Arch, abi: std.Target.Abi) [:0]const u8 {
|
||||
return switch (abi) {
|
||||
.muslabin32 => "mipsn32",
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([
|
|||
try args.append("-I");
|
||||
try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
|
||||
|
||||
const arch_name = target.osArchName();
|
||||
const arch_name = std.zig.target.osArchName(target);
|
||||
try args.append("-I");
|
||||
try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-linux-any", .{
|
||||
comp.zig_lib_directory.path.?, arch_name,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue