aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/derivation-goal.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-10-01 23:29:45 -0400
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2023-10-02 15:05:23 +0000
commit72b65981f9590db06558958179bef4dcf733777a (patch)
tree7ac9ce29716f721b28a0a286023bb87c215c9f77 /src/libstore/build/derivation-goal.cc
parent7e2399b12360d267af8dac033c3d0d95a00b874d (diff)
Revert "Adapt scheduler to work with dynamic derivations"
This reverts commit 5e3986f59cb58f48186a49dcec7aa317b4787522. This un-implements RFC 92 but fixes the critical bug #9052 which many people are hitting. This is a decent stop-gap until a minimal reproduction of that bug is found and a proper fix can be made. Mostly fixed #9052, but I would like to leave that issue open until we have a regression test, so I can then properly fix the bug (unbreaking RFC 92) later. (cherry picked from commit 8440afbed756254784d9fea3eaab06649dffd390)
Diffstat (limited to 'src/libstore/build/derivation-goal.cc')
-rw-r--r--src/libstore/build/derivation-goal.cc33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index 6472ecd99..83c0a3135 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -71,7 +71,7 @@ DerivationGoal::DerivationGoal(const StorePath & drvPath,
, wantedOutputs(wantedOutputs)
, buildMode(buildMode)
{
- state = &DerivationGoal::loadDerivation;
+ state = &DerivationGoal::getDerivation;
name = fmt(
"building of '%s' from .drv file",
DerivedPath::Built { makeConstantStorePathRef(drvPath), wantedOutputs }.to_string(worker.store));
@@ -164,6 +164,24 @@ void DerivationGoal::addWantedOutputs(const OutputsSpec & outputs)
}
+void DerivationGoal::getDerivation()
+{
+ trace("init");
+
+ /* The first thing to do is to make sure that the derivation
+ exists. If it doesn't, it may be created through a
+ substitute. */
+ if (buildMode == bmNormal && worker.evalStore.isValidPath(drvPath)) {
+ loadDerivation();
+ return;
+ }
+
+ addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath)));
+
+ state = &DerivationGoal::loadDerivation;
+}
+
+
void DerivationGoal::loadDerivation()
{
trace("loading derivation");
@@ -1498,24 +1516,23 @@ void DerivationGoal::waiteeDone(GoalPtr waitee, ExitCode result)
if (!useDerivation) return;
auto & fullDrv = *dynamic_cast<Derivation *>(drv.get());
- std::optional info = tryGetConcreteDrvGoal(waitee);
- if (!info) return;
- const auto & [dg, drvReq] = *info;
+ auto * dg = dynamic_cast<DerivationGoal *>(&*waitee);
+ if (!dg) return;
- auto * nodeP = fullDrv.inputDrvs.findSlot(drvReq.get());
+ auto * nodeP = fullDrv.inputDrvs.findSlot(DerivedPath::Opaque { .path = dg->drvPath });
if (!nodeP) return;
auto & outputs = nodeP->value;
for (auto & outputName : outputs) {
- auto buildResult = dg.get().getBuildResult(DerivedPath::Built {
- .drvPath = makeConstantStorePathRef(dg.get().drvPath),
+ auto buildResult = dg->getBuildResult(DerivedPath::Built {
+ .drvPath = makeConstantStorePathRef(dg->drvPath),
.outputs = OutputsSpec::Names { outputName },
});
if (buildResult.success()) {
auto i = buildResult.builtOutputs.find(outputName);
if (i != buildResult.builtOutputs.end())
inputDrvOutputs.insert_or_assign(
- { dg.get().drvPath, outputName },
+ { dg->drvPath, outputName },
i->second.outPath);
}
}