@@ -586,12 +586,15 @@ computePrebuiltModulesASTMap(CompilerInstance &ScanInstance,
586586}
587587
588588std::unique_ptr<DependencyOutputOptions>
589- getDependencyOutputOptions (CompilerInstance &ScanInstance) {
589+ takeDependencyOutputOptionsFrom (CompilerInstance &ScanInstance) {
590590 // This function moves the existing dependency output options from the
591591 // invocation to the collector. The options in the invocation are reset,
592592 // which ensures that the compiler won't create new dependency collectors,
593593 // and thus won't write out the extra '.d' files to disk.
594594 auto Opts = std::make_unique<DependencyOutputOptions>();
595+
596+ // We need at least one -MT equivalent for the generator of make dependency
597+ // files to work.
595598 std::swap (*Opts, ScanInstance.getInvocation ().getDependencyOutputOpts ());
596599 if (Opts->Targets .empty ())
597600 Opts->Targets = {deduceDepTarget (ScanInstance.getFrontendOpts ().OutputFile ,
@@ -603,29 +606,24 @@ getDependencyOutputOptions(CompilerInstance &ScanInstance) {
603606
604607std::shared_ptr<ModuleDepCollector> initializeScanInstanceDependencyCollector (
605608 CompilerInstance &ScanInstance,
606- const DependencyOutputOptions &DepOutputOpts, StringRef WorkingDirectory,
607- DependencyConsumer &Consumer, DependencyScanningService &Service,
608- CompilerInvocation &Inv, DependencyActionController &Controller,
609+ std::unique_ptr<DependencyOutputOptions> DepOutputOpts,
610+ StringRef WorkingDirectory, DependencyConsumer &Consumer,
611+ DependencyScanningService &Service, CompilerInvocation &Inv,
612+ DependencyActionController &Controller,
609613 PrebuiltModulesAttrsMap PrebuiltModulesASTMap,
610614 llvm::SmallVector<StringRef> &StableDirs) {
611- // Create the dependency collector that will collect the produced
612- // dependencies. May return the created ModuleDepCollector depending
613- // on the scanning format.
614-
615- auto Opts = std::make_unique<DependencyOutputOptions>(DepOutputOpts);
616-
617615 std::shared_ptr<ModuleDepCollector> MDC;
618616 switch (Service.getFormat ()) {
619617 case ScanningOutputFormat::Make:
620618 ScanInstance.addDependencyCollector (
621619 std::make_shared<DependencyConsumerForwarder>(
622- std::move (Opts ), WorkingDirectory, Consumer));
620+ std::move (DepOutputOpts ), WorkingDirectory, Consumer));
623621 break ;
624622 case ScanningOutputFormat::P1689:
625623 case ScanningOutputFormat::Full:
626624 MDC = std::make_shared<ModuleDepCollector>(
627- Service, std::move (Opts ), ScanInstance, Consumer, Controller, Inv ,
628- std::move (PrebuiltModulesASTMap), StableDirs);
625+ Service, std::move (DepOutputOpts ), ScanInstance, Consumer, Controller,
626+ Inv, std::move (PrebuiltModulesASTMap), StableDirs);
629627 ScanInstance.addDependencyCollector (MDC);
630628 break ;
631629 }
@@ -676,11 +674,12 @@ bool DependencyScanningAction::runInvocation(
676674 if (!MaybePrebuiltModulesASTMap)
677675 return false ;
678676
679- auto DepOutputOpts = getDependencyOutputOptions (ScanInstance);
677+ auto DepOutputOpts = takeDependencyOutputOptionsFrom (ScanInstance);
680678
681679 MDC = initializeScanInstanceDependencyCollector (
682- ScanInstance, *DepOutputOpts, WorkingDirectory, Consumer, Service,
683- OriginalInvocation, Controller, *MaybePrebuiltModulesASTMap, StableDirs);
680+ ScanInstance, std::move (DepOutputOpts), WorkingDirectory, Consumer,
681+ Service, OriginalInvocation, Controller, *MaybePrebuiltModulesASTMap,
682+ StableDirs);
684683
685684 std::unique_ptr<FrontendAction> Action;
686685
0 commit comments