diff options
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index c4d983fa2da..8068bbea78d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -576,8 +576,31 @@ void Driver::generateCompilationDiagnostics(Compilation &C, } } -int Driver::ExecuteCompilation(const Compilation &C, - SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands) const { +void Driver::setUpResponseFiles(Compilation &C, Job &J) { + if (JobList *Jobs = dyn_cast<JobList>(&J)) { + for (JobList::iterator I = Jobs->begin(), E = Jobs->end(); I != E; ++I) + setUpResponseFiles(C, **I); + return; + } + + Command *CurCommand = dyn_cast<Command>(&J); + if (!CurCommand) + return; + + // Since argumentsFitWithinSystemLimits() may underestimate system's capacity + // if the tool does not support response files, there is a chance/ that things + // will just work without a response file, so we silently just skip it. + if (CurCommand->getCreator().getResponseFilesSupport() == Tool::RF_None || + llvm::sys::argumentsFitWithinSystemLimits(CurCommand->getArguments())) + return; + + std::string TmpName = GetTemporaryPath("response", "txt"); + CurCommand->setResponseFile(C.addTempFile(C.getArgs().MakeArgString( + TmpName.c_str()))); +} + +int Driver::ExecuteCompilation(Compilation &C, + SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands) { // Just print if -### was present. if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) { C.getJobs().Print(llvm::errs(), "\n", true); @@ -588,6 +611,9 @@ int Driver::ExecuteCompilation(const Compilation &C, if (Diags.hasErrorOccurred()) return 1; + // Set up response file names for each command, if necessary + setUpResponseFiles(C, C.getJobs()); + C.ExecuteJob(C.getJobs(), FailingCommands); // Remove temp files. |