summaryrefslogtreecommitdiff
path: root/lib/Linker
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-07-07 23:21:43 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-07-07 23:21:43 +0000
commitdd04df0ec33a903ee7fc747701bafde622f77d8b (patch)
tree341d4fd4ba6e81cb79966ef2c379ccbb2d8b5100 /lib/Linker
parentb3d59701c89a6e03a0e0909543f3e7bd9140900f (diff)
downloadllvm-dd04df0ec33a903ee7fc747701bafde622f77d8b.tar.gz
llvm-dd04df0ec33a903ee7fc747701bafde622f77d8b.tar.bz2
llvm-dd04df0ec33a903ee7fc747701bafde622f77d8b.tar.xz
For PR495:
Get rid of the difference between file paths and directory paths. The Path class now simply stores a path that can refer to either a file or a directory. This required various changes in the implementation and interface of the class with the corresponding impact to its users. Doxygen comments were also updated to reflect these changes. Interface changes are: appendDirectory -> appendComponent appendFile -> appendComponent elideDirectory -> eraseComponent elideFile -> eraseComponent elideSuffix -> eraseSuffix renameFile -> rename setDirectory -> set setFile -> set Changes pass Dejagnu and llvm-test/SingleSource tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp2
-rw-r--r--lib/Linker/Linker.cpp42
2 files changed, 26 insertions, 18 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 23ba6ebf58..d20044fa3c 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -899,7 +899,7 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
// 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.setFile(Src->getModuleIdentifier());
+ modId.set(Src->getModuleIdentifier());
if (!modId.isEmpty())
Dest->removeLibrary(modId.getBasename());
diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp
index 3371740393..c72f1b5aca 100644
--- a/lib/Linker/Linker.cpp
+++ b/lib/Linker/Linker.cpp
@@ -69,7 +69,6 @@ Linker::verbose(const std::string& message) {
void
Linker::addPath(const sys::Path& path) {
- assert(path.isDirectory() && "Can only insert directories into the path");
LibPaths.push_back(path);
}
@@ -77,7 +76,7 @@ void
Linker::addPaths(const std::vector<std::string>& paths) {
for (unsigned i = 0; i != paths.size(); ++i) {
sys::Path aPath;
- aPath.setDirectory(paths[i]);
+ aPath.set(paths[i]);
LibPaths.push_back(aPath);
}
}
@@ -118,26 +117,35 @@ Linker::LoadObject(const sys::Path &FN) {
static inline sys::Path IsLibrary(const std::string& Name,
const sys::Path& Directory) {
- assert(Directory.isDirectory() && "Need to specify a directory");
sys::Path FullPath(Directory);
- FullPath.appendFile("lib" + Name);
- FullPath.appendSuffix("a");
- if (FullPath.isArchive())
- return FullPath;
+ // Make sure the directory actually is a directory in the file system.
+ if (FullPath.isDirectory())
+ {
+ // Try the libX.a form
+ FullPath.appendComponent("lib" + Name);
+ FullPath.appendSuffix("a");
+ if (FullPath.isArchive())
+ return FullPath;
+
+ // Try the libX.bca form
+ FullPath.eraseSuffix();
+ FullPath.appendSuffix("bca");
+ if (FullPath.isArchive())
+ return FullPath;
- FullPath.elideSuffix();
- FullPath.appendSuffix("bca");
- if (FullPath.isArchive())
- return FullPath;
+ // Try the libX.so form
+ FullPath.eraseSuffix();
+ FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
+ if (FullPath.isDynamicLibrary()) // Native shared library?
+ return FullPath;
+ if (FullPath.isBytecodeFile()) // .so file containing bytecode?
+ return FullPath;
- FullPath.elideSuffix();
- FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
- if (FullPath.isDynamicLibrary()) // Native shared library?
- return FullPath;
- if (FullPath.isBytecodeFile()) // .so file containing bytecode?
- return FullPath;
+ // Not found .. fall through
+ }
+ // Indicate that the library was not found in the directory.
FullPath.clear();
return FullPath;
}