Exempt the clang subcommand when fuzzing. (#4468)

This teaches the driver library to track when its being used with
fuzzing and disables the `clang` subcommand from actually running Clang.

The Clang libraries have a large backlog of fuzzer-found issues that
isn't being actively reduced, so we can't productively fuzz into it.
This lets us more productively fuzz at the top level.

This is also available on the command line itself, which should be
useful if anyone wants to fuzz Carbon from the command line using tools
like AFL -- they can inject this flag to avoid getting noise from the
fuzzer hitting known issues in Clang.
This commit is contained in:
Chandler Carruth
2024-11-01 15:35:29 +00:00
committed by GitHub
parent 32e5212daa
commit 954441c358
5 changed files with 31 additions and 0 deletions
+9
View File
@@ -44,6 +44,15 @@ Arguments passed to Clang.
auto ClangSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
std::string target = llvm::sys::getDefaultTargetTriple();
ClangRunner runner(driver_env.installation, target, driver_env.vlog_stream);
// Don't run Clang when fuzzing, it is known to not be reliable under fuzzing
// due to many unfixed issues.
if (driver_env.fuzzing) {
driver_env.error_stream
<< "error: cannot run `clang` subcommand productively when fuzzing\n";
return {.success = false};
}
return {.success = runner.Run(options_.args)};
}