Skip to content

Commit a321a98

Browse files
authored
Merge pull request #9867 from akyrtzi/akyrtzi/pr/stable-remote-thinlto-fix
[ThinLTO][Cache] When remote caching is enabled, use the passed-in thin-LTO cache as temp directory
2 parents 8370b43 + b2273ed commit a321a98

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ class ThinLTOCodeGenerator {
235235
/// the processing.
236236
void setSaveTempsDir(std::string Path) { SaveTempsDir = std::move(Path); }
237237

238+
/// Set the path to a directory where to save temporaries from the remote
239+
/// service.
240+
void setRemoteServiceTempsDir(std::string Path) {
241+
RemoteServiceTempsDir = std::move(Path);
242+
}
243+
238244
/// Set the path to a directory where to save generated object files. This
239245
/// path can be used by a linker to request on-disk files instead of in-memory
240246
/// buffers. When set, results are available through getProducedBinaryFiles()
@@ -376,6 +382,9 @@ class ThinLTOCodeGenerator {
376382
/// Path to a directory to save the temporary bitcode files.
377383
std::string SaveTempsDir;
378384

385+
/// Path to a directory to save the temporary remote service files.
386+
std::string RemoteServiceTempsDir;
387+
379388
/// Path to a directory to save the generated object files.
380389
std::string SavedObjectsDirectoryPath;
381390

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,8 @@ void ThinLTOCodeGenerator::run() {
15881588
// First, we need to remember whether the caller requests buffer API or file
15891589
// API based on if the SavedObjectsDirectoryPath was set or not.
15901590
bool UseBufferAPI = SavedObjectsDirectoryPath.empty();
1591+
if (SavedObjectsDirectoryPath.empty())
1592+
SavedObjectsDirectoryPath = RemoteServiceTempsDir;
15911593
std::string TempDirectory;
15921594
if (CacheOptions.Type == CachingOptions::CacheType::RemoteService &&
15931595
SavedObjectsDirectoryPath.empty()) {

llvm/tools/lto/lto.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu) {
619619

620620
void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg,
621621
const char *cache_dir) {
622+
if (sys::Process::GetEnv("LLVM_THINLTO_USE_REMOTE_CACHE")) {
623+
unwrap(cg)->setRemoteServiceTempsDir(cache_dir);
624+
return;
625+
}
622626
// FIXME: need to return error somehow.
623627
Error Err = unwrap(cg)->setCacheDir(cache_dir);
624628
if (Err)

0 commit comments

Comments
 (0)