[llvm-commits] [llvm] r61730 - /llvm/trunk/tools/llvm-ld/llvm-ld.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 5 11:01:33 PST 2009
Author: lattner
Date: Mon Jan 5 13:01:32 2009
New Revision: 61730
URL: http://llvm.org/viewvc/llvm-project?rev=61730&view=rev
Log:
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!
Modified:
llvm/trunk/tools/llvm-ld/llvm-ld.cpp
Modified: llvm/trunk/tools/llvm-ld/llvm-ld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/llvm-ld.cpp?rev=61730&r1=61729&r2=61730&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ld/llvm-ld.cpp (original)
+++ llvm/trunk/tools/llvm-ld/llvm-ld.cpp Mon Jan 5 13:01:32 2009
@@ -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 @@
// 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";
More information about the llvm-commits
mailing list