diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -817,9 +817,11 @@ /// Returns the path to the generated file in SavedObjectsDirectoryPath. static std::string writeGeneratedObject(int count, StringRef CacheEntryPath, StringRef SavedObjectsDirectoryPath, - const MemoryBuffer &OutputBuffer) { + const MemoryBuffer &OutputBuffer, + StringRef ArchName) { SmallString<128> OutputPath(SavedObjectsDirectoryPath); - llvm::sys::path::append(OutputPath, Twine(count) + ".thinlto.o"); + llvm::sys::path::append(OutputPath, + Twine(count) + "." + ArchName + ".thinlto.o"); OutputPath.c_str(); // Ensure the string is null terminated. if (sys::fs::exists(OutputPath)) sys::fs::remove(OutputPath); @@ -883,7 +885,8 @@ ProducedBinaries[count] = std::move(OutputBuffer); else ProducedBinaryFiles[count] = writeGeneratedObject( - count, "", SavedObjectsDirectoryPath, *OutputBuffer); + count, "", SavedObjectsDirectoryPath, *OutputBuffer, + TMBuilder.TheTriple.getArchName()); }, count++); } @@ -1007,7 +1010,7 @@ else ProducedBinaryFiles[count] = writeGeneratedObject( count, CacheEntryPath, SavedObjectsDirectoryPath, - *ErrOrBuffer.get()); + *ErrOrBuffer.get(), TMBuilder.TheTriple.getArchName()); return; } } @@ -1064,7 +1067,8 @@ return; } ProducedBinaryFiles[count] = writeGeneratedObject( - count, CacheEntryPath, SavedObjectsDirectoryPath, *OutputBuffer); + count, CacheEntryPath, SavedObjectsDirectoryPath, *OutputBuffer, + TMBuilder.TheTriple.getArchName()); }, IndexCount); } }