Eliminate silly warnings from the linker of the form:
[oota-llvm.git] / lib / Linker / LinkModules.cpp
index d58acbec81c0ab11d36cb442e98c8de804b09231..0d65ddd1dd9564c6e71d326fe746cc99a7d349b7 100644 (file)
@@ -237,19 +237,7 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
       }
 
       // 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();
       }
@@ -517,18 +505,12 @@ static bool LinkGlobals(Module *Dest, Module *Src,
       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);
@@ -821,7 +803,8 @@ static bool LinkAppendingVars(Module *M,
 // 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");
 
@@ -829,6 +812,8 @@ bool llvm::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
     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())
@@ -836,7 +821,10 @@ bool llvm::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
   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.