aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-11-29 16:51:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-11-29 18:05:11 -0700
commit19eaf54bc9ea8229dd0ae9e8e99865aba6fe4398 (patch)
tree4c880f4cef886512213513b170024e51c145e866 /src
parentec10e63f4945e81cfc5369a2c886ef0b7ae11c1b (diff)
downloadzig-19eaf54bc9ea8229dd0ae9e8e99865aba6fe4398.tar.gz
zig-19eaf54bc9ea8229dd0ae9e8e99865aba6fe4398.zip
update libc linux headers to v5.16-rc3
* Add missing Linux headers. Closes #9837 * Update existing headers to latest Linux. * Consolidate headers that are the same for multiple Zig target CPU architectures. For example, Linux has only an x86 directory for both x86_64 and x86 CPU architectures. Now Zig only ships an x86 directory for Linux headers, and will emit the proper corresponding -isystem flags. * tools/update-linux-headers.zig is now available for upgrading to newer Linux headers, and the update process is now documented on the wiki.
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig3
-rw-r--r--src/glibc.zig3
-rw-r--r--src/target.zig16
3 files changed, 20 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 80d0142996..2d33fe83b6 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -3886,10 +3886,11 @@ fn detectLibCIncludeDirs(
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{s}",
.{ zig_lib_dir, generic_name },
);
+ const generic_arch_name = target_util.osArchName(target);
const arch_os_include_dir = try std.fmt.allocPrint(
arena,
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-any",
- .{ zig_lib_dir, @tagName(target.cpu.arch), os_name },
+ .{ zig_lib_dir, generic_arch_name, os_name },
);
const generic_os_include_dir = try std.fmt.allocPrint(
arena,
diff --git a/src/glibc.zig b/src/glibc.zig
index 049db4f870..fd143bac7e 100644
--- a/src/glibc.zig
+++ b/src/glibc.zig
@@ -555,9 +555,10 @@ 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_util.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.?, @tagName(arch),
+ comp.zig_lib_directory.path.?, arch_name,
}));
try args.append("-I");
diff --git a/src/target.zig b/src/target.zig
index 6f6d9f811d..9d22feff66 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -106,6 +106,22 @@ pub fn libCGenericName(target: std.Target) [:0]const u8 {
}
}
+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_32 => "arm64",
+ .mips, .mipsel, .mips64, .mips64el => "mips",
+ .powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc",
+ .riscv32, .riscv64 => "riscv",
+ .sparc, .sparcel, .sparcv9 => "sparc",
+ .i386, .x86_64 => "x86",
+ else => @tagName(target.cpu.arch),
+ },
+ else => @tagName(target.cpu.arch),
+ };
+}
+
pub fn canBuildLibC(target: std.Target) bool {
for (available_libcs) |libc| {
if (target.cpu.arch == libc.arch and target.os.tag == libc.os and target.abi == libc.abi) {