Skip to content

Commit

Permalink
Enable disabling --cfg fuzzing_repro
Browse files Browse the repository at this point in the history
Changing `RUSTFLAGS` causes a recompile of the entire project so for
projects that are expensive to build this option being enabled by
default means that workflows which switch back-and-forth between fuzzing
and running individual tests generate a full rebuild every time. This
adds a `--no-cfg-fuzzing` option on the `cargo fuzz run` CLI to disable
this `--cfg` argument from being passed.
  • Loading branch information
alexcrichton committed Feb 13, 2024
1 parent 7302ebf commit 18138bd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/options/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ pub struct Run {
/// Number of concurrent jobs to run
pub jobs: u16,

/// By default the 'cfg(fuzzing_repro)' compilation configuration is set
/// when a single test case is being run, and this flag allows you to opt
/// out of it.
#[arg(long)]
pub no_cfg_fuzzing_repro: bool,

#[arg(last(true))]
/// Additional libFuzzer arguments passed through to the binary
pub args: Vec<String>,
Expand All @@ -37,7 +43,7 @@ pub struct Run {
impl RunCommand for Run {
fn run_command(&mut self) -> Result<()> {
let project = FuzzProject::new(self.fuzz_dir_wrapper.fuzz_dir.to_owned())?;
self.build.cfg_fuzzing_repro = !self.corpus.is_empty();
self.build.cfg_fuzzing_repro = !self.corpus.is_empty() && !self.no_cfg_fuzzing_repro;
project.exec_fuzz(self)
}
}

0 comments on commit 18138bd

Please sign in to comment.