@@ -1329,6 +1329,27 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1329
1329
OI.SelectedSanitizer );
1330
1330
}
1331
1331
1332
+ static void
1333
+ currentDependsOnPCHIfPresent (JobAction *PCH,
1334
+ std::unique_ptr<Action> &Current,
1335
+ ActionList &Actions) {
1336
+ if (PCH) {
1337
+ // FIXME: When we have a PCH job, it's officially owned by the Actions
1338
+ // array; but it's also a secondary input to each of the current
1339
+ // JobActions, which means that we need to flip the "owns inputs" bit
1340
+ // on the JobActions so they don't try to free it. That in turn means
1341
+ // we need to transfer ownership of all the JobActions' existing
1342
+ // inputs to the Actions array, since the JobActions either own or
1343
+ // don't own _all_ of their inputs. Ownership can't vary
1344
+ // input-by-input.
1345
+ auto *job = cast<JobAction>(Current.get ());
1346
+ auto inputs = job->getInputs ();
1347
+ Actions.append (inputs.begin (), inputs.end ());
1348
+ job->setOwnsInputs (false );
1349
+ job->addInput (PCH);
1350
+ }
1351
+ }
1352
+
1332
1353
void Driver::buildActions (const ToolChain &TC,
1333
1354
const DerivedArgList &Args,
1334
1355
const InputFileList &Inputs,
@@ -1393,30 +1414,17 @@ void Driver::buildActions(const ToolChain &TC,
1393
1414
Current.reset (new CompileJobAction (Current.release (),
1394
1415
types::TY_LLVM_BC,
1395
1416
previousBuildState));
1417
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1396
1418
AllModuleInputs.push_back (Current.get ());
1397
1419
Current.reset (new BackendJobAction (Current.release (),
1398
1420
OI.CompilerOutputType , 0 ));
1399
1421
} else {
1400
1422
Current.reset (new CompileJobAction (Current.release (),
1401
1423
OI.CompilerOutputType ,
1402
1424
previousBuildState));
1425
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1403
1426
AllModuleInputs.push_back (Current.get ());
1404
1427
}
1405
- if (PCH) {
1406
- // FIXME: When we have a PCH job, it's officially owned by the Actions
1407
- // array; but it's also a secondary input to each of the current
1408
- // JobActions, which means that we need to flip the "owns inputs" bit
1409
- // on the JobActions so they don't try to free it. That in turn means
1410
- // we need to transfer ownership of all the JobActions' existing
1411
- // inputs to the Actions array, since the JobActions either own or
1412
- // don't own _all_ of their inputs. Ownership can't vary
1413
- // input-by-input.
1414
- auto *job = cast<JobAction>(Current.get ());
1415
- auto inputs = job->getInputs ();
1416
- Actions.append (inputs.begin (), inputs.end ());
1417
- job->setOwnsInputs (false );
1418
- job->addInput (PCH);
1419
- }
1420
1428
AllLinkerInputs.push_back (Current.release ());
1421
1429
break ;
1422
1430
}
0 commit comments