mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 15:39:06 +00:00
Implement support for dependent libraries. The "source" module's dependent
libraries list is merged into the "destination" module's list. Also, if the source module is one of the dependent libraries, it is removed from the list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
46a981c3e2
commit
57a0efa322
@ -23,6 +23,7 @@
|
|||||||
#include "llvm/SymbolTable.h"
|
#include "llvm/SymbolTable.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include "llvm/System/Path.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -835,6 +836,9 @@ static bool LinkAppendingVars(Module *M,
|
|||||||
// shouldn't be relied on to be consistent.
|
// shouldn't be relied on to be consistent.
|
||||||
//
|
//
|
||||||
bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
||||||
|
assert(Dest != 0 && "Invalid Destination module");
|
||||||
|
assert(Src != 0 && "Invalid Source Module");
|
||||||
|
|
||||||
if (Dest->getEndianness() == Module::AnyEndianness)
|
if (Dest->getEndianness() == Module::AnyEndianness)
|
||||||
Dest->setEndianness(Src->getEndianness());
|
Dest->setEndianness(Src->getEndianness());
|
||||||
if (Dest->getPointerSize() == Module::AnyPointerSize)
|
if (Dest->getPointerSize() == Module::AnyPointerSize)
|
||||||
@ -847,6 +851,16 @@ bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
|||||||
Dest->getPointerSize() != Src->getPointerSize())
|
Dest->getPointerSize() != Src->getPointerSize())
|
||||||
std::cerr << "WARNING: Linking two modules of different pointer size!\n";
|
std::cerr << "WARNING: Linking two modules of different pointer size!\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.
|
||||||
|
Module::lib_iterator SI = Src->lib_begin();
|
||||||
|
Module::lib_iterator SE = Src->lib_end();
|
||||||
|
while ( SI != SE ) {
|
||||||
|
Dest->addLibrary(*SI);
|
||||||
|
++SI;
|
||||||
|
}
|
||||||
|
|
||||||
// LinkTypes - Go through the symbol table of the Src module and see if any
|
// LinkTypes - Go through the symbol table of the Src module and see if any
|
||||||
// types are named in the src module that are not named in the Dst module.
|
// types are named in the src module that are not named in the Dst module.
|
||||||
// Make sure there are no type name conflicts.
|
// Make sure there are no type name conflicts.
|
||||||
@ -915,6 +929,13 @@ bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
|||||||
//
|
//
|
||||||
if (LinkAppendingVars(Dest, AppendingVars, ErrorMsg)) return true;
|
if (LinkAppendingVars(Dest, AppendingVars, ErrorMsg)) return true;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
sys::Path modId;
|
||||||
|
modId.set_file(Src->getModuleIdentifier());
|
||||||
|
if (!modId.is_empty())
|
||||||
|
Dest->removeLibrary(modId.get_basename());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "llvm/SymbolTable.h"
|
#include "llvm/SymbolTable.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include "llvm/System/Path.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -835,6 +836,9 @@ static bool LinkAppendingVars(Module *M,
|
|||||||
// shouldn't be relied on to be consistent.
|
// shouldn't be relied on to be consistent.
|
||||||
//
|
//
|
||||||
bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
||||||
|
assert(Dest != 0 && "Invalid Destination module");
|
||||||
|
assert(Src != 0 && "Invalid Source Module");
|
||||||
|
|
||||||
if (Dest->getEndianness() == Module::AnyEndianness)
|
if (Dest->getEndianness() == Module::AnyEndianness)
|
||||||
Dest->setEndianness(Src->getEndianness());
|
Dest->setEndianness(Src->getEndianness());
|
||||||
if (Dest->getPointerSize() == Module::AnyPointerSize)
|
if (Dest->getPointerSize() == Module::AnyPointerSize)
|
||||||
@ -847,6 +851,16 @@ bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
|||||||
Dest->getPointerSize() != Src->getPointerSize())
|
Dest->getPointerSize() != Src->getPointerSize())
|
||||||
std::cerr << "WARNING: Linking two modules of different pointer size!\n";
|
std::cerr << "WARNING: Linking two modules of different pointer size!\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.
|
||||||
|
Module::lib_iterator SI = Src->lib_begin();
|
||||||
|
Module::lib_iterator SE = Src->lib_end();
|
||||||
|
while ( SI != SE ) {
|
||||||
|
Dest->addLibrary(*SI);
|
||||||
|
++SI;
|
||||||
|
}
|
||||||
|
|
||||||
// LinkTypes - Go through the symbol table of the Src module and see if any
|
// LinkTypes - Go through the symbol table of the Src module and see if any
|
||||||
// types are named in the src module that are not named in the Dst module.
|
// types are named in the src module that are not named in the Dst module.
|
||||||
// Make sure there are no type name conflicts.
|
// Make sure there are no type name conflicts.
|
||||||
@ -915,6 +929,13 @@ bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
|
|||||||
//
|
//
|
||||||
if (LinkAppendingVars(Dest, AppendingVars, ErrorMsg)) return true;
|
if (LinkAppendingVars(Dest, AppendingVars, ErrorMsg)) return true;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
sys::Path modId;
|
||||||
|
modId.set_file(Src->getModuleIdentifier());
|
||||||
|
if (!modId.is_empty())
|
||||||
|
Dest->removeLibrary(modId.get_basename());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user