summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-06 16:07:51 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-09-09 12:39:00 +0200
commita2204a921218e35ae29936561a5d3726cfbfa0e1 (patch)
tree3dc9d41c049570fb01e018e45a89d0a06c3c23b0
parent4ae3c2c6d2ea8e3da6f208e631068ebf284dfd44 (diff)
downloadjustbuild-a2204a921218e35ae29936561a5d3726cfbfa0e1.tar.gz
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. (cherry-picked from f63d3df866a2d75b694c8c484b21fbcdccd58acd)
-rw-r--r--src/buildtool/main/build_utils.cpp11
1 files changed, 9 insertions, 2 deletions
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);