Skip to content

Update for new LLVM pass manager #193

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 2 commits into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/bin/cargo-afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,33 @@ where

// add some flags to sanitizers to make them work with Rust code
let asan_options = env::var("ASAN_OPTIONS").unwrap_or_default();
let asan_options = format!("detect_odr_violation=0:abort_on_error=1:symbolize=0:{}", asan_options);
let asan_options = format!(
"detect_odr_violation=0:abort_on_error=1:symbolize=0:{}",
asan_options
);

let tsan_options = env::var("TSAN_OPTIONS").unwrap_or_default();
let tsan_options = format!("report_signal_unsafe=0:{}", tsan_options);

let version_meta = rustc_version::version_meta().unwrap();
let passes = if version_meta.semver.minor >= 57
&& version_meta.llvm_version.map_or(true, |v| v.major >= 13)
{
// New LLVM pass manager is enabled when Rust 1.57+ and LLVM 13+
// https://github.com/rust-lang/rust/pull/88243
"sancov-module"
} else {
"sancov"
};

// `-C codegen-units=1` is needed to work around link errors
// https://github.com/rust-fuzz/afl.rs/pull/193#issuecomment-933550430
let mut rustflags = format!(
"--cfg fuzzing \
-C debug-assertions \
-C overflow_checks \
-C passes=sancov \
-C passes={} \
-C codegen-units=1 \
-C llvm-args=-sanitizer-coverage-level=3 \
-C llvm-args=-sanitizer-coverage-trace-pc-guard \
-C llvm-args=-sanitizer-coverage-prune-blocks=0 \
Expand All @@ -313,6 +330,7 @@ where
-C debuginfo=0 \
-l afl-llvm-rt \
-L {} ",
passes,
common::afl_llvm_rt_dir().display()
);

Expand All @@ -323,14 +341,16 @@ where
"--cfg fuzzing \
-C debug-assertions \
-C overflow_checks \
-C passes=sancov \
-C passes={} \
-C codegen-units=1 \
-C llvm-args=-sanitizer-coverage-level=3 \
-C llvm-args=-sanitizer-coverage-trace-pc-guard \
-C llvm-args=-sanitizer-coverage-prune-blocks=0 \
-C opt-level=3 \
-C target-cpu=native \
-C debuginfo=0 \
-L {} ",
passes,
common::afl_llvm_rt_dir().display()
);

Expand Down