about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/compiler/patches/llvm-module-cache.patch
blob: 9a22d0482ea5c26b464733f742d3f74439a0cd78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
The compiler fails if LLVM modules are enabled and it cannot write its module
cache. This patch detects and rejects the fake, non-existant $HOME used in Nix
builds.

We could simply return false in `cache_directory`, but that completely disables
module caching, and may unnecessarily slow down builds. Instead, let it use
'/tmp/.cache'.

--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -1380,6 +1380,9 @@ bool user_config_directory(SmallVectorImpl<char> &result) {
   if (!home_directory(result)) {
     return false;
   }
+  if (std::equal(result.begin(), result.end(), "/homeless-shelter")) {
+    return false;
+  }
   append(result, ".config");
   return true;
 }
@@ -1401,6 +1404,9 @@ bool cache_directory(SmallVectorImpl<char> &result) {
   if (!home_directory(result)) {
     return false;
   }
+  if (std::equal(result.begin(), result.end(), "/homeless-shelter")) {
+    system_temp_directory(true/*ErasedOnReboot*/, result);
+  }
   append(result, ".cache");
   return true;
 }