From b8cc54df0a7748e1af5b2f0acbf548c5bcab6f56 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 20 Oct 2024 22:55:00 +0200 Subject: [PATCH] libstore: return relevant store path in goal result we now do not need the goal pointers any more to process worker results. Change-Id: I1a021b862ca666bcd23fee9f38973e90e6f94a72 --- src/libstore/build/derivation-goal.cc | 8 ++++++-- src/libstore/build/entry-points.cc | 6 ++---- src/libstore/build/goal.hh | 3 +++ src/libstore/build/substitution-goal.cc | 9 ++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 5de159b2d..765df5f5a 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -127,11 +127,15 @@ Goal::WorkResult DerivationGoal::timedOut(Error && ex) kj::Promise> DerivationGoal::workImpl() noexcept { - return (useDerivation ? getDerivation() : haveDerivation()).attach(kj::defer([this] { + KJ_DEFER({ act.reset(); actLock.reset(); builderActivities.clear(); - })); + }); + + BOOST_OUTCOME_CO_TRY(auto result, co_await (useDerivation ? getDerivation() : haveDerivation())); + result.storePath = drvPath; + co_return result; } bool DerivationGoal::addWantedOutputs(const OutputsSpec & outputs) diff --git a/src/libstore/build/entry-points.cc b/src/libstore/build/entry-points.cc index 2e91b1778..13112d827 100644 --- a/src/libstore/build/entry-points.cc +++ b/src/libstore/build/entry-points.cc @@ -33,10 +33,8 @@ void Store::buildPaths(const std::vector & reqs, BuildMode buildMod ex = result.ex; } if (result.exitCode != Goal::ecSuccess) { - if (auto i2 = dynamic_cast(i.get())) - failed.insert(printStorePath(i2->drvPath)); - else if (auto i2 = dynamic_cast(i.get())) - failed.insert(printStorePath(i2->storePath)); + if (result.storePath) + failed.insert(printStorePath(*result.storePath)); } } diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh index 29540dcd3..5b66a2c08 100644 --- a/src/libstore/build/goal.hh +++ b/src/libstore/build/goal.hh @@ -94,6 +94,9 @@ public: bool timedOut = false; bool hashMismatch = false; bool checkMismatch = false; + /// Store path this goal relates to. Will be set to drvPath for + /// derivations, or the substituted store path for substitions. + std::optional storePath = {}; }; protected: diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc index e0ca23a86..2d0c594ac 100644 --- a/src/libstore/build/substitution-goal.cc +++ b/src/libstore/build/substitution-goal.cc @@ -3,6 +3,7 @@ #include "nar-info.hh" #include "signals.hh" #include "finally.hh" +#include #include #include @@ -54,7 +55,7 @@ try { /* If the path already exists we're done. */ if (!repair && worker.store.isValidPath(storePath)) { - return {done(ecSuccess, BuildResult::AlreadyValid)}; + co_return done(ecSuccess, BuildResult::AlreadyValid); } if (settings.readOnlyMode) @@ -62,9 +63,11 @@ try { subs = settings.useSubstitutes ? getDefaultSubstituters() : std::list>(); - return tryNext(); + BOOST_OUTCOME_CO_TRY(auto result, co_await tryNext()); + result.storePath = storePath; + co_return result; } catch (...) { - return {std::current_exception()}; + co_return result::failure(std::current_exception()); }