When -link-as-library, add -l options to Module's deplibs
authorReid Spencer <rspencer@reidspencer.com>
Wed, 8 Dec 2004 05:17:40 +0000 (05:17 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Wed, 8 Dec 2004 05:17:40 +0000 (05:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18617 91177308-0d34-0410-b5e6-96231b3b80d8

tools/gccld/gccld.cpp
tools/llvm-ld/llvm-ld.cpp

index 48fbd8b633daec561487573f8e67b428d862adc7..d06eb6ec05f5d1a24ac62d32db5c42f683aa74d8 100644 (file)
@@ -176,10 +176,17 @@ int main(int argc, char **argv, char **envp) {
     std::auto_ptr<Module> Composite(0);
 
     if (LinkAsLibrary) {
-      // Link in only the files, we ignore libraries in this case.
+      // Link in only the files.
       Composite.reset( new Module(argv[0]) );
       if (LinkFiles(argv[0], Composite.get(), InputFilenames, Verbose))
         return 1; // Error already printed
+      // The libraries aren't linked in but are noted as "dependent" in the
+      // module.
+      for (cl::list<std::string>::const_iterator I = Libraries.begin(), 
+           E = Libraries.end(); I != E ; ++I) {
+        Composite.get()->addLibrary(*I);
+      }
+
     } else {
       // Build a list of the items from our command line
       LinkItemList Items;
index 3512c2a66a32f85afd5587adca11a36a66333024..db5c4173a37cb70512198c9d56439393fc089ea2 100644 (file)
@@ -397,10 +397,17 @@ int main(int argc, char **argv, char **envp) {
   std::auto_ptr<Module> Composite(0);
 
   if (LinkAsLibrary) {
-    // Link in only the files, we ignore libraries in this case.
+    // Link in only the files.
     Composite.reset( new Module(argv[0]) );
     if (LinkFiles(argv[0], Composite.get(), InputFilenames, Verbose))
       return 1; // Error already printed
+
+    // The libraries aren't linked in but are noted as "dependent" in the
+    // module.
+    for (cl::list<std::string>::const_iterator I = Libraries.begin(), 
+         E = Libraries.end(); I != E ; ++I) {
+      Composite.get()->addLibrary(*I);
+    }
   } else {
     // Build a list of the items from our command line
     LinkItemList Items;