| author | |
| committer | |
| log | ff79b87fa062d602722a6ec17f74550cda42a624 |
| tree | a08a33c1f2160724fc5436ad6f527fa1c4264aad |
| parent | 37f36da391570739e639f857bef3de1170eaac50 |
Many tools were broken after the recent hash-table refactorings, fix
them and ensure they won't silently break again.5 files changed, 46 insertions(+), 30 deletions(-)
test/standalone.zig+8| ... | @@ -32,4 +32,12 @@ pub fn addCases(cases: *tests.StandaloneContext) void { | ... | @@ -32,4 +32,12 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 32 | cases.addBuildFile("test/stage1/c_abi/build.zig", .{}); | 32 | cases.addBuildFile("test/stage1/c_abi/build.zig", .{}); |
| 33 | } | 33 | } |
| 34 | cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ .build_modes = true, .cross_targets = true }); | 34 | cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ .build_modes = true, .cross_targets = true }); |
| 35 | |||
| 36 | // Ensure the development tools are buildable. | ||
| 37 | cases.add("tools/gen_spirv_spec.zig"); | ||
| 38 | cases.add("tools/gen_stubs.zig"); | ||
| 39 | cases.add("tools/update_clang_options.zig"); | ||
| 40 | cases.add("tools/update_cpu_features.zig"); | ||
| 41 | cases.add("tools/update_glibc.zig"); | ||
| 42 | cases.add("tools/update_spirv_features.zig"); | ||
| 35 | } | 43 | } |
tools/gen_spirv_spec.zig+3| ... | @@ -14,6 +14,9 @@ pub fn main() !void { | ... | @@ -14,6 +14,9 @@ pub fn main() !void { |
| 14 | const spec_path = args[1]; | 14 | const spec_path = args[1]; |
| 15 | const spec = try std.fs.cwd().readFileAlloc(allocator, spec_path, std.math.maxInt(usize)); | 15 | const spec = try std.fs.cwd().readFileAlloc(allocator, spec_path, std.math.maxInt(usize)); |
| 16 | 16 | ||
| 17 | // Required for json parsing. | ||
| 18 | @setEvalBranchQuota(10000); | ||
| 19 | |||
| 17 | var tokens = std.json.TokenStream.init(spec); | 20 | var tokens = std.json.TokenStream.init(spec); |
| 18 | var registry = try std.json.parse(g.Registry, &tokens, .{ .allocator = allocator }); | 21 | var registry = try std.json.parse(g.Registry, &tokens, .{ .allocator = allocator }); |
| 19 | 22 |
tools/process_headers.zig+21-19| ... | @@ -234,17 +234,19 @@ const DestTarget = struct { | ... | @@ -234,17 +234,19 @@ const DestTarget = struct { |
| 234 | os: OsTag, | 234 | os: OsTag, |
| 235 | abi: Abi, | 235 | abi: Abi, |
| 236 | 236 | ||
| 237 | fn hash(a: DestTarget) u32 { | 237 | const HashContext = struct { |
| 238 | return @enumToInt(a.arch) +% | 238 | pub fn hash(self: @This(), a: DestTarget) u32 { |
| 239 | (@enumToInt(a.os) *% @as(u32, 4202347608)) +% | 239 | return @enumToInt(a.arch) +% |
| 240 | (@enumToInt(a.abi) *% @as(u32, 4082223418)); | 240 | (@enumToInt(a.os) *% @as(u32, 4202347608)) +% |
| 241 | } | 241 | (@enumToInt(a.abi) *% @as(u32, 4082223418)); |
| 242 | } | ||
| 242 | 243 | ||
| 243 | fn eql(a: DestTarget, b: DestTarget) bool { | 244 | pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool { |
| 244 | return a.arch.eql(b.arch) and | 245 | return a.arch.eql(b.arch) and |
| 245 | a.os == b.os and | 246 | a.os == b.os and |
| 246 | a.abi == b.abi; | 247 | a.abi == b.abi; |
| 247 | } | 248 | } |
| 249 | }; | ||
| 248 | }; | 250 | }; |
| 249 | 251 | ||
| 250 | const Contents = struct { | 252 | const Contents = struct { |
| ... | @@ -259,7 +261,7 @@ const Contents = struct { | ... | @@ -259,7 +261,7 @@ const Contents = struct { |
| 259 | }; | 261 | }; |
| 260 | 262 | ||
| 261 | const HashToContents = std.StringHashMap(Contents); | 263 | const HashToContents = std.StringHashMap(Contents); |
| 262 | const TargetToHash = std.ArrayHashMap(DestTarget, []const u8, DestTarget.hash, DestTarget.eql, true); | 264 | const TargetToHash = std.ArrayHashMap(DestTarget, []const u8, DestTarget.HashContext, true); |
| 263 | const PathTable = std.StringHashMap(*TargetToHash); | 265 | const PathTable = std.StringHashMap(*TargetToHash); |
| 264 | 266 | ||
| 265 | const LibCVendor = enum { | 267 | const LibCVendor = enum { |
| ... | @@ -423,9 +425,9 @@ pub fn main() !void { | ... | @@ -423,9 +425,9 @@ pub fn main() !void { |
| 423 | while (path_it.next()) |path_kv| { | 425 | while (path_it.next()) |path_kv| { |
| 424 | var contents_list = std.ArrayList(*Contents).init(allocator); | 426 | var contents_list = std.ArrayList(*Contents).init(allocator); |
| 425 | { | 427 | { |
| 426 | var hash_it = path_kv.value.*.iterator(); | 428 | var hash_it = path_kv.value_ptr.*.iterator(); |
| 427 | while (hash_it.next()) |hash_kv| { | 429 | while (hash_it.next()) |hash_kv| { |
| 428 | const contents = hash_to_contents.get(hash_kv.value.*).?; | 430 | const contents = hash_to_contents.getPtr(hash_kv.value_ptr.*).?; |
| 429 | try contents_list.append(contents); | 431 | try contents_list.append(contents); |
| 430 | } | 432 | } |
| 431 | } | 433 | } |
| ... | @@ -433,7 +435,7 @@ pub fn main() !void { | ... | @@ -433,7 +435,7 @@ pub fn main() !void { |
| 433 | const best_contents = contents_list.popOrNull().?; | 435 | const best_contents = contents_list.popOrNull().?; |
| 434 | if (best_contents.hit_count > 1) { | 436 | if (best_contents.hit_count > 1) { |
| 435 | // worth it to make it generic | 437 | // worth it to make it generic |
| 436 | const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key.* }); | 438 | const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* }); |
| 437 | try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?); | 439 | try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?); |
| 438 | try std.fs.cwd().writeFile(full_path, best_contents.bytes); | 440 | try std.fs.cwd().writeFile(full_path, best_contents.bytes); |
| 439 | best_contents.is_generic = true; | 441 | best_contents.is_generic = true; |
| ... | @@ -443,17 +445,17 @@ pub fn main() !void { | ... | @@ -443,17 +445,17 @@ pub fn main() !void { |
| 443 | missed_opportunity_bytes += this_missed_bytes; | 445 | missed_opportunity_bytes += this_missed_bytes; |
| 444 | std.debug.warn("Missed opportunity ({:2}): {s}\n", .{ | 446 | std.debug.warn("Missed opportunity ({:2}): {s}\n", .{ |
| 445 | std.fmt.fmtIntSizeDec(this_missed_bytes), | 447 | std.fmt.fmtIntSizeDec(this_missed_bytes), |
| 446 | path_kv.key.*, | 448 | path_kv.key_ptr.*, |
| 447 | }); | 449 | }); |
| 448 | } else break; | 450 | } else break; |
| 449 | } | 451 | } |
| 450 | } | 452 | } |
| 451 | var hash_it = path_kv.value.*.iterator(); | 453 | var hash_it = path_kv.value_ptr.*.iterator(); |
| 452 | while (hash_it.next()) |hash_kv| { | 454 | while (hash_it.next()) |hash_kv| { |
| 453 | const contents = hash_to_contents.get(hash_kv.value.*).?; | 455 | const contents = hash_to_contents.get(hash_kv.value_ptr.*).?; |
| 454 | if (contents.is_generic) continue; | 456 | if (contents.is_generic) continue; |
| 455 | 457 | ||
| 456 | const dest_target = hash_kv.key.*; | 458 | const dest_target = hash_kv.key_ptr.*; |
| 457 | const arch_name = switch (dest_target.arch) { | 459 | const arch_name = switch (dest_target.arch) { |
| 458 | .specific => |a| @tagName(a), | 460 | .specific => |a| @tagName(a), |
| 459 | else => @tagName(dest_target.arch), | 461 | else => @tagName(dest_target.arch), |
| ... | @@ -463,7 +465,7 @@ pub fn main() !void { | ... | @@ -463,7 +465,7 @@ pub fn main() !void { |
| 463 | @tagName(dest_target.os), | 465 | @tagName(dest_target.os), |
| 464 | @tagName(dest_target.abi), | 466 | @tagName(dest_target.abi), |
| 465 | }); | 467 | }); |
| 466 | const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, out_subpath, path_kv.key.* }); | 468 | const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* }); |
| 467 | try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?); | 469 | try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?); |
| 468 | try std.fs.cwd().writeFile(full_path, contents.bytes); | 470 | try std.fs.cwd().writeFile(full_path, contents.bytes); |
| 469 | } | 471 | } |
tools/update_cpu_features.zig+11-11| ... | @@ -902,19 +902,19 @@ fn processOneTarget(job: Job) anyerror!void { | ... | @@ -902,19 +902,19 @@ fn processOneTarget(job: Job) anyerror!void { |
| 902 | { | 902 | { |
| 903 | var it = root_map.iterator(); | 903 | var it = root_map.iterator(); |
| 904 | root_it: while (it.next()) |kv| { | 904 | root_it: while (it.next()) |kv| { |
| 905 | if (kv.key.len == 0) continue; | 905 | if (kv.key_ptr.len == 0) continue; |
| 906 | if (kv.key.*[0] == '!') continue; | 906 | if (kv.key_ptr.*[0] == '!') continue; |
| 907 | if (kv.value.* != .Object) continue; | 907 | if (kv.value_ptr.* != .Object) continue; |
| 908 | if (hasSuperclass(&kv.value.Object, "SubtargetFeature")) { | 908 | if (hasSuperclass(&kv.value_ptr.Object, "SubtargetFeature")) { |
| 909 | const llvm_name = kv.value.Object.get("Name").?.String; | 909 | const llvm_name = kv.value_ptr.Object.get("Name").?.String; |
| 910 | if (llvm_name.len == 0) continue; | 910 | if (llvm_name.len == 0) continue; |
| 911 | 911 | ||
| 912 | var zig_name = try llvmNameToZigName(arena, llvm_name); | 912 | var zig_name = try llvmNameToZigName(arena, llvm_name); |
| 913 | var desc = kv.value.Object.get("Desc").?.String; | 913 | var desc = kv.value_ptr.Object.get("Desc").?.String; |
| 914 | var deps = std.ArrayList([]const u8).init(arena); | 914 | var deps = std.ArrayList([]const u8).init(arena); |
| 915 | var omit = false; | 915 | var omit = false; |
| 916 | var flatten = false; | 916 | var flatten = false; |
| 917 | const implies = kv.value.Object.get("Implies").?.Array; | 917 | const implies = kv.value_ptr.Object.get("Implies").?.Array; |
| 918 | for (implies.items) |imply| { | 918 | for (implies.items) |imply| { |
| 919 | const other_key = imply.Object.get("def").?.String; | 919 | const other_key = imply.Object.get("def").?.String; |
| 920 | const other_obj = &root_map.getPtr(other_key).?.Object; | 920 | const other_obj = &root_map.getPtr(other_key).?.Object; |
| ... | @@ -960,13 +960,13 @@ fn processOneTarget(job: Job) anyerror!void { | ... | @@ -960,13 +960,13 @@ fn processOneTarget(job: Job) anyerror!void { |
| 960 | try all_features.append(feature); | 960 | try all_features.append(feature); |
| 961 | } | 961 | } |
| 962 | } | 962 | } |
| 963 | if (hasSuperclass(&kv.value.Object, "Processor")) { | 963 | if (hasSuperclass(&kv.value_ptr.Object, "Processor")) { |
| 964 | const llvm_name = kv.value.Object.get("Name").?.String; | 964 | const llvm_name = kv.value_ptr.Object.get("Name").?.String; |
| 965 | if (llvm_name.len == 0) continue; | 965 | if (llvm_name.len == 0) continue; |
| 966 | 966 | ||
| 967 | var zig_name = try llvmNameToZigName(arena, llvm_name); | 967 | var zig_name = try llvmNameToZigName(arena, llvm_name); |
| 968 | var deps = std.ArrayList([]const u8).init(arena); | 968 | var deps = std.ArrayList([]const u8).init(arena); |
| 969 | const features = kv.value.Object.get("Features").?.Array; | 969 | const features = kv.value_ptr.Object.get("Features").?.Array; |
| 970 | for (features.items) |feature| { | 970 | for (features.items) |feature| { |
| 971 | const feature_key = feature.Object.get("def").?.String; | 971 | const feature_key = feature.Object.get("def").?.String; |
| 972 | const feature_obj = &root_map.getPtr(feature_key).?.Object; | 972 | const feature_obj = &root_map.getPtr(feature_key).?.Object; |
| ... | @@ -979,7 +979,7 @@ fn processOneTarget(job: Job) anyerror!void { | ... | @@ -979,7 +979,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 979 | )) orelse continue; | 979 | )) orelse continue; |
| 980 | try deps.append(feature_zig_name); | 980 | try deps.append(feature_zig_name); |
| 981 | } | 981 | } |
| 982 | const tune_features = kv.value.Object.get("TuneFeatures").?.Array; | 982 | const tune_features = kv.value_ptr.Object.get("TuneFeatures").?.Array; |
| 983 | for (tune_features.items) |feature| { | 983 | for (tune_features.items) |feature| { |
| 984 | const feature_key = feature.Object.get("def").?.String; | 984 | const feature_key = feature.Object.get("def").?.String; |
| 985 | const feature_obj = &root_map.getPtr(feature_key).?.Object; | 985 | const feature_obj = &root_map.getPtr(feature_key).?.Object; |
tools/update_spirv_features.zig+3| ... | @@ -68,6 +68,9 @@ pub fn main() !void { | ... | @@ -68,6 +68,9 @@ pub fn main() !void { |
| 68 | usageAndExit(std.io.getStdErr(), args[0], 1); | 68 | usageAndExit(std.io.getStdErr(), args[0], 1); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | // Required for json parsing. | ||
| 72 | @setEvalBranchQuota(10000); | ||
| 73 | |||
| 71 | const registry_path = try fs.path.join(allocator, &.{ spirv_headers_root, "include", "spirv", "unified1", "spirv.core.grammar.json" }); | 74 | const registry_path = try fs.path.join(allocator, &.{ spirv_headers_root, "include", "spirv", "unified1", "spirv.core.grammar.json" }); |
| 72 | const registry_json = try std.fs.cwd().readFileAlloc(allocator, registry_path, std.math.maxInt(usize)); | 75 | const registry_json = try std.fs.cwd().readFileAlloc(allocator, registry_path, std.math.maxInt(usize)); |
| 73 | var tokens = std.json.TokenStream.init(registry_json); | 76 | var tokens = std.json.TokenStream.init(registry_json); |