Skip to content

[ThinLTO][Cache] When remote caching is enabled, use the passed-in thin-LTO cache as temp directory #9867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ class ThinLTOCodeGenerator {
/// the processing.
void setSaveTempsDir(std::string Path) { SaveTempsDir = std::move(Path); }

/// Set the path to a directory where to save temporaries from the remote
/// service.
void setRemoteServiceTempsDir(std::string Path) {
RemoteServiceTempsDir = std::move(Path);
}

/// Set the path to a directory where to save generated object files. This
/// path can be used by a linker to request on-disk files instead of in-memory
/// buffers. When set, results are available through getProducedBinaryFiles()
Expand Down Expand Up @@ -376,6 +382,9 @@ class ThinLTOCodeGenerator {
/// Path to a directory to save the temporary bitcode files.
std::string SaveTempsDir;

/// Path to a directory to save the temporary remote service files.
std::string RemoteServiceTempsDir;

/// Path to a directory to save the generated object files.
std::string SavedObjectsDirectoryPath;

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,8 @@ void ThinLTOCodeGenerator::run() {
// First, we need to remember whether the caller requests buffer API or file
// API based on if the SavedObjectsDirectoryPath was set or not.
bool UseBufferAPI = SavedObjectsDirectoryPath.empty();
if (SavedObjectsDirectoryPath.empty())
SavedObjectsDirectoryPath = RemoteServiceTempsDir;
std::string TempDirectory;
if (CacheOptions.Type == CachingOptions::CacheType::RemoteService &&
SavedObjectsDirectoryPath.empty()) {
Expand Down
4 changes: 4 additions & 0 deletions llvm/tools/lto/lto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu) {

void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg,
const char *cache_dir) {
if (sys::Process::GetEnv("LLVM_THINLTO_USE_REMOTE_CACHE")) {
unwrap(cg)->setRemoteServiceTempsDir(cache_dir);
return;
}
// FIXME: need to return error somehow.
Error Err = unwrap(cg)->setCacheDir(cache_dir);
if (Err)
Expand Down