authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-10-17 11:51:39+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-10-17 11:55:17+03:00
log96f9e20152001c7611b2c40f36ef9a522165d9d0
tree696de46e18d697cd772ccf9c36b7a967ca50749e
parente765495b114af3417aea4cffcd7c37f400aab3fe

add c_frontend to translate-c cache hash


4 files changed, 10 insertions(+), 5 deletions(-)

src/Compilation.zig+1
......@@ -3936,6 +3936,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
39363936
39373937 man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
39383938 man.hash.addBytes(c_src);
3939 man.hash.add(comp.c_frontend);
39393940
39403941 // If the previous invocation resulted in clang errors, we will see a hit
39413942 // here with 0 files in the manifest, in which case it is actually a miss.
src/aro_translate_c.zig+5-2
......@@ -308,7 +308,6 @@ fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void {
308308fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void {
309309 const node_types = c.tree.nodes.items(.ty);
310310 const ty = node_types[@intFromEnum(enum_decl)];
311 const node_data = c.tree.nodes.items(.data);
312311 if (c.decl_table.get(@intFromPtr(ty.data.@"enum"))) |_|
313312 return; // Avoid processing this decl twice
314313 const toplevel = scope.id == .root;
......@@ -342,11 +341,15 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes:
342341 else => |e| return e,
343342 };
344343
344 const val = c.tree.value_map.get(field_node).?;
345 const str = try std.fmt.allocPrint(c.arena, "{d}", .{val.data.int});
346 const int = try ZigTag.integer_literal.create(c.arena, str);
347
345348 const enum_const_def = try ZigTag.enum_constant.create(c.arena, .{
346349 .name = enum_val_name,
347350 .is_public = toplevel,
348351 .type = enum_const_type_node,
349 .value = transExpr(c, node_data[@intFromEnum(field_node)].decl.node, .used) catch @panic("TODO"),
352 .value = int,
350353 });
351354 if (toplevel)
352355 try addTopLevelDecl(c, enum_val_name, enum_const_def)
src/main.zig+1
......@@ -4238,6 +4238,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati
42384238 defer man.deinit();
42394239
42404240 man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
4241 man.hash.add(comp.c_frontend);
42414242 Compilation.cache_helpers.hashCSource(&man, c_source_file) catch |err| {
42424243 fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) });
42434244 };
test/src/Cases.zig+3-3
......@@ -681,11 +681,11 @@ pub fn lowerToBuildSteps(
681681 }
682682 }
683683
684 for (self.translate.items) |*case| switch (case.kind) {
684 for (self.translate.items) |case| switch (case.kind) {
685685 .run => |output| {
686686 const annotated_case_name = b.fmt("run-translated-c {s}", .{case.name});
687687 if (opt_test_filter) |filter| {
688 if (std.mem.indexOf(u8, annotated_case_name, filter) == null) return;
688 if (std.mem.indexOf(u8, annotated_case_name, filter) == null) continue;
689689 }
690690 if (!std.process.can_spawn) {
691691 std.debug.print("Unable to spawn child processes on {s}, skipping test.\n", .{@tagName(builtin.os.tag)});
......@@ -723,7 +723,7 @@ pub fn lowerToBuildSteps(
723723 .translate => |output| {
724724 const annotated_case_name = b.fmt("zig translate-c {s}", .{case.name});
725725 if (opt_test_filter) |filter| {
726 if (std.mem.indexOf(u8, annotated_case_name, filter) == null) return;
726 if (std.mem.indexOf(u8, annotated_case_name, filter) == null) continue;
727727 }
728728
729729 const write_src = b.addWriteFiles();