blob: 7e8d655acd2a1a5a51f7f3b66a46f71a2fdc00a6 [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>
John Criswell71478b72003-09-19 20:24:23 +000032
Brian Gaeke3b3640a2003-11-05 22:12:52 +000033/// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
34/// archive. The file named FN must exist.
Misha Brukman5208ba12003-09-30 18:09:32 +000035///
Brian Gaeke3b3640a2003-11-05 22:12:52 +000036static inline bool IsArchive(const std::string &FN) {
37 // Inspect the beginning of the file to see if it contains the "ar" magic
38 // string.
Brian Gaekeee8adb12003-11-11 18:27:37 +000039 std::string Magic("!<arch>\012");
40 char buf[1 + Magic.size()];
Brian Gaeke3b3640a2003-11-05 22:12:52 +000041 std::ifstream f(FN.c_str());
Brian Gaekeee8adb12003-11-11 18:27:37 +000042 f.read(buf, Magic.size());
43 buf[Magic.size()] = '\0';
44 return Magic == buf;
45}
46
47/// IsBytecode - Returns true IFF the file named FN appears to be an
48/// LLVM bytecode file. The file named FN must exist.
49///
50static inline bool IsBytecode(const std::string &FN) {
51 // Inspect the beginning of the file to see if it contains the LLVM
52 // bytecode format magic string.
53 std::string Magic("llvm");
54 char buf[1 + Magic.size()];
55 std::ifstream f(FN.c_str());
56 f.read(buf, Magic.size());
57 buf[Magic.size()] = '\0';
58 return Magic == buf;
John Criswell71478b72003-09-19 20:24:23 +000059}
60
Misha Brukman5208ba12003-09-30 18:09:32 +000061/// FindLib - locates a particular library. It will prepend and append
62/// various directories, prefixes, and suffixes until it can find the library.
63///
64/// Inputs:
65/// Filename - Name of the file to find.
66/// Paths - List of directories to search.
67///
68/// Outputs:
69/// None.
70///
71/// Return value:
72/// The name of the file is returned.
73/// If the file is not found, an empty string is returned.
74///
John Criswell71478b72003-09-19 20:24:23 +000075static std::string
Misha Brukman61087cc2003-09-30 17:51:20 +000076FindLib(const std::string &Filename, const std::vector<std::string> &Paths) {
John Criswell71478b72003-09-19 20:24:23 +000077 // Determine if the pathname can be found as it stands.
Brian Gaekeee8adb12003-11-11 18:27:37 +000078 if (FileOpenable(Filename))
John Criswell71478b72003-09-19 20:24:23 +000079 return Filename;
John Criswell71478b72003-09-19 20:24:23 +000080
John Criswell71478b72003-09-19 20:24:23 +000081 // If that doesn't work, convert the name into a library name.
John Criswell71478b72003-09-19 20:24:23 +000082 std::string LibName = "lib" + Filename;
83
John Criswell71478b72003-09-19 20:24:23 +000084 // Iterate over the directories in Paths to see if we can find the library
85 // there.
Misha Brukman17dc4ce2003-09-29 22:16:43 +000086 for (unsigned Index = 0; Index != Paths.size(); ++Index) {
John Criswell71478b72003-09-19 20:24:23 +000087 std::string Directory = Paths[Index] + "/";
88
Brian Gaekeee8adb12003-11-11 18:27:37 +000089 if (FileOpenable(Directory + LibName + ".bc"))
John Criswell71478b72003-09-19 20:24:23 +000090 return Directory + LibName + ".bc";
John Criswell71478b72003-09-19 20:24:23 +000091
Brian Gaekeee8adb12003-11-11 18:27:37 +000092 if (FileOpenable(Directory + LibName + ".so"))
John Criswell71478b72003-09-19 20:24:23 +000093 return Directory + LibName + ".so";
John Criswell71478b72003-09-19 20:24:23 +000094
Brian Gaekeee8adb12003-11-11 18:27:37 +000095 if (FileOpenable(Directory + LibName + ".a"))
John Criswell71478b72003-09-19 20:24:23 +000096 return Directory + LibName + ".a";
John Criswell71478b72003-09-19 20:24:23 +000097 }
98
John Criswell71478b72003-09-19 20:24:23 +000099 // One last hope: Check LLVM_LIB_SEARCH_PATH.
John Criswell71478b72003-09-19 20:24:23 +0000100 char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
101 if (SearchPath == NULL)
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000102 return std::string();
John Criswell71478b72003-09-19 20:24:23 +0000103
104 LibName = std::string(SearchPath) + "/" + LibName;
Brian Gaekeee8adb12003-11-11 18:27:37 +0000105 if (FileOpenable(LibName))
John Criswell71478b72003-09-19 20:24:23 +0000106 return LibName;
John Criswell71478b72003-09-19 20:24:23 +0000107
108 return std::string();
109}
110
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000111/// GetAllDefinedSymbols - Modifies its parameter DefinedSymbols to contain the
112/// name of each externally-visible symbol defined in M.
Misha Brukman5208ba12003-09-30 18:09:32 +0000113///
Misha Brukman61087cc2003-09-30 17:51:20 +0000114void GetAllDefinedSymbols(Module *M, std::set<std::string> &DefinedSymbols) {
John Criswell71478b72003-09-19 20:24:23 +0000115 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
116 if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage())
117 DefinedSymbols.insert(I->getName());
118 for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
119 if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage())
120 DefinedSymbols.insert(I->getName());
121}
122
Misha Brukman5208ba12003-09-30 18:09:32 +0000123/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
124/// exist in an LLVM module. This is a bit tricky because there may be two
125/// symbols with the same name but different LLVM types that will be resolved to
126/// each other but aren't currently (thus we need to treat it as resolved).
127///
128/// Inputs:
129/// M - The module in which to find undefined symbols.
130///
131/// Outputs:
132/// UndefinedSymbols - A set of C++ strings containing the name of all
133/// undefined symbols.
134///
135/// Return value:
136/// None.
137///
John Criswell71478b72003-09-19 20:24:23 +0000138void
Misha Brukman61087cc2003-09-30 17:51:20 +0000139GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
John Criswell71478b72003-09-19 20:24:23 +0000140 std::set<std::string> DefinedSymbols;
141 UndefinedSymbols.clear(); // Start out empty
142
143 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
144 if (I->hasName()) {
145 if (I->isExternal())
146 UndefinedSymbols.insert(I->getName());
147 else if (!I->hasInternalLinkage())
148 DefinedSymbols.insert(I->getName());
149 }
150 for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
151 if (I->hasName()) {
152 if (I->isExternal())
153 UndefinedSymbols.insert(I->getName());
154 else if (!I->hasInternalLinkage())
155 DefinedSymbols.insert(I->getName());
156 }
157
158 // Prune out any defined symbols from the undefined symbols set...
159 for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
160 I != UndefinedSymbols.end(); )
161 if (DefinedSymbols.count(*I))
162 UndefinedSymbols.erase(I++); // This symbol really is defined!
163 else
164 ++I; // Keep this symbol in the undefined symbols list
165}
166
167
Misha Brukman5208ba12003-09-30 18:09:32 +0000168/// LoadObject - reads the specified bytecode object file.
169///
170/// Inputs:
171/// FN - The name of the file to load.
172///
173/// Outputs:
174/// OutErrorMessage - The error message to give back to the caller.
175///
176/// Return Value:
177/// A pointer to a module represening the bytecode file is returned.
178/// If an error occurs, the pointer is 0.
179///
John Criswell71478b72003-09-19 20:24:23 +0000180std::auto_ptr<Module>
Misha Brukmane6763132003-09-29 22:26:24 +0000181LoadObject(const std::string & FN, std::string &OutErrorMessage) {
John Criswell71478b72003-09-19 20:24:23 +0000182 std::string ErrorMessage;
183 Module *Result = ParseBytecodeFile(FN, &ErrorMessage);
184 if (Result) return std::auto_ptr<Module>(Result);
John Criswell71478b72003-09-19 20:24:23 +0000185 OutErrorMessage = "Bytecode file '" + FN + "' corrupt!";
186 if (ErrorMessage.size()) OutErrorMessage += ": " + ErrorMessage;
187 return std::auto_ptr<Module>();
188}
189
Misha Brukman5208ba12003-09-30 18:09:32 +0000190/// LinkInArchive - opens an archive library and link in all objects which
191/// provide symbols that are currently undefined.
192///
193/// Inputs:
194/// M - The module in which to link the archives.
195/// Filename - The pathname of the archive.
196/// Verbose - Flags whether verbose messages should be printed.
197///
198/// Outputs:
199/// ErrorMessage - A C++ string detailing what error occurred, if any.
200///
201/// Return Value:
202/// TRUE - An error occurred.
203/// FALSE - No errors.
204///
Misha Brukmane6763132003-09-29 22:26:24 +0000205static bool LinkInArchive(Module *M,
206 const std::string &Filename,
207 std::string &ErrorMessage,
208 bool Verbose)
John Criswell71478b72003-09-19 20:24:23 +0000209{
John Criswell71478b72003-09-19 20:24:23 +0000210 // Find all of the symbols currently undefined in the bytecode program.
211 // If all the symbols are defined, the program is complete, and there is
212 // no reason to link in any archive files.
John Criswell71478b72003-09-19 20:24:23 +0000213 std::set<std::string> UndefinedSymbols;
Misha Brukmane6763132003-09-29 22:26:24 +0000214 GetAllUndefinedSymbols(M, UndefinedSymbols);
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000215 if (UndefinedSymbols.empty()) {
John Criswell71478b72003-09-19 20:24:23 +0000216 if (Verbose) std::cerr << " No symbols undefined, don't link library!\n";
217 return false; // No need to link anything in!
218 }
219
John Criswell71478b72003-09-19 20:24:23 +0000220 // Load in the archive objects.
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000221 if (Verbose) std::cerr << " Loading archive file '" << Filename << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000222 std::vector<Module*> Objects;
Misha Brukmane6763132003-09-29 22:26:24 +0000223 if (ReadArchiveFile(Filename, Objects, &ErrorMessage))
John Criswell71478b72003-09-19 20:24:23 +0000224 return true;
John Criswell71478b72003-09-19 20:24:23 +0000225
John Criswell71478b72003-09-19 20:24:23 +0000226 // Figure out which symbols are defined by all of the modules in the archive.
John Criswell71478b72003-09-19 20:24:23 +0000227 std::vector<std::set<std::string> > DefinedSymbols;
Misha Brukmane6763132003-09-29 22:26:24 +0000228 DefinedSymbols.resize(Objects.size());
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000229 for (unsigned i = 0; i != Objects.size(); ++i) {
John Criswell71478b72003-09-19 20:24:23 +0000230 GetAllDefinedSymbols(Objects[i], DefinedSymbols[i]);
231 }
232
233 // While we are linking in object files, loop.
234 bool Linked = true;
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000235 while (Linked) {
John Criswell71478b72003-09-19 20:24:23 +0000236 Linked = false;
237
238 for (unsigned i = 0; i != Objects.size(); ++i) {
239 // Consider whether we need to link in this module... we only need to
240 // link it in if it defines some symbol which is so far undefined.
241 //
242 const std::set<std::string> &DefSymbols = DefinedSymbols[i];
243
244 bool ObjectRequired = false;
245 for (std::set<std::string>::iterator I = UndefinedSymbols.begin(),
246 E = UndefinedSymbols.end(); I != E; ++I)
247 if (DefSymbols.count(*I)) {
248 if (Verbose)
249 std::cerr << " Found object providing symbol '" << *I << "'...\n";
250 ObjectRequired = true;
251 break;
252 }
253
254 // We DO need to link this object into the program...
255 if (ObjectRequired) {
256 if (LinkModules(M, Objects[i], &ErrorMessage))
257 return true; // Couldn't link in the right object file...
258
259 // Since we have linked in this object, delete it from the list of
260 // objects to consider in this archive file.
261 std::swap(Objects[i], Objects.back());
262 std::swap(DefinedSymbols[i], DefinedSymbols.back());
263 Objects.pop_back();
264 DefinedSymbols.pop_back();
265 --i; // Do not skip an entry
266
267 // The undefined symbols set should have shrunk.
268 GetAllUndefinedSymbols(M, UndefinedSymbols);
269 Linked = true; // We have linked something in!
270 }
271 }
272 }
273
274 return false;
275}
276
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000277/// LinkInFile - opens a bytecode file and links in all objects which
Misha Brukman5208ba12003-09-30 18:09:32 +0000278/// provide symbols that are currently undefined.
279///
280/// Inputs:
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000281/// HeadModule - The module in which to link the bytecode file.
282/// Filename - The pathname of the bytecode file.
Misha Brukman5208ba12003-09-30 18:09:32 +0000283/// Verbose - Flags whether verbose messages should be printed.
284///
285/// Outputs:
286/// ErrorMessage - A C++ string detailing what error occurred, if any.
287///
288/// Return Value:
289/// TRUE - An error occurred.
290/// FALSE - No errors.
291///
Misha Brukmane6763132003-09-29 22:26:24 +0000292static bool LinkInFile(Module *HeadModule,
293 const std::string &Filename,
294 std::string &ErrorMessage,
295 bool Verbose)
John Criswell71478b72003-09-19 20:24:23 +0000296{
297 std::auto_ptr<Module> M(LoadObject(Filename, ErrorMessage));
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000298 if (M.get() == 0) return true;
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000299 bool Result = LinkModules(HeadModule, M.get(), &ErrorMessage);
300 if (Verbose) std::cerr << "Linked in bytecode file '" << Filename << "'\n";
301 return Result;
John Criswell71478b72003-09-19 20:24:23 +0000302}
303
Misha Brukman5208ba12003-09-30 18:09:32 +0000304/// LinkFiles - takes a module and a list of files and links them all together.
305/// It locates the file either in the current directory, as its absolute
306/// or relative pathname, or as a file somewhere in LLVM_LIB_SEARCH_PATH.
307///
308/// Inputs:
309/// progname - The name of the program (infamous argv[0]).
310/// HeadModule - The module under which all files will be linked.
311/// Files - A vector of C++ strings indicating the LLVM bytecode filenames
312/// to be linked. The names can refer to a mixture of pure LLVM
313/// bytecode files and archive (ar) formatted files.
314/// Verbose - Flags whether verbose output should be printed while linking.
315///
316/// Outputs:
317/// HeadModule - The module will have the specified LLVM bytecode files linked
318/// in.
319///
320/// Return value:
321/// FALSE - No errors.
322/// TRUE - Some error occurred.
323///
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000324bool LinkFiles(const char *progname,
325 Module *HeadModule,
326 const std::vector<std::string> &Files,
327 bool Verbose)
John Criswell71478b72003-09-19 20:24:23 +0000328{
329 // String in which to receive error messages.
330 std::string ErrorMessage;
331
332 // Full pathname of the file
333 std::string Pathname;
334
335 // Get the library search path from the environment
336 char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
337
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000338 for (unsigned i = 0; i < Files.size(); ++i) {
John Criswell71478b72003-09-19 20:24:23 +0000339 // Determine where this file lives.
Brian Gaekeee8adb12003-11-11 18:27:37 +0000340 if (FileOpenable(Files[i])) {
John Criswell71478b72003-09-19 20:24:23 +0000341 Pathname = Files[i];
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000342 } else {
343 if (SearchPath == NULL) {
Brian Gaeke608e75c2003-10-08 19:09:30 +0000344 std::cerr << progname << ": Cannot find linker input file '"
345 << Files[i] << "'\n";
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000346 std::cerr << progname
347 << ": Warning: Your LLVM_LIB_SEARCH_PATH is unset.\n";
John Criswell71478b72003-09-19 20:24:23 +0000348 return true;
349 }
350
351 Pathname = std::string(SearchPath)+"/"+Files[i];
Brian Gaekeee8adb12003-11-11 18:27:37 +0000352 if (!FileOpenable(Pathname)) {
Brian Gaeke608e75c2003-10-08 19:09:30 +0000353 std::cerr << progname << ": Cannot find linker input file '"
354 << Files[i] << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000355 return true;
356 }
357 }
358
John Criswell71478b72003-09-19 20:24:23 +0000359 // A user may specify an ar archive without -l, perhaps because it
360 // is not installed as a library. Detect that and link the library.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000361 if (IsArchive(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000362 if (Verbose)
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000363 std::cerr << "Trying to link archive '" << Pathname << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000364
Misha Brukmane6763132003-09-29 22:26:24 +0000365 if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
John Criswell71478b72003-09-19 20:24:23 +0000366 PrintAndReturn(progname, ErrorMessage,
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000367 ": Error linking in archive '" + Pathname + "'");
John Criswell71478b72003-09-19 20:24:23 +0000368 return true;
369 }
Brian Gaekeee8adb12003-11-11 18:27:37 +0000370 } else if (IsBytecode(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000371 if (Verbose)
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000372 std::cerr << "Trying to link bytecode file '" << Pathname << "'\n";
John Criswell71478b72003-09-19 20:24:23 +0000373
Misha Brukmane6763132003-09-29 22:26:24 +0000374 if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
John Criswell71478b72003-09-19 20:24:23 +0000375 PrintAndReturn(progname, ErrorMessage,
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000376 ": Error linking in bytecode file '" + Pathname + "'");
John Criswell71478b72003-09-19 20:24:23 +0000377 return true;
378 }
379 }
380 }
381
382 return false;
383}
384
Misha Brukman5208ba12003-09-30 18:09:32 +0000385/// LinkLibraries - takes the specified library files and links them into the
386/// main bytecode object file.
387///
388/// Inputs:
389/// progname - The name of the program (infamous argv[0]).
390/// HeadModule - The module into which all necessary libraries will be linked.
391/// Libraries - The list of libraries to link into the module.
392/// LibPaths - The list of library paths in which to find libraries.
393/// Verbose - Flags whether verbose messages should be printed.
394/// Native - Flags whether native code is being generated.
395///
396/// Outputs:
397/// HeadModule - The module will have all necessary libraries linked in.
398///
399/// Return value:
400/// FALSE - No error.
401/// TRUE - Error.
402///
Misha Brukmane6763132003-09-29 22:26:24 +0000403bool LinkLibraries(const char *progname,
404 Module *HeadModule,
405 const std::vector<std::string> &Libraries,
406 const std::vector<std::string> &LibPaths,
407 bool Verbose,
408 bool Native)
John Criswell71478b72003-09-19 20:24:23 +0000409{
410 // String in which to receive error messages.
411 std::string ErrorMessage;
412
Brian Gaekef1fce082003-10-21 21:07:12 +0000413 for (unsigned i = 0; i < Libraries.size(); ++i) {
John Criswell71478b72003-09-19 20:24:23 +0000414 // Determine where this library lives.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000415 std::string Pathname = FindLib(Libraries[i], LibPaths);
416 if (Pathname.empty()) {
John Criswell71478b72003-09-19 20:24:23 +0000417 // If the pathname does not exist, then continue to the next one if
418 // we're doing a native link and give an error if we're doing a bytecode
419 // link.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000420 if (!Native) {
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000421 PrintAndReturn(progname, "Cannot find library -l" + Libraries[i] + "\n");
John Criswell71478b72003-09-19 20:24:23 +0000422 return true;
423 }
424 }
425
John Criswell71478b72003-09-19 20:24:23 +0000426 // A user may specify an ar archive without -l, perhaps because it
427 // is not installed as a library. Detect that and link the library.
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000428 if (IsArchive(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000429 if (Verbose)
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000430 std::cerr << "Trying to link archive '" << Pathname << "' (-l" << Libraries[i] << ")\n";
John Criswell71478b72003-09-19 20:24:23 +0000431
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000432 if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
John Criswell71478b72003-09-19 20:24:23 +0000433 PrintAndReturn(progname, ErrorMessage,
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000434 ": Error linking in archive '" + Pathname + "' (-l" + Libraries[i] + ")");
John Criswell71478b72003-09-19 20:24:23 +0000435 return true;
436 }
Brian Gaekeee8adb12003-11-11 18:27:37 +0000437 } else if (IsBytecode(Pathname)) {
John Criswell71478b72003-09-19 20:24:23 +0000438 if (Verbose)
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000439 std::cerr << "Trying to link bytecode file '" << Pathname << "' (-l" << Libraries[i] << ")\n";
John Criswell71478b72003-09-19 20:24:23 +0000440
Misha Brukman17dc4ce2003-09-29 22:16:43 +0000441 if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
John Criswell71478b72003-09-19 20:24:23 +0000442 PrintAndReturn(progname, ErrorMessage,
Brian Gaeke3b3640a2003-11-05 22:12:52 +0000443 ": error linking in bytecode file '" + Pathname + "' (-l" + Libraries[i] + ")");
John Criswell71478b72003-09-19 20:24:23 +0000444 return true;
445 }
446 }
447 }
448
449 return false;
450}