[llvm-commits] CVS: llvm/tools/llvm-ld/llvm-ld.cpp
Reid Spencer
reid at x10sys.com
Sun Dec 5 11:15:40 PST 2004
Changes in directory llvm/tools/llvm-ld:
llvm-ld.cpp updated: 1.5 -> 1.6
---
Log message:
Fix PR139: http://llvm.cs.uiuc.edu/PR139 :\
When not linking as a library, use LinkItems to retain command line order of \
linking, otherwise use LinkFiles
---
Diffs of the changes: (+20 -19)
Index: llvm/tools/llvm-ld/llvm-ld.cpp
diff -u llvm/tools/llvm-ld/llvm-ld.cpp:1.5 llvm/tools/llvm-ld/llvm-ld.cpp:1.6
--- llvm/tools/llvm-ld/llvm-ld.cpp:1.5 Sat Nov 20 14:02:56 2004
+++ llvm/tools/llvm-ld/llvm-ld.cpp Sun Dec 5 13:15:29 2004
@@ -389,29 +389,30 @@
cl::ParseCommandLineOptions(argc, argv, " llvm linker for GCC\n");
sys::PrintStackTraceOnErrorSignal();
- std::string ModuleID("llvm-ld-output");
- std::auto_ptr<Module> Composite(new Module(ModuleID));
-
- // We always look first in the current directory when searching for libraries.
- LibPaths.insert(LibPaths.begin(), ".");
-
- // If the user specified an extra search path in their environment, respect
- // it.
- if (char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH"))
- LibPaths.push_back(SearchPath);
-
// Remove any consecutive duplicates of the same library...
Libraries.erase(std::unique(Libraries.begin(), Libraries.end()),
Libraries.end());
- // Link in all of the files
- if (LinkFiles(argv[0], Composite.get(), InputFilenames, Verbose))
- return 1; // Error already printed
-
- // Link in all of the libraries next...
- if (!LinkAsLibrary)
- LinkLibraries(argv[0], Composite.get(), Libraries, LibPaths,
- Verbose, Native);
+ // Set up the Composite module.
+ std::auto_ptr<Module> Composite(0);
+
+ if (LinkAsLibrary) {
+ // Link in only the files, we ignore libraries in this case.
+ Composite.reset( new Module(argv[0]) );
+ if (LinkFiles(argv[0], Composite.get(), InputFilenames, Verbose))
+ return 1; // Error already printed
+ } else {
+ // Build a list of the items from our command line
+ LinkItemList Items;
+ BuildLinkItems(Items, InputFilenames, Libraries);
+
+ // Link all the items together
+ Composite.reset( LinkItems(argv[0], Items, LibPaths, Verbose, Native) );
+
+ // Check for an error during linker
+ if (!Composite.get())
+ return 1; // Error already printed
+ }
// Optimize the module
Optimize(Composite.get());
More information about the llvm-commits
mailing list