[llvm] [libLTO] add thinlto caching flags to libLTO (PR #168567)

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 11:03:29 PST 2025


================
@@ -543,6 +567,24 @@ thinlto_code_gen_t thinlto_create_codegen(void) {
     assert(CGOptLevelOrNone);
     CodeGen->setCodeGenOptLevel(*CGOptLevelOrNone);
   }
+  if (!ThinLTOCacheDir.empty()) {
+    auto Err = llvm::sys::fs::create_directories(ThinLTOCacheDir.getValue());
+    if (Err)
+      report_fatal_error(Twine("Unable to create thinLTO cache directory: ") +
+                         Err.message());
+    bool result;
+    Err = llvm::sys::fs::is_directory(ThinLTOCacheDir.getValue(), result);
+    if (Err || !result)
+      report_fatal_error(Twine("Unable to get status of thinLTO cache path or "
+                               "path is not a directory: ") +
+                         Err.message());
+    CodeGen->setCacheDir(ThinLTOCacheDir);
+  }
+  CodeGen->setCachePruningInterval(ThinLTOCachePruningInterval);
----------------
cachemeifyoucan wrote:

I do not like the unconditional setting here. That means we need to make sure the cl::opt initial value is the same as the one defined in the other files, otherwise it is a behavior change.

Is it reasonable to allow those overwrite when `ThinLTOCacheDir` is set via cl::opt only?

https://github.com/llvm/llvm-project/pull/168567


More information about the llvm-commits mailing list