Add ability to search only for native shared object, and expose the
authorMisha Brukman <brukman+llvm@gmail.com>
Thu, 20 Nov 2003 19:08:06 +0000 (19:08 +0000)
committerMisha Brukman <brukman+llvm@gmail.com>
Thu, 20 Nov 2003 19:08:06 +0000 (19:08 +0000)
functionality to the rest of gccld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkArchives.cpp
tools/gccld/Linker.cpp
tools/gccld/gccld.h

index 701458bb43ed054b031b2ea65b3d521bd3689222..a009cf59d6917c0bec27dcf72bc4cc14d44dfe32 100644 (file)
@@ -39,8 +39,9 @@ namespace llvm {
 /// named by the value of the environment variable LLVM_LIB_SEARCH_PATH. Returns
 /// an empty string if no matching file can be found.
 ///
-static std::string FindLib(const std::string &Filename,
-                           const std::vector<std::string> &Paths) {
+std::string FindLib(const std::string &Filename,
+                    const std::vector<std::string> &Paths,
+                    bool SharedObjectOnly) {
   // Determine if the pathname can be found as it stands.
   if (FileOpenable(Filename))
     return Filename;
@@ -53,13 +54,13 @@ static std::string FindLib(const std::string &Filename,
   for (unsigned Index = 0; Index != Paths.size(); ++Index) {
     std::string Directory = Paths[Index] + "/";
 
-    if (FileOpenable(Directory + LibName + ".bc"))
+    if (!SharedObjectOnly && FileOpenable(Directory + LibName + ".bc"))
       return Directory + LibName + ".bc";
 
     if (FileOpenable(Directory + LibName + ".so"))
       return Directory + LibName + ".so";
 
-    if (FileOpenable(Directory + LibName + ".a"))
+    if (!SharedObjectOnly && FileOpenable(Directory + LibName + ".a"))
       return Directory + LibName + ".a";
   }
 
@@ -99,9 +100,6 @@ void GetAllDefinedSymbols(Module *M, std::set<std::string> &DefinedSymbols) {
 ///  UndefinedSymbols - A set of C++ strings containing the name of all
 ///                     undefined symbols.
 ///
-/// Return value:
-///  None.
-///
 void
 GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
   std::set<std::string> DefinedSymbols;
index 701458bb43ed054b031b2ea65b3d521bd3689222..a009cf59d6917c0bec27dcf72bc4cc14d44dfe32 100644 (file)
@@ -39,8 +39,9 @@ namespace llvm {
 /// named by the value of the environment variable LLVM_LIB_SEARCH_PATH. Returns
 /// an empty string if no matching file can be found.
 ///
-static std::string FindLib(const std::string &Filename,
-                           const std::vector<std::string> &Paths) {
+std::string FindLib(const std::string &Filename,
+                    const std::vector<std::string> &Paths,
+                    bool SharedObjectOnly) {
   // Determine if the pathname can be found as it stands.
   if (FileOpenable(Filename))
     return Filename;
@@ -53,13 +54,13 @@ static std::string FindLib(const std::string &Filename,
   for (unsigned Index = 0; Index != Paths.size(); ++Index) {
     std::string Directory = Paths[Index] + "/";
 
-    if (FileOpenable(Directory + LibName + ".bc"))
+    if (!SharedObjectOnly && FileOpenable(Directory + LibName + ".bc"))
       return Directory + LibName + ".bc";
 
     if (FileOpenable(Directory + LibName + ".so"))
       return Directory + LibName + ".so";
 
-    if (FileOpenable(Directory + LibName + ".a"))
+    if (!SharedObjectOnly && FileOpenable(Directory + LibName + ".a"))
       return Directory + LibName + ".a";
   }
 
@@ -99,9 +100,6 @@ void GetAllDefinedSymbols(Module *M, std::set<std::string> &DefinedSymbols) {
 ///  UndefinedSymbols - A set of C++ strings containing the name of all
 ///                     undefined symbols.
 ///
-/// Return value:
-///  None.
-///
 void
 GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
   std::set<std::string> DefinedSymbols;
index 9b7eb1e87731e5331ce143d0c1e3d9f789306f9e..a2d2eb8d6ad02f455053d511f1db9f30f0daa5f3 100644 (file)
@@ -58,6 +58,10 @@ GenerateNative (const std::string & OutputFilename,
 std::auto_ptr<Module>
 LoadObject (const std::string & FN, std::string &OutErrorMessage);
 
+std::string FindLib(const std::string &Filename,
+                    const std::vector<std::string> &Paths,
+                    bool SharedObjectOnly = false);
+  
 bool
 LinkLibraries (const char * progname,
                Module * HeadModule,