From b1c29bc87768e73bfe9a3fbf080b274198e6282c Mon Sep 17 00:00:00 2001 From: "Samuel E. Moelius III" Date: Thu, 16 Dec 2021 14:02:48 -0500 Subject: [PATCH 1/2] Handle old LLVM pass manager on rustc 1.57 --- src/bin/cargo-afl.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/bin/cargo-afl.rs b/src/bin/cargo-afl.rs index 1120ce470..f7ab18f4c 100644 --- a/src/bin/cargo-afl.rs +++ b/src/bin/cargo-afl.rs @@ -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 only pass `-C passes=sancov-module` 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" @@ -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() +} From 169427879fd74bae21d63be6b8fe41a293f6dee6 Mon Sep 17 00:00:00 2001 From: Samuel Moelius <35515885+smoelius@users.noreply.github.com> Date: Wed, 22 Dec 2021 10:28:50 -0500 Subject: [PATCH 2/2] Grammar --- src/bin/cargo-afl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/cargo-afl.rs b/src/bin/cargo-afl.rs index f7ab18f4c..826978aa8 100644 --- a/src/bin/cargo-afl.rs +++ b/src/bin/cargo-afl.rs @@ -305,7 +305,7 @@ where // 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 only pass `-C passes=sancov-module` to nightly + // 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();