blob: 7cd440d1d267b9c7128d208336efe660b64ebd24 [file] [log] [blame]
Chris Lattnera58d2be2003-09-30 03:24:28 +00001//===- Linker.cpp - Link together LLVM objects and libraries --------------===//
John Criswell7c0e0222003-10-20 17:47:21 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
John Criswell71478b72003-09-19 20:24:23 +00009//
Chris Lattnera58d2be2003-09-30 03:24:28 +000010// This file contains routines to handle linking together LLVM bytecode files,
11// and to handle annoying things like static libraries.
John Criswell71478b72003-09-19 20:24:23 +000012//
13//===----------------------------------------------------------------------===//
14
Misha Brukman17dc4ce2003-09-29 22:16:43 +000015#include "gccld.h"
John Criswell71478b72003-09-19 20:24:23 +000016#include "llvm/Module.h"
17#include "llvm/PassManager.h"
18#include "llvm/Bytecode/Reader.h"
19#include "llvm/Bytecode/WriteBytecodePass.h"
20#include "llvm/Target/TargetData.h"
21#include "llvm/Transforms/IPO.h"
22#include "llvm/Transforms/Scalar.h"
Misha Brukman17dc4ce2003-09-29 22:16:43 +000023#include "llvm/Transforms/Utils/Linker.h"
John Criswell71478b72003-09-19 20:24:23 +000024#include "Support/CommandLine.h"
Misha Brukman17dc4ce2003-09-29 22:16:43 +000025#include "Support/FileUtilities.h"
John Criswell71478b72003-09-19 20:24:23 +000026#include "Support/Signals.h"
Misha Brukman17dc4ce2003-09-29 22:16:43 +000027#include "Support/SystemUtils.h"
Misha Brukman17dc4ce2003-09-29 22:16:43 +000028#include <algorithm>
John Criswell71478b72003-09-19 20:24:23 +000029#include <fstream>
30#include <memory>
31#include <set>
Chris Lattner6cc8ca92003-11-28 07:44:09 +000032using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000033
Brian Gaeke0d723ac2003-11-11 21:54:01 +000034/// FindLib - Try to convert Filename into the name of a file that we can open,
35/// if it does not already name a file we can open, by first trying to open
36/// Filename, then libFilename.<suffix> for each of a set of several common
37/// library suffixes, in each of the directories in Paths and the directory
38/// named by the value of the environment variable LLVM_LIB_SEARCH_PATH. Returns
39/// an empty string if no matching file can be found.
Misha Brukman5208ba12003-09-30 18:09:32 +000040///
Chris Lattner6cc8ca92003-11-28 07:44:09 +000041std::string llvm::FindLib(const std::string &Filename,
42 const std::vector<std::string> &Paths,
43 bool SharedObjectOnly) {
John Criswell71478b72003-09-19 20:24:23 +000044 // Determine if the pathname can be found as it stands.
Brian Gaekeee8adb12003-11-11 18:27:37 +000045 if (FileOpenable(Filename))
John Criswell71478b72003-09-19 20:24:23 +000046 return Filename;
John Criswell71478b72003-09-19 20:24:23 +000047
John Criswell71478b72003-09-19 20:24:23 +000048 // If that doesn't work, convert the name into a library name.
John Criswell71478b72003-09-19 20:24:23 +000049 std::string LibName = "lib" + Filename;
50
John Criswell71478b72003-09-19 20:24:23 +000051 // Iterate over the directories in Paths to see if we can find the library
52 // there.
Misha Brukman17dc4ce2003-09-29 22:16:43 +000053 for (unsigned Index = 0; Index != Paths.size(); ++Index) {
John Criswell71478b72003-09-19 20:24:23 +000054 std::string Directory = Paths[Index] + "/";
55
Misha Brukman84fbc652003-11-20 19:08:06 +000056 if (!SharedObjectOnly && FileOpenable(Directory + LibName + ".bc"))
John Criswell71478b72003-09-19 20:24:23 +000057 return Directory + LibName + ".bc";
John Criswell71478b72003-09-19 20:24:23 +000058
Brian Gaekeee8adb12003-11-11 18:27:37 +000059 if (FileOpenable(Directory + LibName + ".so"))
John Criswell71478b72003-09-19 20:24:23 +000060 return Directory + LibName + ".so";
John Criswell71478b72003-09-19 20:24:23 +000061
Misha Brukman84fbc652003-11-20 19:08:06 +000062 if (!SharedObjectOnly && FileOpenable(Directory + LibName + ".a"))
John Criswell71478b72003-09-19 20:24:23 +000063 return Directory + LibName + ".a";
John Criswell71478b72003-09-19 20:24:23 +000064 }
65
John Criswell71478b72003-09-19 20:24:23 +000066 // One last hope: Check LLVM_LIB_SEARCH_PATH.
John Criswell71478b72003-09-19 20:24:23 +000067 char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
68 if (SearchPath == NULL)
Misha Brukman17dc4ce2003-09-29 22:16:43 +000069 return std::string();
John Criswell71478b72003-09-19 20:24:23 +000070
71 LibName = std::string(SearchPath) + "/" + LibName;
Brian Gaekeee8adb12003-11-11 18:27:37 +000072 if (FileOpenable(LibName))
John Criswell71478b72003-09-19 20:24:23 +000073 return LibName;
John Criswell71478b72003-09-19 20:24:23 +000074
75 return std::string();
76}
77
Brian Gaeke3b3640a2003-11-05 22:12:52 +000078/// GetAllDefinedSymbols - Modifies its parameter DefinedSymbols to contain the
79/// name of each externally-visible symbol defined in M.
Misha Brukman5208ba12003-09-30 18:09:32 +000080///
Chris Lattner6cc8ca92003-11-28 07:44:09 +000081void llvm::GetAllDefinedSymbols(Module *M,
82 std::set<std::string> &DefinedSymbols) {
John Criswell71478b72003-09-19 20:24:23 +000083 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
84 if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage())
85 DefinedSymbols.insert(I->getName());
86 for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
87 if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage())
88 DefinedSymbols.insert(I->getName());
89}
90
Misha Brukman5208ba12003-09-30 18:09:32 +000091/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
92/// exist in an LLVM module. This is a bit tricky because there may be two
93/// symbols with the same name but different LLVM types that will be resolved to
94/// each other but aren't currently (thus we need to treat it as resolved).
95///
96/// Inputs:
97/// M - The module in which to find undefined symbols.
98///
99/// Outputs:
100/// UndefinedSymbols - A set of C++ strings containing the name of all
101/// undefined symbols.
102///
John Criswell71478b72003-09-19 20:24:23 +0000103void
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000104llvm::GetAllUndefinedSymbols(Module *M,
105 std::set<std::string> &UndefinedSymbols) {
John Criswell71478b72003-09-19 20:24:23 +0000106 std::set<std::string> DefinedSymbols;
107 UndefinedSymbols.clear(); // Start out empty
108
109 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
110 if (I->hasName()) {
111 if (I->isExternal())
112 UndefinedSymbols.insert(I->getName());
113 else if (!I->hasInternalLinkage())
114 DefinedSymbols.insert(I->getName());
115 }
116 for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
117 if (I->hasName()) {
118 if (I->isExternal())
119 UndefinedSymbols.insert(I->getName());
120 else if (!I->hasInternalLinkage())
121 DefinedSymbols.insert(I->getName());
122 }
123
124 // Prune out any defined symbols from the undefined symbols set...
125 for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
126 I != UndefinedSymbols.end(); )
127 if (DefinedSymbols.count(*I))
128 UndefinedSymbols.erase(I++); // This symbol really is defined!
129 else
130 ++I; // Keep this symbol in the undefined symbols list
131}
132
133
Brian Gaeke0d723ac2003-11-11 21:54:01 +0000134/// LoadObject - Read in and parse the bytecode file named by FN and return the
135/// module it contains (wrapped in an auto_ptr), or 0 and set ErrorMessage if an
136/// error occurs.
Misha Brukman5208ba12003-09-30 18:09:32 +0000137///
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000138std::auto_ptr<Module> llvm::LoadObject(const std::string &FN,
139 std::string &ErrorMessage) {
Brian Gaeke0d723ac2003-11-11 21:54:01 +0000140 std::string ParserErrorMessage;
141 Module *Result = ParseBytecodeFile(FN, &ParserErrorMessage);
John Criswell71478b72003-09-19 20:24:23 +0000142 if (Result) return std::auto_ptr<Module>(Result);
Brian Gaeke0d723ac2003-11-11 21:54:01 +0000143 ErrorMessage = "Bytecode file '" + FN + "' could not be loaded";
144 if (ParserErrorMessage.size()) ErrorMessage += ": " + ParserErrorMessage;
John Criswell71478b72003-09-19 20:24:23 +0000145 return std::auto_ptr<Module>();
146}
147
Misha Brukman5208ba12003-09-30 18:09:32 +0000148/// LinkInArchive - opens an archive library and link in all objects which
149/// provide symbols that are currently undefined.
150///
151/// Inputs:
152/// M - The module in which to link the archives.
153/// Filename - The pathname of the archive.
154/// Verbose - Flags whether verbose messages should be printed.
155///
156/// Outputs:
157/// ErrorMessage - A C++ string detailing what error occurred, if any.
158///
159/// Return Value:
160/// TRUE - An error occurred.
161/// FALSE - No errors.
162///
Misha Brukmane6763132003-09-29 22:26:24 +0000163static bool LinkInArchive(Module *M,
164 const std::string &Filename,
165 std::string &ErrorMessage,
166 bool Verbose)
John Criswell71478b72003-09-19 20:24:23 +0000167{
John Criswell71478b72003-09-19 20:24:23 +0000168 // Find all of the symbols currently undefined in the bytecode program.
169 // If all the symbols are defined, the program is complete, and there is
170 // no reason to link in any archive files.
John Criswell71478b72003-09-19 20:24:23 +0000171 std::set<std::string> UndefinedSymbols;
Misha Brukmane6763132003-09-29 22:26:24 +0000172 GetAllUndefinedSymbols(M, UndefinedSymbols);
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000173 if (UndefinedSymbols.empty()) {
John Criswell71478b72003-09-19 20:24:23 +0000174 if (Verbose) std::cerr << " No symbols undefined, don't link library!\n";
175 return false; // No need to link anything in!
176 }
177
John Criswell71478b72003-09-19 20:24:23 +0000178 // Load in the archive objects.
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000179 if (Verbose) std::cerr << " Loading archive file '" << Filename << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000180 std::vector<Module*> Objects;
Misha Brukmane6763132003-09-29 22:26:24 +0000181 if (ReadArchiveFile(Filename, Objects, &ErrorMessage))
John Criswell71478b72003-09-19 20:24:23 +0000182 return true;
John Criswell71478b72003-09-19 20:24:23 +0000183
John Criswell71478b72003-09-19 20:24:23 +0000184 // Figure out which symbols are defined by all of the modules in the archive.
John Criswell71478b72003-09-19 20:24:23 +0000185 std::vector<std::set<std::string> > DefinedSymbols;
Misha Brukmane6763132003-09-29 22:26:24 +0000186 DefinedSymbols.resize(Objects.size());
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000187 for (unsigned i = 0; i != Objects.size(); ++i) {
John Criswell71478b72003-09-19 20:24:23 +0000188 GetAllDefinedSymbols(Objects[i], DefinedSymbols[i]);
189 }
190
191 // While we are linking in object files, loop.
192 bool Linked = true;
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000193 while (Linked) {
John Criswell71478b72003-09-19 20:24:23 +0000194 Linked = false;
195
196 for (unsigned i = 0; i != Objects.size(); ++i) {
197 // Consider whether we need to link in this module... we only need to
198 // link it in if it defines some symbol which is so far undefined.
199 //
200 const std::set<std::string> &DefSymbols = DefinedSymbols[i];
201
202 bool ObjectRequired = false;
John Criswell1715ce02003-12-23 17:37:06 +0000203
204 //
John Criswell368751f2003-12-23 20:27:14 +0000205 // If the object defines main() and the program currently has main()
206 // undefined, then automatically link in the module. Otherwise, look to
207 // see if it defines a symbol that is currently undefined.
John Criswell1715ce02003-12-23 17:37:06 +0000208 //
John Criswell368751f2003-12-23 20:27:14 +0000209 if ((M->getMainFunction() == NULL) &&
210 ((DefSymbols.find ("main")) != DefSymbols.end())) {
211 ObjectRequired = true;
212 } else {
John Criswell1715ce02003-12-23 17:37:06 +0000213 for (std::set<std::string>::iterator I = UndefinedSymbols.begin(),
214 E = UndefinedSymbols.end(); I != E; ++I)
215 if (DefSymbols.count(*I)) {
216 if (Verbose)
217 std::cerr << " Found object '"
218 << Objects[i]->getModuleIdentifier ()
219 << "' providing symbol '" << *I << "'...\n";
220 ObjectRequired = true;
221 break;
222 }
John Criswell1715ce02003-12-23 17:37:06 +0000223 }
224
John Criswell71478b72003-09-19 20:24:23 +0000225 // We DO need to link this object into the program...
226 if (ObjectRequired) {
227 if (LinkModules(M, Objects[i], &ErrorMessage))
228 return true; // Couldn't link in the right object file...
229
230 // Since we have linked in this object, delete it from the list of
231 // objects to consider in this archive file.
232 std::swap(Objects[i], Objects.back());
233 std::swap(DefinedSymbols[i], DefinedSymbols.back());
234 Objects.pop_back();
235 DefinedSymbols.pop_back();
236 --i; // Do not skip an entry
237
238 // The undefined symbols set should have shrunk.
239 GetAllUndefinedSymbols(M, UndefinedSymbols);
240 Linked = true; // We have linked something in!
241 }
242 }
243 }
244
245 return false;
246}
247
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000248/// LinkInFile - opens a bytecode file and links in all objects which
Misha Brukman5208ba12003-09-30 18:09:32 +0000249/// provide symbols that are currently undefined.
250///
251/// Inputs:
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000252/// HeadModule - The module in which to link the bytecode file.
253/// Filename - The pathname of the bytecode file.
Misha Brukman5208ba12003-09-30 18:09:32 +0000254/// Verbose - Flags whether verbose messages should be printed.
255///
256/// Outputs:
257/// ErrorMessage - A C++ string detailing what error occurred, if any.
258///
259/// Return Value:
260/// TRUE - An error occurred.
261/// FALSE - No errors.
262///
Misha Brukmane6763132003-09-29 22:26:24 +0000263static bool LinkInFile(Module *HeadModule,
264 const std::string &Filename,
265 std::string &ErrorMessage,
266 bool Verbose)
John Criswell71478b72003-09-19 20:24:23 +0000267{
268 std::auto_ptr<Module> M(LoadObject(Filename, ErrorMessage));
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000269 if (M.get() == 0) return true;
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000270 bool Result = LinkModules(HeadModule, M.get(), &ErrorMessage);
271 if (Verbose) std::cerr << "Linked in bytecode file '" << Filename << "'\n";
272 return Result;
John Criswell71478b72003-09-19 20:24:23 +0000273}
274
Misha Brukman5208ba12003-09-30 18:09:32 +0000275/// LinkFiles - takes a module and a list of files and links them all together.
276/// It locates the file either in the current directory, as its absolute
277/// or relative pathname, or as a file somewhere in LLVM_LIB_SEARCH_PATH.
278///
279/// Inputs:
280/// progname - The name of the program (infamous argv[0]).
281/// HeadModule - The module under which all files will be linked.
282/// Files - A vector of C++ strings indicating the LLVM bytecode filenames
283/// to be linked. The names can refer to a mixture of pure LLVM
284/// bytecode files and archive (ar) formatted files.
285/// Verbose - Flags whether verbose output should be printed while linking.
286///
287/// Outputs:
288/// HeadModule - The module will have the specified LLVM bytecode files linked
289/// in.
290///
291/// Return value:
292/// FALSE - No errors.
293/// TRUE - Some error occurred.
294///
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000295bool llvm::LinkFiles(const char *progname, Module *HeadModule,
296 const std::vector<std::string> &Files, bool Verbose) {
John Criswell71478b72003-09-19 20:24:23 +0000297 // String in which to receive error messages.
298 std::string ErrorMessage;
299
300 // Full pathname of the file
301 std::string Pathname;
302
303 // Get the library search path from the environment
304 char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
305
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000306 for (unsigned i = 0; i < Files.size(); ++i) {
John Criswell71478b72003-09-19 20:24:23 +0000307 // Determine where this file lives.
Brian Gaekeee8adb12003-11-11 18:27:37 +0000308 if (FileOpenable(Files[i])) {
John Criswell71478b72003-09-19 20:24:23 +0000309 Pathname = Files[i];
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000310 } else {
311 if (SearchPath == NULL) {
Brian Gaeke608e75c2003-10-08 19:09:30 +0000312 std::cerr << progname << ": Cannot find linker input file '"
313 << Files[i] << "'\n";
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000314 std::cerr << progname
315 << ": Warning: Your LLVM_LIB_SEARCH_PATH is unset.\n";
John Criswell71478b72003-09-19 20:24:23 +0000316 return true;
317 }
318
319 Pathname = std::string(SearchPath)+"/"+Files[i];
Brian Gaekeee8adb12003-11-11 18:27:37 +0000320 if (!FileOpenable(Pathname)) {
Brian Gaeke608e75c2003-10-08 19:09:30 +0000321 std::cerr << progname << ": Cannot find linker input file '"
322 << Files[i] << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000323 return true;
324 }
325 }
326
John Criswell71478b72003-09-19 20:24:23 +0000327 // A user may specify an ar archive without -l, perhaps because it
328 // is not installed as a library. Detect that and link the library.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000329 if (IsArchive(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000330 if (Verbose)
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000331 std::cerr << "Trying to link archive '" << Pathname << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000332
Misha Brukmane6763132003-09-29 22:26:24 +0000333 if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
John Criswell71478b72003-09-19 20:24:23 +0000334 PrintAndReturn(progname, ErrorMessage,
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000335 ": Error linking in archive '" + Pathname + "'");
John Criswell71478b72003-09-19 20:24:23 +0000336 return true;
337 }
Brian Gaekeee8adb12003-11-11 18:27:37 +0000338 } else if (IsBytecode(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000339 if (Verbose)
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000340 std::cerr << "Trying to link bytecode file '" << Pathname << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000341
Misha Brukmane6763132003-09-29 22:26:24 +0000342 if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
John Criswell71478b72003-09-19 20:24:23 +0000343 PrintAndReturn(progname, ErrorMessage,
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000344 ": Error linking in bytecode file '" + Pathname + "'");
John Criswell71478b72003-09-19 20:24:23 +0000345 return true;
346 }
347 }
348 }
349
350 return false;
351}
352
Misha Brukman5208ba12003-09-30 18:09:32 +0000353/// LinkLibraries - takes the specified library files and links them into the
354/// main bytecode object file.
355///
356/// Inputs:
357/// progname - The name of the program (infamous argv[0]).
358/// HeadModule - The module into which all necessary libraries will be linked.
359/// Libraries - The list of libraries to link into the module.
360/// LibPaths - The list of library paths in which to find libraries.
361/// Verbose - Flags whether verbose messages should be printed.
362/// Native - Flags whether native code is being generated.
363///
364/// Outputs:
365/// HeadModule - The module will have all necessary libraries linked in.
366///
367/// Return value:
368/// FALSE - No error.
369/// TRUE - Error.
370///
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000371void llvm::LinkLibraries(const char *progname, Module *HeadModule,
372 const std::vector<std::string> &Libraries,
373 const std::vector<std::string> &LibPaths,
374 bool Verbose, bool Native) {
John Criswell71478b72003-09-19 20:24:23 +0000375 // String in which to receive error messages.
376 std::string ErrorMessage;
377
Brian Gaekef1fce082003-10-21 21:07:12 +0000378 for (unsigned i = 0; i < Libraries.size(); ++i) {
John Criswell71478b72003-09-19 20:24:23 +0000379 // Determine where this library lives.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000380 std::string Pathname = FindLib(Libraries[i], LibPaths);
381 if (Pathname.empty()) {
John Criswell71478b72003-09-19 20:24:23 +0000382 // If the pathname does not exist, then continue to the next one if
383 // we're doing a native link and give an error if we're doing a bytecode
384 // link.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000385 if (!Native) {
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000386 std::cerr << progname << ": WARNING: Cannot find library -l"
387 << Libraries[i] << "\n";
388 continue;
John Criswell71478b72003-09-19 20:24:23 +0000389 }
390 }
391
John Criswell71478b72003-09-19 20:24:23 +0000392 // A user may specify an ar archive without -l, perhaps because it
393 // is not installed as a library. Detect that and link the library.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000394 if (IsArchive(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000395 if (Verbose)
Brian Gaeke2282ae12003-11-16 23:07:13 +0000396 std::cerr << "Trying to link archive '" << Pathname << "' (-l"
397 << Libraries[i] << ")\n";
John Criswell71478b72003-09-19 20:24:23 +0000398
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000399 if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000400 std::cerr << progname << ": " << ErrorMessage
401 << ": Error linking in archive '" << Pathname << "' (-l"
402 << Libraries[i] << ")\n";
403 exit(1);
John Criswell71478b72003-09-19 20:24:23 +0000404 }
Brian Gaekeee8adb12003-11-11 18:27:37 +0000405 } else if (IsBytecode(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000406 if (Verbose)
Brian Gaeke2282ae12003-11-16 23:07:13 +0000407 std::cerr << "Trying to link bytecode file '" << Pathname
408 << "' (-l" << Libraries[i] << ")\n";
John Criswell71478b72003-09-19 20:24:23 +0000409
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000410 if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
Chris Lattner6cc8ca92003-11-28 07:44:09 +0000411 std::cerr << progname << ": " << ErrorMessage
412 << ": error linking in bytecode file '" << Pathname << "' (-l"
413 << Libraries[i] << ")\n";
414 exit(1);
John Criswell71478b72003-09-19 20:24:23 +0000415 }
416 }
417 }
John Criswell71478b72003-09-19 20:24:23 +0000418}