diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-09-21 19:12:05 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-09-21 19:12:05 +0000 |
commit | 3f212b890862d08ff8b4fb751fb7719ac00965a3 (patch) | |
tree | 14225bc30d8658bc3110bb5cd3bdefb07620f830 /llvm/lib/LTO/LTO.cpp | |
parent | e746e52c7b783757feec0c0c53746475f274c7f0 (diff) | |
download | bcm5719-llvm-3f212b890862d08ff8b4fb751fb7719ac00965a3.tar.gz bcm5719-llvm-3f212b890862d08ff8b4fb751fb7719ac00965a3.zip |
[ThinLTO] Emit files for distributed builds for all modules
With the new LTO API in r278338, we stopped emitting the individual
index files and imports files for some modules in the distributed backend
case (thinlto-index-only plugin option).
Specifically, this is when the linker decides not to include a module in the
link, because it was in an archive library and did not have a strong
reference to it. Not creating the expected output files makes the
distributed build system implementation more difficult, in terms of
checking for the expected outputs of the thin link, and scheduling the
backend jobs. To address this, the gold-plugin will write dummy empty
.thinlto.bc and .imports files for modules not included in the link
(which LTO never sees).
Augmented a gold v1.12+ test, since that version of gold has the handling
for notifying on modules not being included in the link.
llvm-svn: 282100
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 017a45ac7ba..b2f0be2b5e8 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -609,6 +609,26 @@ ThinBackend lto::createInProcessThinBackend(unsigned ParallelismLevel) { }; } +// Given the original \p Path to an output file, replace any path +// prefix matching \p OldPrefix with \p NewPrefix. Also, create the +// resulting directory if it does not yet exist. +std::string lto::getThinLTOOutputFile(const std::string &Path, + const std::string &OldPrefix, + const std::string &NewPrefix) { + if (OldPrefix.empty() && NewPrefix.empty()) + return Path; + SmallString<128> NewPath(Path); + llvm::sys::path::replace_path_prefix(NewPath, OldPrefix, NewPrefix); + StringRef ParentPath = llvm::sys::path::parent_path(NewPath.str()); + if (!ParentPath.empty()) { + // Make sure the new directory exists, creating it if necessary. + if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath)) + llvm::errs() << "warning: could not create directory '" << ParentPath + << "': " << EC.message() << '\n'; + } + return NewPath.str(); +} + class WriteIndexesThinBackend : public ThinBackendProc { std::string OldPrefix, NewPrefix; bool ShouldEmitImportsFiles; @@ -627,26 +647,6 @@ public: ShouldEmitImportsFiles(ShouldEmitImportsFiles), LinkedObjectsFileName(LinkedObjectsFileName) {} - /// Given the original \p Path to an output file, replace any path - /// prefix matching \p OldPrefix with \p NewPrefix. Also, create the - /// resulting directory if it does not yet exist. - std::string getThinLTOOutputFile(const std::string &Path, - const std::string &OldPrefix, - const std::string &NewPrefix) { - if (OldPrefix.empty() && NewPrefix.empty()) - return Path; - SmallString<128> NewPath(Path); - llvm::sys::path::replace_path_prefix(NewPath, OldPrefix, NewPrefix); - StringRef ParentPath = llvm::sys::path::parent_path(NewPath.str()); - if (!ParentPath.empty()) { - // Make sure the new directory exists, creating it if necessary. - if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath)) - llvm::errs() << "warning: could not create directory '" << ParentPath - << "': " << EC.message() << '\n'; - } - return NewPath.str(); - } - Error start( unsigned Task, MemoryBufferRef MBRef, const FunctionImporter::ImportMapTy &ImportList, |