From 18138bda1d20bac37cd785759b44c383e45fc112 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Feb 2024 15:33:13 -0800 Subject: [PATCH] Enable disabling `--cfg fuzzing_repro` 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. --- src/options/run.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/options/run.rs b/src/options/run.rs index 2d66511..6b2b2c5 100644 --- a/src/options/run.rs +++ b/src/options/run.rs @@ -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, @@ -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) } }