@@ -116,19 +116,26 @@ void DerivationGoal::addWantedOutputs(const OutputsSpec & outputs)
116
116
wantedOutputs = newWanted;
117
117
}
118
118
119
+ static Goal::Co empty_co () {
120
+ co_return Goal::Return{};
121
+ }
119
122
120
123
Goal::Co DerivationGoal::init () {
121
124
trace (" init" );
122
125
126
+ Co gcc_bug_workaround{empty_co ()};
127
+
128
+ if (useDerivation && (buildMode != bmNormal || !worker.evalStore .isValidPath (drvPath))) {
129
+ gcc_bug_workaround = await ({upcast_goal (worker.makePathSubstitutionGoal (drvPath))});
130
+ }
131
+
132
+ co_await std::move (gcc_bug_workaround);
133
+
123
134
if (useDerivation) {
124
135
/* The first thing to do is to make sure that the derivation
125
136
exists. If it doesn't, it may be created through a
126
137
substitute. */
127
138
128
- if (buildMode != bmNormal || !worker.evalStore .isValidPath (drvPath)) {
129
- co_await await ({upcast_goal (worker.makePathSubstitutionGoal (drvPath))});
130
- }
131
-
132
139
trace (" loading derivation" );
133
140
134
141
if (nrFailed != 0 ) {
@@ -410,6 +417,9 @@ Goal::Co DerivationGoal::gaveUpOnSubstitution()
410
417
411
418
/* Determine the full set of input paths. */
412
419
420
+ // needed because of GCC bug
421
+ std::optional<std::pair<Co, Co>> gcc_bug_workaround{};
422
+
413
423
/* First, the input derivations. */
414
424
if (useDerivation) {
415
425
auto & fullDrv = *dynamic_cast <Derivation *>(drv.get ());
@@ -483,14 +493,10 @@ Goal::Co DerivationGoal::gaveUpOnSubstitution()
483
493
484
494
resolvedDrvGoal = worker.makeDerivationGoal (
485
495
pathResolved, wantedOutputs, buildMode);
486
- co_await await ({resolvedDrvGoal});
487
496
488
- co_return resolvedFinished ();
489
- }
490
-
491
- /* If we get this far, we know no dynamic drvs inputs */
492
-
493
- for (auto & [depDrvPath, depNode] : fullDrv.inputDrvs .map ) {
497
+ gcc_bug_workaround = {await ({resolvedDrvGoal}), resolvedFinished ()};
498
+ } else for (auto & [depDrvPath, depNode] : fullDrv.inputDrvs .map ) {
499
+ /* If we get this far, we know no dynamic drvs inputs */
494
500
for (auto & outputName : depNode.value ) {
495
501
/* Don't need to worry about `inputGoals`, because
496
502
impure derivations are always resolved above. Can
@@ -515,19 +521,27 @@ Goal::Co DerivationGoal::gaveUpOnSubstitution()
515
521
}
516
522
}
517
523
518
- /* Second, the input sources. */
519
- worker.store .computeFSClosure (drv->inputSrcs , inputPaths);
524
+ bool has_resolved_drv_goal = gcc_bug_workaround.has_value ();
525
+
526
+ if (!gcc_bug_workaround) {
527
+ gcc_bug_workaround = {yield (), tryToBuild ()};
528
+ }
529
+
530
+ if (!has_resolved_drv_goal) {
531
+ /* Second, the input sources. */
532
+ worker.store .computeFSClosure (drv->inputSrcs , inputPaths);
520
533
521
- debug (" added input paths %s" , worker.store .showPaths (inputPaths));
534
+ debug (" added input paths %s" , worker.store .showPaths (inputPaths));
522
535
523
- /* What type of derivation are we building? */
524
- derivationType = drv->type ();
536
+ /* What type of derivation are we building? */
537
+ derivationType = drv->type ();
538
+ }
525
539
526
540
/* Okay, try to build. Note that here we don't wait for a build
527
541
slot to become available, since we don't need one if there is a
528
542
build hook. */
529
- co_await yield ( );
530
- co_return tryToBuild ( );
543
+ co_await std::move (gcc_bug_workaround-> first );
544
+ co_return std::move (gcc_bug_workaround-> second );
531
545
}
532
546
533
547
void DerivationGoal::started ()
0 commit comments