From 375e4338ba69ac5ee76bb933f46bde851c02fb9a Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Thu, 25 Sep 2025 08:49:59 -0400 Subject: [PATCH] Remove archive --- cargo-afl/src/common.rs | 4 ---- cargo-afl/src/config.rs | 27 +++------------------------ cargo-afl/src/main.rs | 7 +++---- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/cargo-afl/src/common.rs b/cargo-afl/src/common.rs index 470f98cd0..53aaadaf6 100644 --- a/cargo-afl/src/common.rs +++ b/cargo-afl/src/common.rs @@ -55,10 +55,6 @@ pub fn object_file_path() -> Result { afl_llvm_dir().map(|path| path.join("libafl-llvm-rt.o")) } -pub fn archive_file_path() -> Result { - afl_llvm_dir().map(|path| path.join("libafl-llvm-rt.a")) -} - pub fn plugins_available() -> Result { let afl_llvm_dir = afl_llvm_dir()?; for result in afl_llvm_dir diff --git a/cargo-afl/src/config.rs b/cargo-afl/src/config.rs index 7b849cdd4..790dbe7f8 100644 --- a/cargo-afl/src/config.rs +++ b/cargo-afl/src/config.rs @@ -10,12 +10,6 @@ use super::common; const AFL_SRC_PATH: &str = "AFLplusplus"; -// https://github.com/rust-fuzz/afl.rs/issues/148 -#[cfg(target_os = "macos")] -static AR_CMD: &str = "/usr/bin/ar"; -#[cfg(not(target_os = "macos"))] -static AR_CMD: &str = "ar"; - #[allow(clippy::struct_excessive_bools)] #[derive(Default, Parser)] #[clap(after_help = "\ @@ -37,8 +31,8 @@ pub struct Args { } pub fn config(args: &Args) -> Result<()> { - let archive_file_path = common::archive_file_path()?; - if !args.force && archive_file_path.exists() && args.plugins == common::plugins_available()? { + let object_file_path = common::object_file_path()?; + if !args.force && object_file_path.exists() && args.plugins == common::plugins_available()? { let version = common::afl_rustc_version()?; bail!( "AFL LLVM runtime was already built for Rust {version}; run `cargo afl config --build \ @@ -129,26 +123,11 @@ fn build_afl(args: &Args, work_dir: &Path) -> Result<()> { Ok(()) } -fn build_afl_llvm_runtime(args: &Args, work_dir: &Path) -> Result<()> { +fn build_afl_llvm_runtime(_args: &Args, work_dir: &Path) -> Result<()> { let object_file_path = common::object_file_path()?; let _: u64 = std::fs::copy(work_dir.join("afl-compiler-rt.o"), &object_file_path) .with_context(|| "could not copy object file")?; - let archive_file_path = common::archive_file_path()?; - let mut command = Command::new(AR_CMD); - command - .arg("r") - .arg(archive_file_path) - .arg(object_file_path); - - if !args.verbose { - command.stdout(Stdio::null()); - command.stderr(Stdio::null()); - } - - let success = command.status().as_ref().is_ok_and(ExitStatus::success); - ensure!(success, "could not run 'ar'"); - Ok(()) } diff --git a/cargo-afl/src/main.rs b/cargo-afl/src/main.rs index ae37822de..ab9a04e15 100644 --- a/cargo-afl/src/main.rs +++ b/cargo-afl/src/main.rs @@ -124,7 +124,7 @@ fn main() { }; if !matches!(afl_args.subcmd, Some(AflSubcommand::Config(..))) - && !common::archive_file_path().unwrap().exists() + && !common::object_file_path().unwrap().exists() { let version = common::afl_rustc_version().unwrap(); eprintln!( @@ -346,9 +346,8 @@ where let mut rustdocflags = rustflags.clone(); rustflags.push_str(&format!( - "-l afl-llvm-rt \ - -L {} ", - common::afl_llvm_dir().unwrap().display() + "-Clink-arg={} ", + common::object_file_path().unwrap().display() )); // add user provided flags