[llvm-commits] CVS: llvm/tools/gccld/gccld.cpp

Misha Brukman brukman at cs.uiuc.edu
Thu Nov 20 13:09:09 PST 2003


Changes in directory llvm/tools/gccld:

gccld.cpp updated: 1.63 -> 1.64

---
Log message:

When writing out the runner script, add -load=<lib> lines to pull in all the
shared objects automagically, so it doesn't have to be done by hand.


---
Diffs of the changes:  (+18 -1)

Index: llvm/tools/gccld/gccld.cpp
diff -u llvm/tools/gccld/gccld.cpp:1.63 llvm/tools/gccld/gccld.cpp:1.64
--- llvm/tools/gccld/gccld.cpp:1.63	Thu Nov 20 00:21:54 2003
+++ llvm/tools/gccld/gccld.cpp	Thu Nov 20 13:08:42 2003
@@ -281,7 +281,24 @@
       if (!Out2.good())
         return PrintAndReturn(argv[0], "error opening '" + OutputFilename +
                                        "' for writing!");
-      Out2 << "#!/bin/sh\nlli $0.bc $*\n";
+      Out2 << "#!/bin/sh\nlli \\\n";
+      // gcc accepts -l<lib> and implicitly searches /lib and /usr/lib.
+      LibPaths.push_back("/lib");
+      LibPaths.push_back("/usr/lib");
+      // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
+      // shared object at all! See RH 8: plain text.
+      std::vector<std::string>::iterator libc = 
+        std::find(Libraries.begin(), Libraries.end(), "c");
+      if (libc != Libraries.end()) Libraries.erase(libc);
+      // List all the shared object (native) libraries this executable will need
+      // 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) {
+        std::string FullLibraryPath = FindLib(*i, LibPaths, true);
+        if (!FullLibraryPath.empty())
+          Out2 << "    -load=" << FullLibraryPath << " \\\n";
+      }
+      Out2 << "    $0.bc $*\n";
       Out2.close();
     }
   





More information about the llvm-commits mailing list