Skip to content

Commit

Permalink
Make ddg map compilation optional (#2341)
Browse files Browse the repository at this point in the history
* Make ddg map compilation optional

* undo

* undo
  • Loading branch information
domenukk authored Jun 26, 2024
1 parent ea6e440 commit 8031111
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions libafl_cc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ categories = ["development-tools::testing", "emulators", "embedded", "os", "no-s

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = []

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = "6.0"
Expand Down
30 changes: 15 additions & 15 deletions libafl_cc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn build_pass(
src_dir: &Path,
src_file: &str,
additional_srcfiles: Option<&Vec<&str>>,
optional: bool,
required: bool,
) {
let dot_offset = src_file.rfind('.').unwrap();
let src_stub = &src_file[..dot_offset];
Expand All @@ -164,7 +164,7 @@ fn build_pass(
};

println!("cargo:rerun-if-changed=src/{src_file}");
let r = if cfg!(unix) {
let command_result = if cfg!(unix) {
let r = Command::new(bindir_path.join("clang++"))
.arg("-v")
.arg(format!("--target={}", env::var("HOST").unwrap()))
Expand Down Expand Up @@ -198,27 +198,27 @@ fn build_pass(
None
};

match r {
Some(r) => match r {
match command_result {
Some(res) => match res {
Ok(s) => {
if !s.success() {
if optional {
println!("cargo:warning=Skipping src/{src_file} - Exit status: {s}");
if required {
panic!("Failed to compile required compiler pass src/{src_file} - Exit status: {s}");
} else {
panic!("Failed to compile {src_file} - Exit status: {s}");
println!("cargo:warning=Skipping non-required compiler pass src/{src_file} - Reason: Exit status {s}");
}
}
}
Err(err) => {
if optional {
println!("cargo:warning=Skipping src/{src_file} - {err}");
if required {
panic!("Failed to compile required compiler pass src/{src_file} - {err}");
} else {
panic!("Failed to compile {src_file} - {err}");
println!("cargo:warning=Skipping non-required compiler pass src/{src_file} - Reason: {err}");
}
}
},
None => {
println!("cargo:warning=Skipping src/{src_file} - Only supported on Windows or *nix.");
println!("cargo:warning=Skipping compiler pass src/{src_file} - Only supported on Windows or *nix.");
}
}
}
Expand Down Expand Up @@ -427,7 +427,7 @@ pub const LIBAFL_CC_LLVM_VERSION: Option<usize> = None;
false,
);

for pass in &[
for pass in [
"function-logging.cc",
"cmplog-routines-pass.cc",
"autotokens-pass.cc",
Expand All @@ -443,12 +443,12 @@ pub const LIBAFL_CC_LLVM_VERSION: Option<usize> = None;
src_dir,
pass,
None,
false,
true,
);
}

// Optional pass
for pass in &["dump-cfg-pass.cc", "profiling.cc"] {
for pass in ["dump-cfg-pass.cc", "profiling.cc"] {
build_pass(
bindir_path,
out_dir,
Expand All @@ -457,7 +457,7 @@ pub const LIBAFL_CC_LLVM_VERSION: Option<usize> = None;
src_dir,
pass,
None,
true,
false,
);
}

Expand Down
2 changes: 1 addition & 1 deletion libafl_qemu/libafl_qemu_build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ pub fn build(

/*
let mut objects = vec![];
for dir in &[
for dir in [
build_dir.join("libcommon.fa.p"),
build_dir.join(format!("libqemu-{cpu_target}-{target_suffix}.fa.p")),
] {
Expand Down

0 comments on commit 8031111

Please sign in to comment.