| ... | @@ -6,8 +6,8 @@ | ... | @@ -6,8 +6,8 @@ |
| 6 | //! this tool. | 6 | //! this tool. |
| 7 | //! | 7 | //! |
| 8 | //! First, use the glibc, musl, FreeBSD, and NetBSD build systems to create installations of all the | 8 | //! First, use the glibc, musl, FreeBSD, and NetBSD build systems to create installations of all the |
| 9 | //! targets in the `glibc_targets`, `musl_targets`, `freebsd_targets`, and `netbsd_targets` | 9 | //! targets in the `glibc_targets`, `musl_targets`, `freebsd_targets`, `netbsd_targets`, and |
| 10 | //! variables. Next, run this tool to create a new directory which puts .h files into | 10 | //! `openbsd_targets` variables. Next, run this tool to create a new directory which puts .h files into |
| 11 | //! <arch> subdirectories, with `generic` being files that apply to all architectures. | 11 | //! <arch> subdirectories, with `generic` being files that apply to all architectures. |
| 12 | //! You'll then have to manually update Zig source repo with these new files. | 12 | //! You'll then have to manually update Zig source repo with these new files. |
| 13 | | 13 | |
| ... | @@ -104,6 +104,19 @@ const netbsd_targets = [_]LibCTarget{ | ... | @@ -104,6 +104,19 @@ const netbsd_targets = [_]LibCTarget{ |
| 104 | .{ .arch = .x86_64, .abi = .none }, | 104 | .{ .arch = .x86_64, .abi = .none }, |
| 105 | }; | 105 | }; |
| 106 | | 106 | |
| | 107 | const openbsd_targets = [_]LibCTarget{ |
| | 108 | .{ .arch = .arm, .abi = .eabi }, |
| | 109 | .{ .arch = .aarch64, .abi = .none }, |
| | 110 | .{ .arch = .mips64, .abi = .none }, |
| | 111 | .{ .arch = .mips64el, .abi = .none }, |
| | 112 | .{ .arch = .powerpc, .abi = .eabihf }, |
| | 113 | .{ .arch = .powerpc64, .abi = .none }, |
| | 114 | .{ .arch = .riscv64, .abi = .none }, |
| | 115 | .{ .arch = .sparc64, .abi = .none }, |
| | 116 | .{ .arch = .x86, .abi = .none }, |
| | 117 | .{ .arch = .x86_64, .abi = .none }, |
| | 118 | }; |
| | 119 | |
| 107 | const Contents = struct { | 120 | const Contents = struct { |
| 108 | bytes: []const u8, | 121 | bytes: []const u8, |
| 109 | hit_count: usize, | 122 | hit_count: usize, |
| ... | @@ -125,6 +138,7 @@ const LibCVendor = enum { | ... | @@ -125,6 +138,7 @@ const LibCVendor = enum { |
| 125 | glibc, | 138 | glibc, |
| 126 | freebsd, | 139 | freebsd, |
| 127 | netbsd, | 140 | netbsd, |
| | 141 | openbsd, |
| 128 | }; | 142 | }; |
| 129 | | 143 | |
| 130 | pub fn main(init: std.process.Init) !void { | 144 | pub fn main(init: std.process.Init) !void { |
| ... | @@ -176,6 +190,7 @@ pub fn main(init: std.process.Init) !void { | ... | @@ -176,6 +190,7 @@ pub fn main(init: std.process.Init) !void { |
| 176 | .musl => &musl_targets, | 190 | .musl => &musl_targets, |
| 177 | .freebsd => &freebsd_targets, | 191 | .freebsd => &freebsd_targets, |
| 178 | .netbsd => &netbsd_targets, | 192 | .netbsd => &netbsd_targets, |
| | 193 | .openbsd => &openbsd_targets, |
| 179 | }; | 194 | }; |
| 180 | | 195 | |
| 181 | var path_table = PathTable.init(arena); | 196 | var path_table = PathTable.init(arena); |
| ... | @@ -215,6 +230,22 @@ pub fn main(init: std.process.Init) !void { | ... | @@ -215,6 +230,22 @@ pub fn main(init: std.process.Init) !void { |
| 215 | .sparc64, | 230 | .sparc64, |
| 216 | => |a| @tagName(a), | 231 | => |a| @tagName(a), |
| 217 | | 232 | |
| | 233 | else => unreachable, |
| | 234 | }, |
| | 235 | .openbsd => switch (libc_target.arch) { |
| | 236 | .arm => "armv7", |
| | 237 | .aarch64 => "arm64", |
| | 238 | .mips64 => "octeon", |
| | 239 | .mips64el => "loongson", |
| | 240 | .powerpc => "macppc", |
| | 241 | .x86 => "i386", |
| | 242 | .x86_64 => "amd64", |
| | 243 | |
| | 244 | .powerpc64, |
| | 245 | .riscv64, |
| | 246 | .sparc64, |
| | 247 | => |a| @tagName(a), |
| | 248 | |
| 218 | else => unreachable, | 249 | else => unreachable, |
| 219 | }, | 250 | }, |
| 220 | }; | 251 | }; |
| ... | @@ -225,6 +256,7 @@ pub fn main(init: std.process.Init) !void { | ... | @@ -225,6 +256,7 @@ pub fn main(init: std.process.Init) !void { |
| 225 | .musl, .glibc => "linux", | 256 | .musl, .glibc => "linux", |
| 226 | .freebsd => "freebsd", | 257 | .freebsd => "freebsd", |
| 227 | .netbsd => "netbsd", | 258 | .netbsd => "netbsd", |
| | 259 | .openbsd => "openbsd", |
| 228 | }, | 260 | }, |
| 229 | @tagName(libc_target.abi), | 261 | @tagName(libc_target.abi), |
| 230 | }); | 262 | }); |
| ... | @@ -234,6 +266,7 @@ pub fn main(init: std.process.Init) !void { | ... | @@ -234,6 +266,7 @@ pub fn main(init: std.process.Init) !void { |
| 234 | .glibc, | 266 | .glibc, |
| 235 | .freebsd, | 267 | .freebsd, |
| 236 | .netbsd, | 268 | .netbsd, |
| | 269 | .openbsd, |
| 237 | => &[_][]const u8{ search_path, libc_dir, "usr", "include" }, | 270 | => &[_][]const u8{ search_path, libc_dir, "usr", "include" }, |
| 238 | .musl => &[_][]const u8{ search_path, libc_dir, "usr", "local", "musl", "include" }, | 271 | .musl => &[_][]const u8{ search_path, libc_dir, "usr", "local", "musl", "include" }, |
| 239 | }; | 272 | }; |
| ... | @@ -370,6 +403,6 @@ fn usageAndExit(arg0: []const u8) noreturn { | ... | @@ -370,6 +403,6 @@ fn usageAndExit(arg0: []const u8) noreturn { |
| 370 | std.debug.print("--search-path can be used any number of times.\n", .{}); | 403 | std.debug.print("--search-path can be used any number of times.\n", .{}); |
| 371 | std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{}); | 404 | std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{}); |
| 372 | std.debug.print("--out is a dir that will be created, and populated with the results\n", .{}); | 405 | std.debug.print("--out is a dir that will be created, and populated with the results\n", .{}); |
| 373 | std.debug.print("--abi is either glibc, musl, freebsd, or netbsd\n", .{}); | 406 | std.debug.print("--abi is either glibc, musl, freebsd, netbsd, or openbsd\n", .{}); |
| 374 | std.process.exit(1); | 407 | std.process.exit(1); |
| 375 | } | 408 | } |