Skip to content

Commit 019f8c3

Browse files
authored
Merge pull request #197 from smoelius/master
Handle old LLVM pass manager on rustc 1.57
2 parents 6aae34a + 1694278 commit 019f8c3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/bin/cargo-afl.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,13 @@ where
303303
let tsan_options = env::var("TSAN_OPTIONS").unwrap_or_default();
304304
let tsan_options = format!("report_signal_unsafe=0:{}", tsan_options);
305305

306+
// The new LLVM pass manager was not enabled in rustc 1.57 as expected:
307+
// https://github.com/rust-lang/rust/pull/91263
308+
// The fix for now is to pass `-C passes=sancov-module` only to nightly
309+
// compilers for which the LLVM version is >= 13.
310+
306311
let version_meta = rustc_version::version_meta().unwrap();
307-
let passes = if version_meta.semver.minor >= 57
308-
&& version_meta.llvm_version.map_or(true, |v| v.major >= 13)
309-
{
310-
// New LLVM pass manager is enabled when Rust 1.57+ and LLVM 13+
311-
// https://github.com/rust-lang/rust/pull/88243
312+
let passes = if is_nightly() && version_meta.llvm_version.map_or(true, |v| v.major >= 13) {
312313
"sancov-module"
313314
} else {
314315
"sancov"
@@ -377,3 +378,11 @@ where
377378
.unwrap();
378379
process::exit(status.code().unwrap_or(1));
379380
}
381+
382+
fn is_nightly() -> bool {
383+
Command::new("rustc")
384+
.args(&["-Z", "help"])
385+
.status()
386+
.unwrap()
387+
.success()
388+
}

0 commit comments

Comments
 (0)