diff --git a/libafl_cc/build.rs b/libafl_cc/build.rs index 834e6f6c9d..5f3334429a 100644 --- a/libafl_cc/build.rs +++ b/libafl_cc/build.rs @@ -1,6 +1,11 @@ -#[cfg(target_vendor = "apple")] -use std::path::PathBuf; -use std::{env, fs::File, io::Write, path::Path, process::Command, str}; +use std::{ + env, + fs::File, + io::Write, + path::{Path, PathBuf}, + process::Command, + str, +}; #[cfg(target_vendor = "apple")] use glob::glob; @@ -125,6 +130,7 @@ fn find_llvm_version() -> Option { None } +#[allow(clippy::too_many_arguments)] fn build_pass( bindir_path: &Path, out_dir: &Path, @@ -132,17 +138,25 @@ fn build_pass( ldflags: &Vec<&str>, src_dir: &Path, src_file: &str, + additional_srcfiles: Option<&Vec<&str>>, optional: bool, ) { let dot_offset = src_file.rfind('.').unwrap(); let src_stub = &src_file[..dot_offset]; + let additionals = if let Some(x) = additional_srcfiles { + x.iter().map(|f| src_dir.join(f)).collect::>() + } else { + Vec::new() + }; + println!("cargo:rerun-if-changed=src/{src_file}"); let r = if cfg!(unix) { let r = Command::new(bindir_path.join("clang++")) .arg("-v") .args(cxxflags) .arg(src_dir.join(src_file)) + .args(additionals) .args(ldflags) .arg("-o") .arg(out_dir.join(format!("{src_stub}.{}", dll_extension()))) @@ -154,6 +168,7 @@ fn build_pass( .arg("-v") .args(cxxflags) .arg(src_dir.join(src_file)) + .args(additionals) .arg("/link") .args(ldflags) .arg(format!( @@ -359,6 +374,7 @@ pub const LIBAFL_CC_LLVM_VERSION: Option = None; &ldflags, src_dir, pass, + None, false, ); } @@ -372,6 +388,7 @@ pub const LIBAFL_CC_LLVM_VERSION: Option = None; &ldflags, src_dir, pass, + None, true, ); }