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

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 03:51:23 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);
----------------
w2yehia wrote:

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

yes. done

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


More information about the llvm-commits mailing list