@@ -5740,6 +5740,7 @@ InputInfo Driver::BuildJobsForActionNoCache(
57405740
57415741 // Only use pipes when there is exactly one input.
57425742 InputInfoList InputInfos;
5743+ bool JobForPreprocessToStdout = false ;
57435744 for (const Action *Input : Inputs) {
57445745 // Treat dsymutil and verify sub-jobs as being at the top-level too, they
57455746 // shouldn't get temporary output names.
@@ -5750,6 +5751,11 @@ InputInfo Driver::BuildJobsForActionNoCache(
57505751 C, Input, TC, BoundArch, SubJobAtTopLevel, MultipleArchs, LinkingOutput,
57515752 CachedResults, A->getOffloadingDeviceKind ()));
57525753 }
5754+ // Check if we are in sub-work for preprocessing for host side. If so we will
5755+ // add another job to print information to terminal later.
5756+ if (!AtTopLevel && A->getKind () == Action::PreprocessJobClass &&
5757+ C.getJobs ().size () == 1 )
5758+ JobForPreprocessToStdout = true ;
57535759
57545760 // Always use the first input as the base input.
57555761 const char *BaseInput = InputInfos[0 ].getBaseInput ();
@@ -5784,6 +5790,7 @@ InputInfo Driver::BuildJobsForActionNoCache(
57845790
57855791 // Determine the place to write output to, if any.
57865792 InputInfo Result;
5793+ InputInfo ResultForPreprocessToStdout;
57875794 InputInfoList UnbundlingResults;
57885795 if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(JA)) {
57895796 // If we have an unbundling job, we need to create results for all the
@@ -5945,6 +5952,8 @@ InputInfo Driver::BuildJobsForActionNoCache(
59455952 AtTopLevel, MultipleArchs,
59465953 OffloadingPrefix),
59475954 BaseInput);
5955+ if (JobForPreprocessToStdout)
5956+ ResultForPreprocessToStdout = InputInfo (A, " -" , BaseInput);
59485957 }
59495958
59505959 if (CCCPrintBindings && !CCGenDiagnostics) {
@@ -5967,12 +5976,19 @@ InputInfo Driver::BuildJobsForActionNoCache(
59675976 llvm::errs () << " ] \n " ;
59685977 }
59695978 } else {
5970- if (UnbundlingResults.empty ())
5979+ if (UnbundlingResults.empty ()) {
59715980 T->ConstructJob (
59725981 C, *JA, Result, InputInfos,
59735982 C.getArgsForToolChain (TC, BoundArch, JA->getOffloadingDeviceKind ()),
59745983 LinkingOutput);
5975- else
5984+ // Add another job to print information to terminal for host side.
5985+ if (JobForPreprocessToStdout) {
5986+ T->ConstructJob (
5987+ C, *JA, ResultForPreprocessToStdout, InputInfos,
5988+ C.getArgsForToolChain (TC, BoundArch, JA->getOffloadingDeviceKind ()),
5989+ LinkingOutput);
5990+ }
5991+ } else
59765992 T->ConstructJobMultipleOutputs (
59775993 C, *JA, UnbundlingResults, InputInfos,
59785994 C.getArgsForToolChain (TC, BoundArch, JA->getOffloadingDeviceKind ()),
0 commit comments