@@ -1340,6 +1340,27 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1340
1340
OI.SelectedSanitizer );
1341
1341
}
1342
1342
1343
+ static void
1344
+ currentDependsOnPCHIfPresent (JobAction *PCH,
1345
+ std::unique_ptr<Action> &Current,
1346
+ ActionList &Actions) {
1347
+ if (PCH) {
1348
+ // FIXME: When we have a PCH job, it's officially owned by the Actions
1349
+ // array; but it's also a secondary input to each of the current
1350
+ // JobActions, which means that we need to flip the "owns inputs" bit
1351
+ // on the JobActions so they don't try to free it. That in turn means
1352
+ // we need to transfer ownership of all the JobActions' existing
1353
+ // inputs to the Actions array, since the JobActions either own or
1354
+ // don't own _all_ of their inputs. Ownership can't vary
1355
+ // input-by-input.
1356
+ auto *job = cast<JobAction>(Current.get ());
1357
+ auto inputs = job->getInputs ();
1358
+ Actions.append (inputs.begin (), inputs.end ());
1359
+ job->setOwnsInputs (false );
1360
+ job->addInput (PCH);
1361
+ }
1362
+ }
1363
+
1343
1364
void Driver::buildActions (const ToolChain &TC,
1344
1365
const DerivedArgList &Args,
1345
1366
const InputFileList &Inputs,
@@ -1404,30 +1425,17 @@ void Driver::buildActions(const ToolChain &TC,
1404
1425
Current.reset (new CompileJobAction (Current.release (),
1405
1426
types::TY_LLVM_BC,
1406
1427
previousBuildState));
1428
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1407
1429
AllModuleInputs.push_back (Current.get ());
1408
1430
Current.reset (new BackendJobAction (Current.release (),
1409
1431
OI.CompilerOutputType , 0 ));
1410
1432
} else {
1411
1433
Current.reset (new CompileJobAction (Current.release (),
1412
1434
OI.CompilerOutputType ,
1413
1435
previousBuildState));
1436
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1414
1437
AllModuleInputs.push_back (Current.get ());
1415
1438
}
1416
- if (PCH) {
1417
- // FIXME: When we have a PCH job, it's officially owned by the Actions
1418
- // array; but it's also a secondary input to each of the current
1419
- // JobActions, which means that we need to flip the "owns inputs" bit
1420
- // on the JobActions so they don't try to free it. That in turn means
1421
- // we need to transfer ownership of all the JobActions' existing
1422
- // inputs to the Actions array, since the JobActions either own or
1423
- // don't own _all_ of their inputs. Ownership can't vary
1424
- // input-by-input.
1425
- auto *job = cast<JobAction>(Current.get ());
1426
- auto inputs = job->getInputs ();
1427
- Actions.append (inputs.begin (), inputs.end ());
1428
- job->setOwnsInputs (false );
1429
- job->addInput (PCH);
1430
- }
1431
1439
AllLinkerInputs.push_back (Current.release ());
1432
1440
break ;
1433
1441
}
0 commit comments