Skip to content

Commit

Permalink
Add optional feature 'no_cfg_fuzzing'
Browse files Browse the repository at this point in the history
This is to allow not setting 'fuzzing' flag when compiling fuzzed
targets.
Some crates (eg. secp256k1) stub some functions, when they detect
'fuzzing' flag, which makes them useless when fuzzing.
  • Loading branch information
lrubasze authored and smoelius committed Mar 16, 2023
1 parent b9c273a commit 8ece4f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ tempfile = "3.4"

[features]
reset_lazy_static = ["lazy_static"]
no_cfg_fuzzing = []
7 changes: 5 additions & 2 deletions src/bin/cargo-afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ where
// `-C codegen-units=1` is needed to work around link errors
// https://github.com/rust-fuzz/afl.rs/pull/193#issuecomment-933550430
let mut rustflags = format!(
"--cfg fuzzing \
-C debug-assertions \
"-C debug-assertions \
-C overflow_checks \
-C passes={passes} \
-C codegen-units=1 \
Expand All @@ -375,6 +374,10 @@ where
-C target-cpu=native "
);

if cfg!(not(feature = "no_cfg_fuzzing")) {
rustflags.push_str("--cfg fuzzing ");
}

if cfg!(target_os = "linux") {
// work around https://github.com/rust-fuzz/afl.rs/issues/141 /
// https://github.com/rust-lang/rust/issues/53945, can be removed once
Expand Down

0 comments on commit 8ece4f9

Please sign in to comment.