[llvm] r313488 - [ThinLTO] Avoid archive member collisions with old API
Johan Engelen via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 17 10:38:26 PDT 2017
Author: jengelen
Date: Sun Sep 17 10:38:26 2017
New Revision: 313488
URL: http://llvm.org/viewvc/llvm-project?rev=313488&view=rev
Log:
[ThinLTO] Avoid archive member collisions with old API
Summary:
ld64 on OSX uses the old ThinLTOCodegenerator API. When two modules have the same name in an archive (valid archive), a name collision happens for the modules' buffer identifiers.
This PR resolves this, by suffixing the module name with an increasing number such that the identifiers are guaranteed to be unique.
For a similar fix in LLD, see https://reviews.llvm.org/D25495
Reviewers: mehdi_amini, tejohnson
Reviewed By: mehdi_amini
Subscribers: inglorion, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D37961
Modified:
llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
Modified: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=313488&r1=313487&r2=313488&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp Sun Sep 17 10:38:26 2017
@@ -535,7 +535,9 @@ static void initTMBuilder(TargetMachineB
} // end anonymous namespace
void ThinLTOCodeGenerator::addModule(StringRef Identifier, StringRef Data) {
- ThinLTOBuffer Buffer(Data, Identifier);
+ std::string Id =
+ (Twine(Identifier) + "_" + std::to_string(Modules.size())).str();
+ ThinLTOBuffer Buffer(Data, std::move(Id));
LLVMContext Context;
StringRef TripleStr;
ErrorOr<std::string> TripleOrErr = expectedToErrorOrAndEmitErrors(
More information about the llvm-commits
mailing list