Mercurial > projects > ldc
comparison gen/linker.cpp @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | a60e7d1ce3ee |
children |
comparison
equal
deleted
inserted
replaced
1649:36da40ecbbe0 | 1650:40bd4a0d4870 |
---|---|
104 if (!errstr.empty()) | 104 if (!errstr.empty()) |
105 { | 105 { |
106 error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); | 106 error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); |
107 fatal(); | 107 fatal(); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 // strip debug info | 111 // strip debug info |
112 if (!global.params.symdebug) | 112 if (!global.params.symdebug) |
113 args.push_back("-strip-debug"); | 113 args.push_back("-strip-debug"); |
114 | 114 |
220 std::string errstr; | 220 std::string errstr; |
221 | 221 |
222 // find gcc for linking | 222 // find gcc for linking |
223 llvm::sys::Path gcc = getGcc(); | 223 llvm::sys::Path gcc = getGcc(); |
224 // get a string version for argv[0] | 224 // get a string version for argv[0] |
225 std::string gccStr = gcc.toString(); | 225 const char* gccStr = gcc.c_str(); |
226 | 226 |
227 // build arguments | 227 // build arguments |
228 std::vector<const char*> args; | 228 std::vector<const char*> args; |
229 | 229 |
230 // first the program name ?? | 230 // first the program name ?? |
231 args.push_back(gccStr.c_str()); | 231 args.push_back(gccStr); |
232 | 232 |
233 // object files | 233 // object files |
234 for (int i = 0; i < global.params.objfiles->dim; i++) | 234 for (int i = 0; i < global.params.objfiles->dim; i++) |
235 { | 235 { |
236 char *p = (char *)global.params.objfiles->data[i]; | 236 char *p = (char *)global.params.objfiles->data[i]; |
272 if (!errstr.empty()) | 272 if (!errstr.empty()) |
273 { | 273 { |
274 error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); | 274 error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); |
275 fatal(); | 275 fatal(); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 // additional linker switches | 279 // additional linker switches |
280 for (int i = 0; i < global.params.linkswitches->dim; i++) | 280 for (int i = 0; i < global.params.linkswitches->dim; i++) |
281 { | 281 { |
282 char *p = (char *)global.params.linkswitches->data[i]; | 282 char *p = (char *)global.params.linkswitches->data[i]; |
290 args.push_back(p); | 290 args.push_back(p); |
291 } | 291 } |
292 | 292 |
293 // default libs | 293 // default libs |
294 switch(global.params.os) { | 294 switch(global.params.os) { |
295 case OSLinux: | 295 case OSLinux: |
296 case OSMacOSX: | 296 case OSMacOSX: |
297 args.push_back("-ldl"); | 297 args.push_back("-ldl"); |
298 // fallthrough | 298 // fallthrough |
299 case OSFreeBSD: | 299 case OSFreeBSD: |
300 args.push_back("-lpthread"); | 300 args.push_back("-lpthread"); |
328 printf("\n"); | 328 printf("\n"); |
329 fflush(stdout); | 329 fflush(stdout); |
330 } | 330 } |
331 | 331 |
332 Logger::println("Linking with: "); | 332 Logger::println("Linking with: "); |
333 std::vector<const char*>::const_iterator I = args.begin(), E = args.end(); | 333 std::vector<const char*>::const_iterator I = args.begin(), E = args.end(); |
334 Stream logstr = Logger::cout(); | 334 Stream logstr = Logger::cout(); |
335 for (; I != E; ++I) | 335 for (; I != E; ++I) |
336 if (*I) | 336 if (*I) |
337 logstr << "'" << *I << "'" << " "; | 337 logstr << "'" << *I << "'" << " "; |
338 logstr << "\n" << std::flush; | 338 logstr << "\n"; // FIXME where's flush ? |
339 | 339 |
340 | 340 |
341 // terminate args list | 341 // terminate args list |
342 args.push_back(NULL); | 342 args.push_back(NULL); |
343 | 343 |
347 error("linking failed:\nstatus: %d", status); | 347 error("linking failed:\nstatus: %d", status); |
348 if (!errstr.empty()) | 348 if (!errstr.empty()) |
349 error("message: %s", errstr.c_str()); | 349 error("message: %s", errstr.c_str()); |
350 return status; | 350 return status; |
351 } | 351 } |
352 | 352 |
353 return 0; | 353 return 0; |
354 } | 354 } |
355 | 355 |
356 ////////////////////////////////////////////////////////////////////////////// | 356 ////////////////////////////////////////////////////////////////////////////// |
357 | 357 |
373 assert(gExePath.isValid()); | 373 assert(gExePath.isValid()); |
374 | 374 |
375 // build arguments | 375 // build arguments |
376 std::vector<const char*> args; | 376 std::vector<const char*> args; |
377 // args[0] should be the name of the executable | 377 // args[0] should be the name of the executable |
378 args.push_back(gExePath.toString().c_str()); | 378 args.push_back(gExePath.c_str()); |
379 // Skip first argument to -run; it's a D source file. | 379 // Skip first argument to -run; it's a D source file. |
380 for (size_t i = 1, length = opts::runargs.size(); i < length; i++) | 380 for (size_t i = 1, length = opts::runargs.size(); i < length; i++) |
381 { | 381 { |
382 args.push_back(opts::runargs[i].c_str()); | 382 args.push_back(opts::runargs[i].c_str()); |
383 } | 383 } |