Synchronize the logic for deciding to link a gv.
[oota-llvm.git] / lib / Linker / LinkModules.cpp
index a9fcee7c98ce03a837a684fad0adfc1752508d2d..3d40c126dd2706f7c589be0060ca91636f73d82e 100644 (file)
@@ -1050,7 +1050,12 @@ bool ModuleLinker::shouldLinkFromSource(bool &LinkFromSrc,
       return false;
     }
     // If the Dest is weak, use the source linkage.
-    LinkFromSrc = Dest.hasExternalWeakLinkage();
+    if (Dest.hasExternalWeakLinkage()) {
+      LinkFromSrc = true;
+      return false;
+    }
+    // Link an available_externally over a declaration.
+    LinkFromSrc = !Src.isDeclaration() && Dest.isDeclaration();
     return false;
   }