]> granicus.if.org Git - clang/commitdiff
Add the hostname to the module hash to avoid sharing between hosts
authorBen Langmuir <blangmuir@apple.com>
Mon, 9 Feb 2015 19:23:08 +0000 (19:23 +0000)
committerBen Langmuir <blangmuir@apple.com>
Mon, 9 Feb 2015 19:23:08 +0000 (19:23 +0000)
Sharing between hosts will cause problems for the LockFileManager, which
can timeout waiting for a process that has already died.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228592 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CompilerInvocation.cpp

index f8d71acd32942689687003ddd6dfb1280aaa92b3..eef0535265f402f8c44ceb8b50ab94583d286f45 100644 (file)
@@ -2021,6 +2021,16 @@ std::string CompilerInvocation::getModuleHash() const {
     }
   }
 
+#if LLVM_ON_UNIX
+  // The LockFileManager cannot tell when processes from another host are
+  // running, so mangle the hostname in to the module hash to separate them.
+  char hostname[256];
+  hostname[255] = 0;
+  hostname[0] = 0;
+  gethostname(hostname, 255);
+  code = hash_combine(code, StringRef(hostname));
+#endif
+
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }