Skip to content
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
22 changes: 22 additions & 0 deletions src/bin/cargo-ziggy/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ fn is_using_nightly_toolchain() -> bool {
String::from_utf8_lossy(&out.stdout).contains("nightly")
}

fn afl_plugins_installed(common: &Common) -> bool {
common
.cargo()
.args(["afl", "--version"])
.output()
.is_ok_and(|out| String::from_utf8_lossy(&out.stdout).contains("with plugins"))
}

impl Build {
/// Build the fuzzers
pub fn build(&self, common: &Common) -> Result<(), anyhow::Error> {
Expand All @@ -26,8 +34,22 @@ impl Build {
bail!("ASAN requires nightly toolchain");
}

if !is_nightly {
eprintln!(
" {} the Rust toolchain is not nightly; AFL++ CMPLOG and ASAN instrumentation are unavailable",
style("Warning:").yellow().bold()
);
}

let cx = Context::new(common, self.target.clone())?;

if is_nightly && !self.no_afl && !afl_plugins_installed(common) {
eprintln!(
" {} the AFL++ LLVM plugins are not available; build them with `cargo afl config --update --plugins --verbose`",
style("Warning:").yellow().bold()
);
}

if !self.no_afl {
eprintln!(" {} afl", style("Building").red().bold());
let target_dir = format!("--target-dir={}", cx.target_dir.join("afl"));
Expand Down