Zig Version
0.16.0-dev.2694+74f361a5c
Steps to Reproduce and Observed Behavior
I wasn't able to reproduce the issue when using a simple C file instead of LZ4.
zig fetch --save=lz4 "git+https://github.com/lz4/lz4#v1.10.0"
build.zig
conststd=@import("std");pubfnbuild(b:*std.Build)void{consttarget=b.standardTargetOptions(.{});constoptimize=b.standardOptimizeOption(.{});consttest_step=b.step("test","Run tests.");constmodule=b.createModule(.{.root_source_file=b.path("src/main.zig"),.target=target,.optimize=optimize,.link_libc=true,});constlz4_src=b.dependency("lz4",.{});module.addIncludePath(lz4_src.path("lib"));module.addCSourceFile(.{.file=lz4_src.path("lib/lz4.c")});consttest_artifact=b.addRunArtifact(b.addTest(.{.root_module=module}));test_step.dependOn(&test_artifact.step);}
src/main.zig
conststd=@import("std");constc=@cImport(@cInclude("lz4.h"));pubfnmain()!void{}test"fuzz example"{trystd.testing.fuzz({},testOne,.{});}fntestOne(context:void,smith:*std.testing.Smith)!void{_=context;_=smith;consthello="Hello Zig";varaaaaa:[10]u8=undefined;_=c.LZ4_decompress_safe(hello.ptr,&aaaaa,hello.len,aaaaa.len);}
> zig build test --fuzz
info(web_server): web interface listening at http://[::1]:33599/
info(web_server): hint: pass '--webui=[::1]:33599' to use the same port next time
Build Summary: 3/3 steps succeeded; 1/1 tests passed
test
└─ run test
└─ compile test Debug native 6 errors
error: undefined symbol: __sanitizer_cov_trace_const_cmp4
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compressBound
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compressBound
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 2666 more times
error: undefined symbol: __sanitizer_cov_trace_const_cmp8
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 6999 more times
error: undefined symbol: __sanitizer_cov_trace_cmp4
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 474 more times
error: undefined symbol: __sanitizer_cov_trace_cmp1
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 4189 more times
error: undefined symbol: __sanitizer_cov_trace_cmp8
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 6505 more times
error: undefined symbol: __sanitizer_cov_trace_switch
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 107 more times
error: 6 compilation errors
...
Using LLVM and LLD for the test didn't help, changing the optimization mode for the module and fuzzer (using --debug-rt flag or with b.graph.debug_compiler_runtime_libs = optimize;) also didn't.
Expected Behavior
Code compiles and fuzzing is run.
### Zig Version
0.16.0-dev.2694+74f361a5c
### Steps to Reproduce and Observed Behavior
I wasn't able to reproduce the issue when using a simple C file instead of LZ4.
```
zig fetch --save=lz4 "git+https://github.com/lz4/lz4#v1.10.0"
```
### build.zig
```zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const test_step = b.step("test", "Run tests.");
const module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const lz4_src = b.dependency("lz4", .{});
module.addIncludePath(lz4_src.path("lib"));
module.addCSourceFile(.{ .file = lz4_src.path("lib/lz4.c") });
const test_artifact = b.addRunArtifact(b.addTest(.{ .root_module = module }));
test_step.dependOn(&test_artifact.step);
}
```
### src/main.zig
```zig
const std = @import("std");
const c = @cImport(@cInclude("lz4.h"));
pub fn main() !void {}
test "fuzz example" {
try std.testing.fuzz({}, testOne, .{});
}
fn testOne(context: void, smith: *std.testing.Smith) !void {
_ = context;
_ = smith;
const hello = "Hello Zig";
var aaaaa: [10]u8 = undefined;
_ = c.LZ4_decompress_safe(hello.ptr, &aaaaa, hello.len, aaaaa.len);
}
```
```
> zig build test --fuzz
info(web_server): web interface listening at http://[::1]:33599/
info(web_server): hint: pass '--webui=[::1]:33599' to use the same port next time
Build Summary: 3/3 steps succeeded; 1/1 tests passed
test
└─ run test
└─ compile test Debug native 6 errors
error: undefined symbol: __sanitizer_cov_trace_const_cmp4
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compressBound
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compressBound
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 2666 more times
error: undefined symbol: __sanitizer_cov_trace_const_cmp8
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 6999 more times
error: undefined symbol: __sanitizer_cov_trace_cmp4
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 474 more times
error: undefined symbol: __sanitizer_cov_trace_cmp1
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 4189 more times
error: undefined symbol: __sanitizer_cov_trace_cmp8
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 6505 more times
error: undefined symbol: __sanitizer_cov_trace_switch
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced by .zig-cache/o/8b2e772c078a1be55e93b8f29553abbb/lz4.o:.text.LZ4_compress_fast_extState
note: referenced 107 more times
error: 6 compilation errors
...
```
Using LLVM and LLD for the test didn't help, changing the optimization mode for the module and fuzzer (using `--debug-rt` flag or with `b.graph.debug_compiler_runtime_libs = optimize;`) also didn't.
### Expected Behavior
Code compiles and fuzzing is run.