}
// If we STILL cannot resolve the types, then there is something wrong.
- // Report the warning and delete one of the names.
if (DelayedTypesToResolve.size() == OldSize) {
- const std::string &Name = DelayedTypesToResolve.back();
-
- const Type *T1 = SrcST->lookupType(Name);
- const Type *T2 = DestST->lookupType(Name);
- std::cerr << "WARNING: Type conflict between types named '" << Name
- << "'.\n Src='";
- WriteTypeSymbolic(std::cerr, T1, Src);
- std::cerr << "'.\n Dest='";
- WriteTypeSymbolic(std::cerr, T2, Dest);
- std::cerr << "'\n";
-
// Remove the symbol name from the destination.
DelayedTypesToResolve.pop_back();
}
DGV->setLinkage(NewLinkage);
if (LinkFromSrc) {
- if (DGV->isConstant() && !SGV->isConstant())
- return Error(Err, "Global Variable Collision on global '" +
- SGV->getName() + "': variables differ in const'ness");
// Inherit const as appropriate
- if (SGV->isConstant()) DGV->setConstant(true);
+ DGV->setConstant(SGV->isConstant());
DGV->setInitializer(0);
} else {
if (SGV->isConstant() && !DGV->isConstant()) {
- if (!DGV->isExternal())
- return Error(Err, "Global Variable Collision on global '" +
- SGV->getName() + "': variables differ in const'ness");
- else
+ if (DGV->isExternal())
DGV->setConstant(true);
}
SGV->setLinkage(GlobalValue::ExternalLinkage);
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
// the problem. Upon failure, the Dest module could be in a modified state, and
// shouldn't be relied on to be consistent.
-bool llvm::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
+bool
+Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
assert(Dest != 0 && "Invalid Destination module");
assert(Src != 0 && "Invalid Source Module");
Dest->setEndianness(Src->getEndianness());
if (Dest->getPointerSize() == Module::AnyPointerSize)
Dest->setPointerSize(Src->getPointerSize());
+ if (Dest->getTargetTriple().empty())
+ Dest->setTargetTriple(Src->getTargetTriple());
if (Src->getEndianness() != Module::AnyEndianness &&
Dest->getEndianness() != Src->getEndianness())
if (Src->getPointerSize() != Module::AnyPointerSize &&
Dest->getPointerSize() != Src->getPointerSize())
std::cerr << "WARNING: Linking two modules of different pointer size!\n";
-
+ if (!Src->getTargetTriple().empty() &&
+ Dest->getTargetTriple() != Src->getTargetTriple())
+ std::cerr << "WARNING: Linking two modules of different target triples!\n";
+
// Update the destination module's dependent libraries list with the libraries
// from the source module. There's no opportunity for duplicates here as the
// Module ensures that duplicate insertions are discarded.