diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2022-06-09 16:58:09 +0200 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2022-06-13 13:30:56 +0200 |
commit | c12577c61dbf37b1b6ae25ed422a900ac71f18fe (patch) | |
tree | 8e1b78c1d2ab7f7db1f9e47eaa6fb60013c6f8e5 /clang/lib/Driver/Compilation.cpp | |
parent | 84b9ae662419ce97b3cb13879be431f6a0c9eaa4 (diff) | |
download | llvm-c12577c61dbf37b1b6ae25ed422a900ac71f18fe.zip llvm-c12577c61dbf37b1b6ae25ed422a900ac71f18fe.tar.gz llvm-c12577c61dbf37b1b6ae25ed422a900ac71f18fe.tar.bz2 |
[clang][driver] Introduce new -fdriver-only flag
This patch introduces the new -fdriver-only flag which instructs Clang to only execute the driver logic without running individual jobs. In a way, this is very similar to -###, with the following differences:
* it doesn't automatically print all jobs,
* it doesn't avoid side effects (e.g. it will generate compilation database when -MJ is specified).
This flag will be useful in testing D121997.
Reviewed By: dexonsmith, egorzhdan
Differential Revision: https://reviews.llvm.org/D127408
Diffstat (limited to 'clang/lib/Driver/Compilation.cpp')
-rw-r--r-- | clang/lib/Driver/Compilation.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index 67d941c..b4367a0 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -162,7 +162,8 @@ bool Compilation::CleanupFileMap(const ArgStringMap &Files, } int Compilation::ExecuteCommand(const Command &C, - const Command *&FailingCommand) const { + const Command *&FailingCommand, + bool LogOnly) const { if ((getDriver().CCPrintOptions || getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) { raw_ostream *OS = &llvm::errs(); @@ -191,6 +192,9 @@ int Compilation::ExecuteCommand(const Command &C, C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions); } + if (LogOnly) + return 0; + std::string Error; bool ExecutionFailed; int Res = C.Execute(Redirects, &Error, &ExecutionFailed); @@ -237,7 +241,8 @@ static bool InputsOk(const Command &C, } void Compilation::ExecuteJobs(const JobList &Jobs, - FailingCommandList &FailingCommands) const { + FailingCommandList &FailingCommands, + bool LogOnly) const { // According to UNIX standard, driver need to continue compiling all the // inputs on the command line even one of them failed. // In all but CLMode, execute all the jobs unless the necessary inputs for the @@ -246,7 +251,7 @@ void Compilation::ExecuteJobs(const JobList &Jobs, if (!InputsOk(Job, FailingCommands)) continue; const Command *FailingCommand = nullptr; - if (int Res = ExecuteCommand(Job, FailingCommand)) { + if (int Res = ExecuteCommand(Job, FailingCommand, LogOnly)) { FailingCommands.push_back(std::make_pair(Res, FailingCommand)); // Bail as soon as one command fails in cl driver mode. if (TheDriver.IsCLMode()) |