aboutsummaryrefslogtreecommitdiff
path: root/src/glibc.zig
diff options
context:
space:
mode:
authorKoakuma <koachan@protonmail.com>2022-05-13 22:59:06 +0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-13 16:43:59 -0400
commitfb0692334ed64a995690c21525fc3e729e63f424 (patch)
tree1a7a8f2617bf890c66ba965a6cc49352b9c48629 /src/glibc.zig
parentaceb7e18bd1eb25affe8118e01e066c9e6bb0c04 (diff)
downloadzig-fb0692334ed64a995690c21525fc3e729e63f424.tar.gz
zig-fb0692334ed64a995690c21525fc3e729e63f424.zip
target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with other projects. Also, added new function to convert glibc arch name to Zig arch name, since it refers to the architecture as sparcv9. This is based on the suggestion by @kubkon in PR 11847. (https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
Diffstat (limited to 'src/glibc.zig')
-rw-r--r--src/glibc.zig55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/glibc.zig b/src/glibc.zig
index dee4e50e37..4deac5275f 100644
--- a/src/glibc.zig
+++ b/src/glibc.zig
@@ -43,6 +43,29 @@ pub const libs = [_]Lib{
.{ .name = "util", .sover = 1 },
};
+// glibc's naming of Zig architectures
+const Arch = enum(c_int) {
+ arm,
+ armeb,
+ aarch64,
+ aarch64_be,
+ mips,
+ mipsel,
+ mips64,
+ mips64el,
+ powerpc,
+ powerpc64,
+ powerpc64le,
+ riscv32,
+ riscv64,
+ sparc,
+ sparcv9,
+ sparcel,
+ s390x,
+ i386,
+ x86_64,
+};
+
pub const LoadMetaDataError = error{
/// The files that ship with the Zig compiler were unable to be read, or otherwise had malformed data.
ZigInstallationCorrupt,
@@ -134,7 +157,7 @@ pub fn loadMetaData(gpa: Allocator, zig_lib_dir: fs.Dir) LoadMetaDataError!*ABI
log.err("abilists: expected ABI name", .{});
return error.ZigInstallationCorrupt;
};
- const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
+ const arch_tag = std.meta.stringToEnum(Arch, arch_name) orelse {
log.err("abilists: unrecognized arch: '{s}'", .{arch_name});
return error.ZigInstallationCorrupt;
};
@@ -148,7 +171,7 @@ pub fn loadMetaData(gpa: Allocator, zig_lib_dir: fs.Dir) LoadMetaDataError!*ABI
};
targets[i] = .{
- .arch = arch_tag,
+ .arch = glibcToZigArch(arch_tag),
.os = .linux,
.abi = abi_tag,
};
@@ -381,7 +404,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
const arch = comp.getTarget().cpu.arch;
const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le;
const is_aarch64 = arch == .aarch64 or arch == .aarch64_be;
- const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparcv9;
+ const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparc64;
const is_64 = arch.ptrBitWidth() == 64;
const s = path.sep_str;
@@ -519,7 +542,7 @@ fn add_include_dirs_arch(
const is_x86 = arch == .i386 or arch == .x86_64;
const is_aarch64 = arch == .aarch64 or arch == .aarch64_be;
const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le;
- const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparcv9;
+ const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparc64;
const is_64 = arch.ptrBitWidth() == 64;
const s = path.sep_str;
@@ -1115,6 +1138,30 @@ fn buildSharedLib(
try sub_compilation.updateSubCompilation();
}
+fn glibcToZigArch(arch_tag: Arch) std.Target.Cpu.Arch {
+ return switch (arch_tag) {
+ .arm => .arm,
+ .armeb => .armeb,
+ .aarch64 => .aarch64,
+ .aarch64_be => .aarch64_be,
+ .mips => .mips,
+ .mipsel => .mipsel,
+ .mips64 => .mips64,
+ .mips64el => .mips64el,
+ .powerpc => .powerpc,
+ .powerpc64 => .powerpc64,
+ .powerpc64le => .powerpc64le,
+ .riscv32 => .riscv32,
+ .riscv64 => .riscv64,
+ .sparc => .sparc,
+ .sparcv9 => .sparc64, // In glibc, sparc64 is called sparcv9.
+ .sparcel => .sparcel,
+ .s390x => .s390x,
+ .i386 => .i386,
+ .x86_64 => .x86_64,
+ };
+}
+
// Return true if glibc has crti/crtn sources for that architecture.
pub fn needsCrtiCrtn(target: std.Target) bool {
return switch (target.cpu.arch) {