Fix error handling in libafl_qemu_build (#2036)

* fix(libafl_qemu_build): assert command success

* fix(libafl_qemu_build): make sure linker_interceptor.py picks up correct compiler

Currently linker_interceptor.py uses 'cc' as the __LIBAFL_QEMU_BUILD_CC environment variable is never set

* remove redudant arg
This commit is contained in:
Stefan Zabka 2024-04-10 18:36:36 +02:00 committed by GitHub
parent 0d5c6219d8
commit 48463d079b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,20 +84,22 @@ pub fn build(
if !qemu_path.is_dir() {
println!("cargo:warning=Qemu not found, cloning with git ({QEMU_REVISION})...");
fs::create_dir_all(&qemu_path).unwrap();
Command::new("git")
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("init")
.status()
.unwrap();
Command::new("git")
.unwrap()
.success());
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("remote")
.arg("add")
.arg("origin")
.arg(QEMU_URL)
.status()
.unwrap();
Command::new("git")
.unwrap()
.success());
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("fetch")
.arg("--depth")
@ -105,13 +107,15 @@ pub fn build(
.arg("origin")
.arg(QEMU_REVISION)
.status()
.unwrap();
Command::new("git")
.unwrap()
.success());
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("checkout")
.arg("FETCH_HEAD")
.status()
.unwrap();
.unwrap()
.success());
fs::write(&qemu_rev, QEMU_REVISION).unwrap();
}
@ -290,22 +294,24 @@ pub fn build(
.arg("--disable-tests");
}
cmd.status().expect("Configure failed");
assert!(
cmd.status().expect("Invoking Configure failed").success(),
"Configure didn't finish successfully"
);
let mut cmd = Command::new("make");
cmd.current_dir(&build_dir)
.env("__LIBAFL_QEMU_BUILD_OUT", build_dir.join("linkinfo.json"))
.env("__LIBAFL_QEMU_BUILD_CC", cc_compiler.path())
.env("__LIBAFL_QEMU_BUILD_CXX", cpp_compiler.path())
.arg("-j");
if let Some(j) = jobs {
Command::new("make")
.current_dir(&build_dir)
.arg("-j")
.arg(&format!("{j}"))
.env("V", "1")
.status()
.expect("Make failed");
} else {
Command::new("make")
.current_dir(&build_dir)
.arg("-j")
.status()
.expect("Make failed");
cmd.arg(&format!("{j}")).env("V", "1");
}
assert!(
cmd.status().expect("Invoking Make Failed").success(),
"Make didn't finish successfully"
);
}
/*