# fix \`\-fsanitize-coverage-trace-pc-guard\` and fuzzer support for C compile units · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/84ece5624a153da44faca52ff622cd03b887d375)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 84ece5624a153da44faca52ff622cd03b887d375

Requested commit: 84ece5624a153da44faca52ff622cd03b887d375

Commit: 84ece5624a153da44faca52ff622cd03b887d375

Tree: a5d520b4f102b6dda9a145f7e4aa9a214894378b

Author: Xavier Bouchoux

Committer: Alex Rønne Petersen

## Message

```
fix `-fsanitize-coverage-trace-pc-guard` and fuzzer support for C compile units

 - allow `-fsanitize-coverage-trace-pc-guard` to be used on its own without enabling the fuzzer.
   (note that previouly, while the flag was only active when fuzzing, the fuzzer itself doesn't use it, and the code will not link as is.)

 - add stub functions in the fuzzer to link with instrumented C code (previously fuzzed tests failed to link if they were calling into C):
   while the zig compile unit uses a custom `EmitOptions.Coverage` with features disabled,
   the C code is built calling into the clang driver with "-fsanitize=fuzzer-no-link" that automatically enables the default features.
	(see https://github.com/llvm/llvm-project/blob/de06978ebcff5f75913067b019d2d522d0be0872/clang/lib/Driver/SanitizerArgs.cpp#L587)

 - emit `-fsanitize-coverage=trace-pc-guard` instead of `-Xclang -fsanitize-coverage-trace-pc-guard` so that edge coverrage is enabled by clang driver. (previously, it was enabled only because the fuzzer was)

```

## Parents

- [aa5c6c027c3f69602f5bcd1ad0b4a89232c85ae1](https://git.cafe/gitcafe/zig/commit/aa5c6c027c3f69602f5bcd1ad0b4a89232c85ae1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/84ece5624a153da44faca52ff622cd03b887d375?format=markdown)
