Skip to content

Instantly share code, notes, and snippets.

@leroycep
Created May 21, 2022 22:42
Show Gist options
  • Save leroycep/7558f9b35083887215fcb49256dc23e2 to your computer and use it in GitHub Desktop.
Save leroycep/7558f9b35083887215fcb49256dc23e2 to your computer and use it in GitHub Desktop.
debugging zig c backend duplicate typedef; https://github.com/ziglang/zig/issues/11651
new f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
new fd5814f465beb2c5 tuple "typedef struct {\n uintptr_t field_0;\n uint8_t field_1;\n} zig_T_tuple_7busize_2c_20u1_7d;\n"
new 8d02975f3a25a947 array_u8_sentinel_0 "typedef uint8_t zig_A_u8_5[5];\n"
new d5d7770a0890948e array_u8 "typedef uint8_t zig_A_u8_1[1];\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
new 4487d943b4f83aed array_u8_sentinel_0 "typedef uint8_t zig_A_u8_1[1];\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
new 25da5e8e385153e6 single_const_pointer "typedef uint16_t (*zig_F__2aconst_20fn_28_29_20anyerror_21void)(void);\n"
new 3b32fc1c5510a94 optional "typedef struct { uintptr_t payload; bool is_null; } zig_Q_usize;\n"
new d3026fb9de972f53 struct "typedef struct {\n zig_L_u8 name;\n zig_F__2aconst_20fn_28_29_20anyerror_21void func;\n zig_Q_usize async_frame_size;\n} zig_S_builtin_TestFn;\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
25da5e8e385153e6 single_const_pointer "typedef uint16_t (*zig_F__2aconst_20fn_28_29_20anyerror_21void)(void);\n"
3b32fc1c5510a94 optional "typedef struct { uintptr_t payload; bool is_null; } zig_Q_usize;\n"
d3026fb9de972f53 struct "typedef struct {\n zig_L_u8 name;\n zig_F__2aconst_20fn_28_29_20anyerror_21void func;\n zig_Q_usize async_frame_size;\n} zig_S_builtin_TestFn;\n"
new 6dc2604353536964 const_slice "typedef struct { zig_S_builtin_TestFn const * ptr; size_t len; } zig_L_builtin_TestFn;\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
new cabb949c9d4755d6 mut_slice "typedef struct { uintptr_t * ptr; size_t len; } zig_M_usize;\n"
new 7d147ecdb904467f struct "typedef struct {\n uintptr_t index;\n zig_M_usize instruction_addresses;\n} zig_S_builtin_StackTrace;\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
25da5e8e385153e6 single_const_pointer "typedef uint16_t (*zig_F__2aconst_20fn_28_29_20anyerror_21void)(void);\n"
3b32fc1c5510a94 optional "typedef struct { uintptr_t payload; bool is_null; } zig_Q_usize;\n"
d3026fb9de972f53 struct "typedef struct {\n zig_L_u8 name;\n zig_F__2aconst_20fn_28_29_20anyerror_21void func;\n zig_Q_usize async_frame_size;\n} zig_S_builtin_TestFn;\n"
new 4aa7cc831f5a8ee5 mut_slice "typedef struct { zig_S_builtin_TestFn * ptr; size_t len; } zig_M_builtin_TestFn;\n"
fd5814f465beb2c5 tuple "typedef struct {\n uintptr_t field_0;\n uint8_t field_1;\n} zig_T_tuple_7busize_2c_20u1_7d;\n"
f4a0c58216b9dad9 const_slice_u8 "typedef struct { uint8_t const * ptr; size_t len; } zig_L_u8;\n"
diff --git a/src/link/C.zig b/src/link/C.zig
index 4159a577d..b0349fc1b 100644
--- a/src/link/C.zig
+++ b/src/link/C.zig
@@ -384,8 +384,12 @@ fn flushDecl(self: *C, f: *Flush, decl_index: Module.Decl.Index) FlushDeclError!
.mod = module,
});
if (!gop.found_existing) {
+ std.debug.print("new ", .{});
try f.err_typedef_buf.appendSlice(gpa, new.value_ptr.rendered);
+ } else {
+ std.debug.print(" ", .{});
}
+ std.debug.print("{x: >16} {s: >20} \"{}\"\n", .{ (Type.HashContext64{ .mod = module }).hash(new.key_ptr.*), @tagName(new.key_ptr.*.tag()), std.zig.fmtEscapes(new.value_ptr.rendered) });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment