[PATCH] D126678: [clang] Allow CLANG_MODULE_CACHE_PATH env var to override module caching behavior

Alex Brachet via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 09:56:24 PDT 2022


This revision was automatically updated to reflect the committed changes.
abrachet marked an inline comment as done.
Closed by commit rGfac39d14b129: [clang] Allow CLANG_MODULE_CACHE_PATH env var to override module caching… (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126678/new/

https://reviews.llvm.org/D126678

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules-cache-path.m


Index: clang/test/Driver/modules-cache-path.m
===================================================================
--- clang/test/Driver/modules-cache-path.m
+++ clang/test/Driver/modules-cache-path.m
@@ -1,2 +1,10 @@
 // RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEFAULT
 // CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
+
+// RUN: env CLANG_MODULE_CACHE_PATH=/dev/null \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=OVERRIDE
+// OVERRIDE: -fmodules-cache-path=/dev/null
+
+// RUN: env CLANG_MODULE_CACHE_PATH= \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=DISABLE
+// DISABLE-NOT: -fmodules-cache-path=
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3600,6 +3600,11 @@
 }
 
 bool Driver::getDefaultModuleCachePath(SmallVectorImpl<char> &Result) {
+  if (const char *Str = std::getenv("CLANG_MODULE_CACHE_PATH")) {
+    Twine Path{Str};
+    Path.toVector(Result);
+    return Path.getSingleStringRef() != "";
+  }
   if (llvm::sys::path::cache_directory(Result)) {
     llvm::sys::path::append(Result, "clang");
     llvm::sys::path::append(Result, "ModuleCache");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126678.435598.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220609/9b099ce8/attachment.bin>


More information about the cfe-commits mailing list