Skip to content

Commit 4b6edfc

Browse files
committed
DerivationBuildingGoal: Check outputs beforehand
See the comment in the code for details. Some of the code is duplicated for now, but we'll be cleaning that up soon.
1 parent cf7084a commit 4b6edfc

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/libstore/build/derivation-building-goal.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,33 @@ std::string showKnownOutputs(Store & store, const Derivation & drv)
151151
produced using a substitute. So we have to build instead. */
152152
Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
153153
{
154+
/* Recheck at goal start. In particular, whereas before we were
155+
given this information by the downstream goal, that cannot happen
156+
anymore if the downstream goal only cares about one output, but
157+
we care about all outputs. */
158+
auto outputHashes = staticOutputHashes(worker.evalStore, *drv);
159+
for (auto & [outputName, outputHash] : outputHashes) {
160+
InitialOutput v{
161+
.wanted = true, // Will be refined later
162+
.outputHash = outputHash};
163+
164+
/* TODO we might want to also allow randomizing the paths
165+
for regular CA derivations, e.g. for sake of checking
166+
determinism. */
167+
if (drv->type().isImpure()) {
168+
v.known = InitialOutputStatus{
169+
.path = StorePath::random(outputPathName(drv->name, outputName)),
170+
.status = PathStatus::Absent,
171+
};
172+
}
173+
174+
initialOutputs.insert({
175+
outputName,
176+
std::move(v),
177+
});
178+
}
179+
checkPathValidity();
180+
154181
Goals waitees;
155182

156183
std::map<ref<const SingleDerivedPath>, GoalPtr, value_comparison> inputGoals;

src/libstore/build/derivation-goal.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ Goal::Co DerivationGoal::haveDerivation()
8282
/* We will finish with it ourselves, as if we were the derivational goal. */
8383
g->preserveException = true;
8484

85-
// TODO move into constructor
86-
g->initialOutputs = initialOutputs;
87-
8885
{
8986
Goals waitees;
9087
waitees.insert(g);

0 commit comments

Comments
 (0)