Skip to content

fix: pass sancov or sancov-module #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 16, 2022
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ result
flake.lock

# vim
**/*.rs.bk
**/*.rs.bk
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ maintenance = { status = "actively-developed" }

[dependencies]
arbitrary = "1"
rustc_version = "0.4"

[dev-dependencies]
rand = "0.8"
Expand Down
16 changes: 15 additions & 1 deletion src/bin/cargo-hfuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,22 @@ fn hfuzz_build<T>(args: T, crate_root: &Path, build_type: &BuildType) where T: s
");

if *build_type == BuildType::ReleaseInstrumented {
// The new LLVM pass manager was not enabled in rustc 1.57 as expected:
// https://github.com/rust-lang/rust/pull/91263
// The fix for now is to pass `-C passes=sancov-module` only to nightly
// compilers for which the LLVM version is >= 13.
let version_meta = rustc_version::version_meta().unwrap();
if version_meta.channel == rustc_version::Channel::Nightly && version_meta.llvm_version.map_or(true, |v| v.major >= 13) {
rustflags.push_str("\
-C passes=sancov-module \
");
} else {
rustflags.push_str("\
-C passes=sancov \
");
};

rustflags.push_str("\
-C passes=sancov \
-C llvm-args=-sanitizer-coverage-level=4 \
-C llvm-args=-sanitizer-coverage-trace-pc-guard \
-C llvm-args=-sanitizer-coverage-trace-divs \
Expand Down