@@ -1300,6 +1300,27 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1300
1300
OI.SelectedSanitizer );
1301
1301
}
1302
1302
1303
+ static void
1304
+ currentDependsOnPCHIfPresent (JobAction *PCH,
1305
+ std::unique_ptr<Action> &Current,
1306
+ ActionList &Actions) {
1307
+ if (PCH) {
1308
+ // FIXME: When we have a PCH job, it's officially owned by the Actions
1309
+ // array; but it's also a secondary input to each of the current
1310
+ // JobActions, which means that we need to flip the "owns inputs" bit
1311
+ // on the JobActions so they don't try to free it. That in turn means
1312
+ // we need to transfer ownership of all the JobActions' existing
1313
+ // inputs to the Actions array, since the JobActions either own or
1314
+ // don't own _all_ of their inputs. Ownership can't vary
1315
+ // input-by-input.
1316
+ auto *job = cast<JobAction>(Current.get ());
1317
+ auto inputs = job->getInputs ();
1318
+ Actions.append (inputs.begin (), inputs.end ());
1319
+ job->setOwnsInputs (false );
1320
+ job->addInput (PCH);
1321
+ }
1322
+ }
1323
+
1303
1324
void Driver::buildActions (const ToolChain &TC,
1304
1325
const DerivedArgList &Args,
1305
1326
const InputFileList &Inputs,
@@ -1364,30 +1385,17 @@ void Driver::buildActions(const ToolChain &TC,
1364
1385
Current.reset (new CompileJobAction (Current.release (),
1365
1386
types::TY_LLVM_BC,
1366
1387
previousBuildState));
1388
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1367
1389
AllModuleInputs.push_back (Current.get ());
1368
1390
Current.reset (new BackendJobAction (Current.release (),
1369
1391
OI.CompilerOutputType , 0 ));
1370
1392
} else {
1371
1393
Current.reset (new CompileJobAction (Current.release (),
1372
1394
OI.CompilerOutputType ,
1373
1395
previousBuildState));
1396
+ currentDependsOnPCHIfPresent (PCH, Current, Actions);
1374
1397
AllModuleInputs.push_back (Current.get ());
1375
1398
}
1376
- if (PCH) {
1377
- // FIXME: When we have a PCH job, it's officially owned by the Actions
1378
- // array; but it's also a secondary input to each of the current
1379
- // JobActions, which means that we need to flip the "owns inputs" bit
1380
- // on the JobActions so they don't try to free it. That in turn means
1381
- // we need to transfer ownership of all the JobActions' existing
1382
- // inputs to the Actions array, since the JobActions either own or
1383
- // don't own _all_ of their inputs. Ownership can't vary
1384
- // input-by-input.
1385
- auto *job = cast<JobAction>(Current.get ());
1386
- auto inputs = job->getInputs ();
1387
- Actions.append (inputs.begin (), inputs.end ());
1388
- job->setOwnsInputs (false );
1389
- job->addInput (PCH);
1390
- }
1391
1399
AllLinkerInputs.push_back (Current.release ());
1392
1400
break ;
1393
1401
}
0 commit comments