diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -163,8 +163,17 @@ pub fn build(b: *std.Build) void { .linkage = .static, }); if (libc_file) |f| lib.setLibCFile(f); - lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/parser.c") }); - if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c") }); + // grammars declare external_scanner_create() with EMPTY PARENS + // (a K&R non-prototype, not (void)): under clang's + // -fsanitize=function the callee's type hash differs from the + // runtime's void*(*)(void) call through the pointer, so the + // first scanner call of ANY parse traps (function_type_mismatch, + // an ud1 blamed on a random inlined line). Uninstrumented + // callees make the runtime's call-site checks skip; the rest + // of UBSan stays live for the grammar code. + const ts_cflags = [_][]const u8{"-fno-sanitize=function"}; + lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/parser.c"), .flags = &ts_cflags }); + if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c"), .flags = &ts_cflags }); lib.root_module.addIncludePath(dep.path(g.src)); root_mod.linkLibrary(lib); if (is_emscripten) wasm_libs.append(b.allocator, lib.getEmittedBin()) catch @panic("OOM"); |
