From f63d3df866a2d75b694c8c484b21fbcdccd58acd Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 6 Jun 2024 16:07:51 +0200 Subject: tc cache: abort writing if a dependent target is not available After successful build of an export target target a cache entry is written. As those export targets have a dependency structure, care is taken to write them in correct order. Writing a cache entry for an export target requires knowledge of the analysis result of that target. Originally, all targets used to be analysed locally, so that information was available for every target that was not read from the local target cache already. However, with the introduction of serve endpoints, it can happen that a target was analyzed locally, but it depends on targets obtained from serve. In this case, we have to refrain from writing a target-level cache entry to keep the the consistency invariants of the target-level cache. --- src/buildtool/main/build_utils.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/buildtool/main/build_utils.cpp') diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp index 5b8d142d..b29ff0c5 100644 --- a/src/buildtool/main/build_utils.cpp +++ b/src/buildtool/main/build_utils.cpp @@ -83,8 +83,15 @@ auto CreateTargetCacheWriterMap( TargetCacheKey tc_key{key}; // check if entry actually needs storing if (not cache_targets.contains(tc_key)) { - // entry already in target-cache, so nothing to be done - (*setter)(nullptr); + if (tc.Read(tc_key)) { + // entry already in target-cache, so nothing to be done + (*setter)(nullptr); + return; + } + (*logger)(fmt::format("Export target {} not analysed locally; " + "not caching anything depending on it", + key.ToString()), + true); return; } auto const& target = cache_targets.at(tc_key); -- cgit v1.2.3