diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-05 19:01:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-05 19:01:32 +0000 |
commit | 5d5a8975298f037e1b1787ae675cfdc66b766fc3 (patch) | |
tree | 2491e4ef1cadd82f739f7ea832a13211d4ed81aa /tools/llvm-ld | |
parent | 86ae142c51fc29ab870ebf42f6bf8699bca81512 (diff) | |
download | external_llvm-5d5a8975298f037e1b1787ae675cfdc66b766fc3.zip external_llvm-5d5a8975298f037e1b1787ae675cfdc66b766fc3.tar.gz external_llvm-5d5a8975298f037e1b1787ae675cfdc66b766fc3.tar.bz2 |
make llvm-ld smart enough to link against native libraries that are
not in system library directories by checking -L paths as well.
Patch by Axel Naumann!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-ld')
-rw-r--r-- | tools/llvm-ld/llvm-ld.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index ed52254..28187c9 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -36,6 +36,7 @@ #include "llvm/Support/Streams.h" #include "llvm/Support/SystemUtils.h" #include "llvm/System/Signals.h" +#include "llvm/Config/config.h" #include <fstream> #include <memory> #include <cstring> @@ -437,8 +438,23 @@ static void EmitShellScript(char **argv) { // on the command line, so that we don't have to do this manually! for (std::vector<std::string>::iterator i = Libraries.begin(), e = Libraries.end(); i != e; ++i) { - sys::Path FullLibraryPath = sys::Path::FindLibrary(*i); - if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary()) + // try explicit -L arguments first: + sys::Path FullLibraryPath; + for (cl::list<std::string>::const_iterator P = LibPaths.begin(), + E = LibPaths.end(); P != E; ++P) { + FullLibraryPath = *P; + FullLibraryPath.appendComponent("lib" + *i); + FullLibraryPath.appendSuffix(&(LTDL_SHLIB_EXT[1])); + if (!FullLibraryPath.isEmpty()) { + if (!FullLibraryPath.isDynamicLibrary()) { + // Not a native shared library; mark as invalid + FullLibraryPath = sys::Path(); + } else break; + } + } + if (FullLibraryPath.isEmpty()) + FullLibraryPath = sys::Path::FindLibrary(*i); + if (!FullLibraryPath.isEmpty()) Out2 << " -load=" << FullLibraryPath.toString() << " \\\n"; } Out2 << " $0.bc ${1+\"$@\"}\n"; |