@@ -1311,6 +1311,27 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1311
1311
OI.SelectedSanitizer );
1312
1312
}
1313
1313
1314
+ static void
1315
+ currentDependsOnPCHIfPresent (JobAction *PCH,
1316
+ std::unique_ptr<Action> &Current,
1317
+ ActionList &Actions) {
1318
+ if (PCH) {
1319
+ // FIXME: When we have a PCH job, it's officially owned by the Actions
1320
+ // array; but it's also a secondary input to each of the current
1321
+ // JobActions, which means that we need to flip the "owns inputs" bit
1322
+ // on the JobActions so they don't try to free it. That in turn means
1323
+ // we need to transfer ownership of all the JobActions' existing
1324
+ // inputs to the Actions array, since the JobActions either own or
1325
+ // don't own _all_ of their inputs. Ownership can't vary
1326
+ // input-by-input.
1327
+ auto *job = cast<JobAction>(Current.get ());
1328
+ auto inputs = job->getInputs ();
1329
+ Actions.append (inputs.begin (), inputs.end ());
1330
+ job->setOwnsInputs (false );
1331
+ job->addInput (PCH);
1332
+ }
1333
+ }
1334
+
1314
1335
void Driver::buildActions (const ToolChain &TC,
1315
1336
const DerivedArgList &Args,
1316
1337
const InputFileList &Inputs,
@@ -1375,30 +1396,17 @@ void Driver::buildActions(const ToolChain &TC,
1375
1396
Current.reset (new CompileJobAction (Current.release (),
1376
1397
types::TY_LLVM_BC,
1377
1398
previousBuildState));
1399
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1378
1400
AllModuleInputs.push_back (Current.get ());
1379
1401
Current.reset (new BackendJobAction (Current.release (),
1380
1402
OI.CompilerOutputType , 0 ));
1381
1403
} else {
1382
1404
Current.reset (new CompileJobAction (Current.release (),
1383
1405
OI.CompilerOutputType ,
1384
1406
previousBuildState));
1407
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1385
1408
AllModuleInputs.push_back (Current.get ());
1386
1409
}
1387
- if (PCH) {
1388
- // FIXME: When we have a PCH job, it's officially owned by the Actions
1389
- // array; but it's also a secondary input to each of the current
1390
- // JobActions, which means that we need to flip the "owns inputs" bit
1391
- // on the JobActions so they don't try to free it. That in turn means
1392
- // we need to transfer ownership of all the JobActions' existing
1393
- // inputs to the Actions array, since the JobActions either own or
1394
- // don't own _all_ of their inputs. Ownership can't vary
1395
- // input-by-input.
1396
- auto *job = cast<JobAction>(Current.get ());
1397
- auto inputs = job->getInputs ();
1398
- Actions.append (inputs.begin (), inputs.end ());
1399
- job->setOwnsInputs (false );
1400
- job->addInput (PCH);
1401
- }
1402
1410
AllLinkerInputs.push_back (Current.release ());
1403
1411
break ;
1404
1412
}
0 commit comments