File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -325,8 +325,30 @@ Error SwiftCASOutputBackend::Implementation::finalizeCacheKeysFor(
325
325
<< CAS.getID (*CacheKey).toString () << " \' => \' "
326
326
<< CAS.getID (*Result).toString () << " \'\n " ;);
327
327
328
- if (auto E = Cache.put (CAS.getID (*CacheKey), CAS.getID (*Result)))
329
- return E;
328
+ if (auto E = Cache.put (CAS.getID (*CacheKey), CAS.getID (*Result))) {
329
+ // If `SWIFT_STRICT_CAS_ERRORS` environment is set, do not attempt to
330
+ // recover from error.
331
+ if (::getenv (" SWIFT_STRICT_CAS_ERRORS" ))
332
+ return E;
333
+ // Failed to update the action cache, this can happen when there is a
334
+ // non-deterministic output from compiler. Check that the cache entry is
335
+ // not missing, if so, then assume this is a cache poisoning that might
336
+ // be benign and the build might continue without problem.
337
+ auto Check = Cache.get (CAS.getID (*CacheKey));
338
+ if (!Check) {
339
+ // A real CAS error, return the original error.
340
+ consumeError (Check.takeError ());
341
+ return E;
342
+ }
343
+ if (!*Check)
344
+ return E;
345
+ // Emit an error message to stderr but don't fail the job. Ideally this
346
+ // should be sent to a DiagnosticEngine but CASBackend lives longer than
347
+ // diagnostic engine and needs to capture all diagnostic outputs before
348
+ // sending this request.
349
+ llvm::errs () << " error: failed to update cache: " << toString (std::move (E))
350
+ << " \n " ;
351
+ }
330
352
331
353
return Error::success ();
332
354
}
You can’t perform that action at this time.
0 commit comments