Skip to content

Handle old LLVM pass manager on rustc 1.57 #197

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
Dec 22, 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
19 changes: 14 additions & 5 deletions src/bin/cargo-afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,13 @@ where
let tsan_options = env::var("TSAN_OPTIONS").unwrap_or_default();
let tsan_options = format!("report_signal_unsafe=0:{}", tsan_options);

// 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();
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
let passes = if is_nightly() && version_meta.llvm_version.map_or(true, |v| v.major >= 13) {
"sancov-module"
} else {
"sancov"
Expand Down Expand Up @@ -377,3 +378,11 @@ where
.unwrap();
process::exit(status.code().unwrap_or(1));
}

fn is_nightly() -> bool {
Command::new("rustc")
.args(&["-Z", "help"])
.status()
.unwrap()
.success()
}