- Timestamp:
- Aug 5, 2018, 4:11:41 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 28582b2
- Parents:
- 4dcaed2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/cfa.cc
r4dcaed2 r37fe352 21 21 #include <string.h> // strcmp 22 22 23 #include <sys/types.h> 24 #include <sys/stat.h> 25 23 26 #include "Common/SemanticError.h" 24 27 #include "config.h" // configure info … … 66 69 } // shuffle 67 70 71 static inline bool dirExists(const string & path) { 72 struct stat info; 73 if(stat( path.c_str(), &info ) != 0) 74 return false; 75 else if(info.st_mode & S_IFDIR) 76 return true; 77 else 78 return false; 79 } //dirExists 80 68 81 69 82 #define str(s) #s … … 96 109 bool xflag = false; // user supplied -x flag 97 110 bool debugging __attribute(( unused )) = false; // -g flag 111 bool m32 = false; // -m32 flag 112 bool m64 = false; // -m64 flag 113 bool intree = false; 98 114 99 115 const char *args[argc + 100]; // cfa command line values, plus some space for additional flags … … 154 170 } else if ( arg == "-no-include-stdhdr" ) { 155 171 noincstd_flag = true; // strip the no-include-stdhdr flag 172 } else if ( arg == "-in-tree" ) { 173 noincstd_flag = true; 174 intree = true; 156 175 } else if ( arg == "-compiler" ) { 157 176 // use the user specified compiler … … 258 277 libs[nlibs] = argv[i]; 259 278 nlibs += 1; 279 } else if ( arg == "-m32" ) { 280 m32 = true; 281 m64 = false; 282 args[nargs] = argv[i]; 283 nargs += 1; 284 } else if ( arg == "-m64" ) { 285 m64 = true; 286 m32 = false; 287 args[nargs] = argv[i]; 288 nargs += 1; 260 289 } else { 261 290 // concatenate any other arguments … … 320 349 nargs += 1; 321 350 351 string libdir; 352 if( !intree ) { 353 const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU); 354 const char * config = debug ? "debug": "nodebug"; 355 libdir = string(CFA_LIBDIR) + arch + config; 356 if( !dirExists(libdir) ) { 357 cerr << argv[0] << " internal error, cannot find prelude directory." << endl; 358 cerr << "Was looking for " << libdir << endl; 359 libdir = string(CFA_LIBDIR) + arch + "nolib"; 360 } 361 362 if( !dirExists(libdir) ) { 363 cerr << argv[0] << " internal error, cannot find prelude directory." << endl; 364 cerr << "Was looking for " << libdir << endl; 365 exit( EXIT_FAILURE ); 366 } 367 368 args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir) ).c_str(); 369 nargs += 1; 370 } else { 371 args[nargs] = "-D__CFA_FLAG__=-t"; 372 nargs += 1; 373 } 374 322 375 if ( link ) { 323 376 args[nargs] = "-Xlinker"; … … 335 388 336 389 // include the cfa library in case it's needed 337 args[nargs] = "-L" CFA_LIBDIR; 338 nargs += 1; 339 if ( debug ) { 340 args[nargs] = "-lcfa-d"; 341 } else { 342 args[nargs] = "-lcfa"; 343 } // if 390 if( !intree ) { 391 args[nargs] = ( *new string( string("-L" ) + libdir) ).c_str(); 392 nargs += 1; 393 } 394 args[nargs] = "-lcfa"; 344 395 nargs += 1; 345 396 args[nargs] = "-lpthread"; … … 400 451 } // if 401 452 402 403 404 405 453 args[nargs] = "-Xlinker"; // used by backtrace 454 nargs += 1; 455 args[nargs] = "-export-dynamic"; 456 nargs += 1; 406 457 407 458 // execute the compilation command
Note: See TracChangeset
for help on using the changeset viewer.