1The compiler fails if LLVM modules are enabled and it cannot write its module
2cache. This patch detects and rejects the fake, non-existant $HOME used in Nix
3builds.
4
5We could simply return false in `cache_directory`, but that completely disables
6module caching, and may unnecessarily slow down builds. Instead, let it use
7'/tmp/.cache'.
8
9--- a/lib/Support/Unix/Path.inc
10+++ b/lib/Support/Unix/Path.inc
11@@ -1380,6 +1380,9 @@ bool user_config_directory(SmallVectorImpl<char> &result) {
12 if (!home_directory(result)) {
13 return false;
14 }
15+ if (std::equal(result.begin(), result.end(), "/homeless-shelter")) {
16+ return false;
17+ }
18 append(result, ".config");
19 return true;
20 }
21@@ -1401,6 +1404,9 @@ bool cache_directory(SmallVectorImpl<char> &result) {
22 if (!home_directory(result)) {
23 return false;
24 }
25+ if (std::equal(result.begin(), result.end(), "/homeless-shelter")) {
26+ system_temp_directory(true/*ErasedOnReboot*/, result);
27+ }
28 append(result, ".cache");
29 return true;
30 }