From 530a3cc6aaef6842b72fbf59405be55503a3a766 Mon Sep 17 00:00:00 2001 From: Romain Malmain Date: Mon, 17 Feb 2025 14:47:38 +0100 Subject: [PATCH] Better error for libafl_cc when binaries are not found (#2988) * better error when libafl_cc does not work as expected * better msg, clippy --- libafl_cc/build.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libafl_cc/build.rs b/libafl_cc/build.rs index 7e33468a52..7cf17f6a0c 100644 --- a/libafl_cc/build.rs +++ b/libafl_cc/build.rs @@ -333,20 +333,25 @@ pub const LIBAFL_CC_LLVM_VERSION: Option = None; llvm_ar = Path::new(&llvm_ar_path).join("llvm-ar"); } + let mut found = true; + if !clang.exists() { - println!("cargo:warning=Failed to find clang frontend."); - return; + println!("cargo:warning=Failed to find binary: clang."); + found = false; } if !clangcpp.exists() { - println!("cargo:warning=Failed to find clang++ frontend."); - return; + println!("cargo:warning=Failed to find binary: clang++."); + found = false; } + if !llvm_ar.exists() { - println!("cargo:warning=Failed to find llvm-ar archiver."); - return; + println!("cargo:warning=Failed to find binary: llvm-ar."); + found = false; } + assert!(found, "\n\tAt least one of the LLVM dependencies could not be found.\n\tThe following search directory was considered: {}\n", bindir_path.display()); + let cxxflags = if let Ok(flags) = llvm_cxxflags { flags } else {