aboutsummaryrefslogtreecommitdiff
path: root/lib/Linker
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2013-01-11 15:29:34 -0800
committerDerek Schuff <dschuff@chromium.org>2013-01-11 15:29:34 -0800
commit0590f4264010a852dc22c9afa16a7df4d004c19a (patch)
tree018cedac9a062788c2fdc337165bbabc946b8d29 /lib/Linker
parentb770d0e0636a4b5ad61b1ca661caee67576c05fc (diff)
Replace DepLibs bitcode record with metadata
It keeps the same Module interface as the existing/old deplibs feature, but populates the library list from the metadata after reading the bitcode/LL into the Module. Keeping the same module interface will allow us to keep the existing uses (e.g. in the gold plugin) as they are. Internally it still uses the LibraryList variable, but uses it basically as a cache backed by the metadata. BUG= Review URL: https://codereview.chromium.org/11615013
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkItems.cpp28
-rw-r--r--lib/Linker/LinkModules.cpp15
2 files changed, 41 insertions, 2 deletions
diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp
index 124e5e4e4d..c3e55976bc 100644
--- a/lib/Linker/LinkItems.cpp
+++ b/lib/Linker/LinkItems.cpp
@@ -51,6 +51,21 @@ Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) {
}
}
+ // @LOCALMOD-BEGIN
+ // At this point we have processed all the link items provided to us. Since
+ // we have an aggregated module at this point, the dependent libraries in
+ // that module should also be aggregated with duplicates eliminated. This is
+ // now the time to process the dependent libraries to resolve any remaining
+ // symbols.
+ bool is_native;
+ for (Module::lib_iterator I = Composite->lib_begin(),
+ E = Composite->lib_end(); I != E; ++I) {
+ if(LinkInLibrary(*I, is_native))
+ return true;
+ if (is_native)
+ NativeItems.push_back(std::make_pair(*I, true));
+ }
+ // @LOCALMOD-END
return false;
}
@@ -113,7 +128,18 @@ bool Linker::LinkInLibraries(const std::vector<std::string> &Libraries) {
for (unsigned i = 0; i < Libraries.size(); ++i)
if (LinkInLibrary(Libraries[i], is_native))
return true;
-
+ // @LOCALMOD-BEGIN
+ // At this point we have processed all the libraries provided to us. Since
+ // we have an aggregated module at this point, the dependent libraries in
+ // that module should also be aggregated with duplicates eliminated. This is
+ // now the time to process the dependent libraries to resolve any remaining
+ // symbols.
+ const Module::LibraryListType& DepLibs = Composite->getLibraries();
+ for (Module::LibraryListType::const_iterator I = DepLibs.begin(),
+ E = DepLibs.end(); I != E; ++I)
+ if (LinkInLibrary(*I, is_native))
+ return true;
+ // @LOCALMOD-END
return false;
}
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 6554d9c429..d2aad0859d 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -1206,7 +1206,20 @@ bool ModuleLinker::run() {
DstM->setModuleInlineAsm(DstM->getModuleInlineAsm()+"\n"+
SrcM->getModuleInlineAsm());
}
-
+ // @LOCALMOD-BEGIN
+ // 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.
+ for (Module::lib_iterator SI = SrcM->lib_begin(), SE = SrcM->lib_end();
+ SI != SE; ++SI)
+ DstM->addLibrary(*SI);
+
+ // If the source library's module id is in the dependent library list of the
+ // destination library, remove it since that module is now linked in.
+ StringRef ModuleId = SrcM->getModuleIdentifier();
+ if (!ModuleId.empty())
+ DstM->removeLibrary(sys::path::stem(ModuleId));
+ // @LOCALMOD-END
// Loop over all of the linked values to compute type mappings.
computeTypeMapping();