Changeset c2051e10 for driver/cfa.cc
- Timestamp:
- Sep 10, 2019, 2:48:01 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- 81e60f7
- Parents:
- 17bc05b (diff), 216597d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
driver/cfa.cc (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/cfa.cc
r17bc05b rc2051e10 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 10 08:44:15201913 // Update Count : 31112 // Last Modified On : Mon Sep 9 17:57:40 2019 13 // Update Count : 417 14 14 // 15 15 … … 28 28 #include "config.h" // configure info 29 29 30 31 30 using std::cerr; 32 31 using std::endl; … … 34 33 using std::to_string; 35 34 36 37 35 //#define __DEBUG_H__ 38 36 39 37 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "N__=" suffix 38 39 void Putenv( char * argv[], string arg ) { 40 // environment variables must have unique names 41 static int flags = 0; 42 43 if ( putenv( (char *)( *new string( string( __CFA_FLAGPREFIX__ + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) { 44 cerr << argv[0] << " error, cannot set environment variable." << endl; 45 exit( EXIT_FAILURE ); 46 } // if 47 } // Putenv 48 49 // check if string has prefix 40 50 bool prefix( const string & arg, const string & pre ) { 41 51 return arg.substr( 0, pre.size() ) == pre; … … 47 57 } 48 58 49 bool suffix( const string & arg ) { 50 static const string suffixes[] = { ".cfa", ".hfa", ".cfa.ii" }; 51 for(const auto sfix : suffixes) { 52 if(arg.size() <= sfix.size()) continue; 53 size_t pos = arg.find_last_of(sfix); 54 size_t exp = (arg.size() - 1); 55 if(pos == exp) return true; 56 } 57 return false; 59 bool suffix( const string & arg ) { // check if string has suffix 60 enum { NumSuffixes = 3 }; 61 static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" }; 62 63 size_t dot = arg.find_last_of( "." ); 64 if ( dot == string::npos ) return false; 65 const string * end = suffixes + NumSuffixes; 66 return std::find( suffixes, end, arg.substr( dot + 1 ) ) != end; 58 67 } // suffix 59 68 60 69 61 void shuffle( const char * args[], int S, int E, int N ) { 62 // S & E index 1 passed the end so adjust with -1 63 #ifdef __DEBUG_H__ 64 cerr << "shuffle:" << S << " " << E << " " << N << endl; 65 #endif // __DEBUG_H__ 66 for ( int j = E-1 + N; j > S-1 + N; j -=1 ) { 67 #ifdef __DEBUG_H__ 68 cerr << "\t" << j << " " << j-N << endl; 69 #endif // __DEBUG_H__ 70 args[j] = args[j-N]; 71 } // for 72 } // shuffle 73 74 static inline bool dirExists( const string & path ) { 70 static inline bool dirExists( const string & path ) { // check if directory exists 75 71 struct stat info; 76 if(stat( path.c_str(), &info ) != 0) 77 return false; 78 else if(info.st_mode & S_IFDIR) 79 return true; 80 else 81 return false; 82 } //dirExists 72 if ( stat( path.c_str(), &info ) != 0 ) return false; 73 return (info.st_mode & S_IFDIR) != 0; 74 } // dirExists 83 75 84 76 static inline string dir(const string & path) { … … 87 79 88 80 81 #define xstr(s) str(s) 89 82 #define str(s) #s 90 83 91 84 int main( int argc, char * argv[] ) { 92 85 string Version( CFA_VERSION_LONG ); // current version number from CONFIG 93 string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch(str( CFA_VERSION_PATCH ) );86 string Major( xstr( CFA_VERSION_MAJOR ) ), Minor( xstr( CFA_VERSION_MINOR ) ), Patch( xstr( CFA_VERSION_PATCH ) ); 94 87 95 88 string installincdir( CFA_INCDIR ); // fixed location of include files … … 99 92 string heading; // banner printed at start of cfa compilation 100 93 string arg; // current command-line argument during command-line parsing 101 string Bprefix; // path where gcc looks for compiler commandsteps94 string bprefix; // path where gcc looks for compiler steps 102 95 string langstd; // language standard 103 96 … … 106 99 107 100 bool x_flag = false; // -x flag 108 bool nonoptarg = false; // indicates non-option argument specified109 bool link = true; // link ing as well as compiling101 bool nonoptarg = false; // no non-option arguments specified, i.e., no file names 102 bool link = true; // link stage occurring 110 103 bool verbose = false; // -v flag 111 104 bool quiet = false; // -quiet flag … … 120 113 bool m32 = false; // -m32 flag 121 114 bool m64 = false; // -m64 flag 122 bool intree = false; 115 bool intree = false; // build in tree 123 116 bool compiling_libs = false; 124 117 bool disttree = false; 118 int o_file = 0; // -o filename position 125 119 126 120 const char *args[argc + 100]; // cfa command line values, plus some space for additional flags … … 146 140 147 141 if ( arg == "-Xlinker" || arg == "-o" ) { 148 args[nargs] = argv[i]; // pass the argument along 149 nargs += 1; 142 args[nargs++] = argv[i]; // pass argument along 150 143 i += 1; 151 144 if ( i == argc ) continue; // next argument available ? 152 args[nargs ] = argv[i]; // pass theargument along153 nargs += 1;145 args[nargs++] = argv[i]; // pass argument along 146 if ( arg == "-o" ) o_file = i; // remember file 154 147 } else if ( arg == "-XCFA" ) { // CFA pass through 155 148 i += 1; 156 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + argv[i] ) ).c_str(); 157 nargs += 1; 149 Putenv( argv, argv[i] ); 158 150 159 151 // CFA specific arguments … … 162 154 CFA_flag = true; // strip the -CFA flag 163 155 link = false; 164 args[nargs] = "-E"; // replace the argument with -E 165 nargs += 1; 156 args[nargs++] = "-fsyntax-only"; // stop after stage 2 166 157 } else if ( arg == "-debug" ) { 167 158 debug = true; // strip the debug flag 168 159 } else if ( arg == "-nodebug" ) { 169 debug = false; // strip the debug flag160 debug = false; // strip the nodebug flag 170 161 } else if ( arg == "-nolib" ) { 171 162 nolib = true; // strip the nodebug flag … … 191 182 if ( i == argc ) continue; // next argument available ? 192 183 compiler_path = argv[i]; 193 if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) { 194 cerr << argv[0] << " error, cannot set environment variable." << endl; 195 exit( EXIT_FAILURE ); 196 } // if 184 Putenv( argv, arg + "=" + argv[i] ); 197 185 198 186 // C specific arguments … … 200 188 } else if ( arg == "-v" ) { 201 189 verbose = true; // verbosity required 202 args[nargs] = argv[i]; // pass the argument along 203 nargs += 1; 190 args[nargs++] = argv[i]; // pass argument along 204 191 } else if ( arg == "-g" ) { 205 192 debugging = true; // symbolic debugging required 206 args[nargs] = argv[i]; // pass the argument along 207 nargs += 1; 193 args[nargs++] = argv[i]; // pass argument along 194 } else if ( arg == "-save-temps" ) { 195 args[nargs++] = argv[i]; // pass argument along 196 Putenv( argv, arg ); // save cfa-cpp output 208 197 } else if ( prefix( arg, "-x" ) ) { // file suffix ? 209 198 string lang; 210 args[nargs] = argv[i]; // pass the argument along 211 nargs += 1; 199 args[nargs++] = argv[i]; // pass argument along 212 200 if ( arg.length() == 2 ) { // separate argument ? 213 201 i += 1; 214 202 if ( i == argc ) continue; // next argument available ? 215 203 lang = argv[i]; 216 args[nargs] = argv[i]; // pass the argument along 217 nargs += 1; 204 args[nargs++] = argv[i]; // pass argument along 218 205 } else { 219 206 lang = arg.substr( 2 ); … … 222 209 } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) { 223 210 std_flag = true; // -std=XX provided 224 args[nargs] = argv[i]; // pass the argument along 225 nargs += 1; 211 args[nargs++] = argv[i]; // pass argument along 226 212 } else if ( arg == "-w" ) { 227 args[nargs] = argv[i]; // pass the argument along 228 nargs += 1; 229 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp 230 nargs += 1; 213 args[nargs++] = argv[i]; // pass argument along 214 Putenv( argv, arg ); 231 215 } else if ( prefix( arg, "-W" ) ) { // check before next tests 232 216 if ( arg == "-Werror" || arg == "-Wall" ) { 233 args[nargs] = argv[i]; // pass the argument along 234 nargs += 1; 235 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp 236 nargs += 1; 217 args[nargs++] = argv[i]; // pass argument along 218 Putenv( argv, argv[i] ); 237 219 } else { 238 220 unsigned int adv = prefix( arg, "-Wno-" ) ? 5 : 2; 239 args[nargs] = argv[i]; // conditionally pass theargument along240 const char * warning = argv[i] + adv; // extract warning221 args[nargs] = argv[i]; // conditionally pass argument along 222 const char * warning = argv[i] + adv; // extract warning 241 223 if ( SemanticWarning_Exist( warning ) ) { // replace the argument for cfa-cpp 242 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str();224 Putenv( argv, arg ); 243 225 } // if 244 226 nargs += 1; 245 227 } // if 246 228 } else if ( prefix( arg, "-B" ) ) { 247 Bprefix = arg.substr(2); // strip the -B flag 248 args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); 249 nargs += 1; 250 } else if ( prefix( arg, "-b" ) ) { 251 if ( arg.length() == 2 ) { // separate argument ? 252 i += 1; 253 if ( i == argc ) continue; // next argument available ? 254 arg += argv[i]; // concatenate argument 255 } // if 256 // later versions of gcc require the -b option to appear at the start of the command line 257 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list 258 args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along 259 if ( putenv( (char *)( *new string( string( "__GCC_MACHINE__=" ) + arg ) ).c_str() ) != 0 ) { 260 cerr << argv[0] << " error, cannot set environment variable." << endl; 261 exit( EXIT_FAILURE ); 262 } // if 263 sargs += 1; 264 nargs += 1; 265 } else if ( prefix( arg, "-V" ) ) { 266 if ( arg.length() == 2 ) { // separate argument ? 267 i += 1; 268 if ( i == argc ) continue; // next argument available ? 269 arg += argv[i]; // concatenate argument 270 } // if 271 // later versions of gcc require the -V option to appear at the start of the command line 272 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list 273 args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along 274 if ( putenv( (char *)( *new string( string( "__GCC_VERSION__=" ) + arg ) ).c_str() ) != 0 ) { 275 cerr << argv[0] << " error, cannot set environment variable." << endl; 276 exit( EXIT_FAILURE ); 277 } // if 278 sargs += 1; 279 nargs += 1; 229 bprefix = arg.substr(2); // strip the -B flag 280 230 } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) { 281 args[nargs] = argv[i]; // pass the argument along 282 nargs += 1; 231 args[nargs++] = argv[i]; // pass argument along 283 232 if ( arg == "-E" || arg == "-M" || arg == "-MM" ) { 284 233 cpp_flag = true; // cpp only … … 287 236 } else if ( arg[1] == 'l' ) { 288 237 // if the user specifies a library, load it after user code 289 libs[nlibs] = argv[i]; 290 nlibs += 1; 238 libs[nlibs++] = argv[i]; 291 239 } else if ( arg == "-m32" ) { 292 240 m32 = true; 293 241 m64 = false; 294 args[nargs] = argv[i]; 295 nargs += 1; 242 args[nargs++] = argv[i]; 296 243 } else if ( arg == "-m64" ) { 297 244 m64 = true; 298 245 m32 = false; 299 args[nargs] = argv[i]; 300 nargs += 1; 246 args[nargs++] = argv[i]; 301 247 } else { 302 248 // concatenate any other arguments 303 args[nargs] = argv[i]; 304 nargs += 1; 249 args[nargs++] = argv[i]; 305 250 } // if 306 251 } else { 307 252 bool cfa = suffix( arg ); // check suffix 308 253 if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ? 309 args[nargs] = "-x"; 310 nargs += 1; 311 args[nargs] = "c"; 312 nargs += 1; 254 args[nargs++] = "-x"; 255 args[nargs++] = "c"; 313 256 } // if 314 args[nargs] = argv[i]; // concatenate file 315 nargs += 1; 257 args[nargs++] = argv[i]; // concatenate files 316 258 if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ? 317 args[nargs] = "-x"; 318 nargs += 1; 319 args[nargs] = "none"; 320 nargs += 1; 259 args[nargs++] = "-x"; 260 args[nargs++] = "none"; 321 261 } // if 322 262 nonoptarg = true; … … 325 265 326 266 #ifdef __x86_64__ 327 args[nargs] = "-mcx16"; // allow double-wide CAA 328 nargs += 1; 267 args[nargs++] = "-mcx16"; // allow double-wide CAA 329 268 #endif // __x86_64__ 330 269 … … 337 276 #endif // __DEBUG_H__ 338 277 278 // -E flag stops at cc1 stage 1, so cfa-cpp in cc1 stage 2 is never executed. 339 279 if ( cpp_flag && CFA_flag ) { 340 280 cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl; … … 343 283 344 284 // add the CFA include-library paths, which allow direct access to header files without directory qualification 345 if( !intree ) { 346 args[nargs] = "-I" CFA_INCDIR; 347 nargs += 1; 285 if ( ! intree ) { 286 args[nargs++] = "-I" CFA_INCDIR; 348 287 if ( ! noincstd_flag ) { // do not use during build 349 args[nargs] = "-I" CFA_INCDIR "stdhdr"; 350 nargs += 1; 351 } // if 352 args[nargs] = "-I" CFA_INCDIR "concurrency"; 353 nargs += 1; 354 args[nargs] = "-I" CFA_INCDIR "containers"; 355 nargs += 1; 356 } else { 357 args[nargs] = "-I" TOP_SRCDIR "libcfa/src"; 358 nargs += 1; 288 args[nargs++] = "-I" CFA_INCDIR "stdhdr"; 289 } // if 290 args[nargs++] = "-I" CFA_INCDIR "concurrency"; 291 args[nargs++] = "-I" CFA_INCDIR "containers"; 292 } else { 293 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src"; 359 294 if ( ! noincstd_flag ) { // do not use during build 360 args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr"; 361 nargs += 1; 362 } // if 363 args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency"; 364 nargs += 1; 365 args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers"; 366 nargs += 1; 367 } 295 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr"; 296 } // if 297 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency"; 298 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/containers"; 299 } // if 368 300 369 301 // add stdbool to get defines for bool/true/false 370 args[nargs] = "-imacros"; 371 nargs += 1; 372 args[nargs] = "stdbool.h"; 373 nargs += 1; 302 args[nargs++] = "-imacros"; 303 args[nargs++] = "stdbool.h"; 374 304 375 305 string libbase; 376 if ( !intree ) {306 if ( ! intree ) { 377 307 libbase = CFA_LIBDIR; 378 308 } else { 379 309 libbase = TOP_BUILDDIR "libcfa/"; 380 } 310 } // if 381 311 382 312 if( compiling_libs ) { 383 args[nargs] = "-D__CFA_FLAG__=-t"; 384 nargs += 1; 385 } 386 387 string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU); 313 Putenv( argv, "-t" ); 314 } // if 315 316 string arch( m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU) ); 388 317 if ( ! m32 && ! m64 ) { 389 318 if ( arch == "x86" ) { 390 args[nargs] = "-m32"; 391 nargs += 1; 319 args[nargs++] = "-m32"; 392 320 } else if ( arch == "x64" ) { 393 args[nargs] = "-m64"; 394 nargs += 1; 321 args[nargs++] = "-m64"; 395 322 } // if 396 323 } // if 324 397 325 const char * config = nolib ? "nolib" : (debug ? "debug": "nodebug"); 398 326 string libdir = libbase + arch + "-" + config; … … 417 345 418 346 if(disttree) { 419 args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + dir(argv[0])) ).c_str();347 Putenv( argv, "--prelude-dir=" + dir(argv[0])) ); 420 348 } else if(intree) { 421 args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + "/prelude") ).c_str();422 } else { 423 args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir) ).c_str();349 Putenv( argv, "--prelude-dir=" + libdir + "/prelude") ); 350 } else { 351 Putenv( argv, "--prelude-dir=" + libdir) ); 424 352 } 425 353 nargs += 1; 426 427 354 for ( int i = 0; i < nlibs; i += 1 ) { // copy non-user libraries after all user libraries 428 args[nargs] = libs[i]; 429 nargs += 1; 355 args[nargs++] = libs[i]; 430 356 } // for 431 357 432 358 if ( link ) { 433 args[nargs] = "-Xlinker"; 434 nargs += 1; 435 args[nargs] = "--undefined=__cfaabi_dbg_bits_write"; 436 nargs += 1; 437 args[nargs] = "-Xlinker"; 438 nargs += 1; 439 args[nargs] = "--undefined=__cfaabi_interpose_startup"; 440 nargs += 1; 441 args[nargs] = "-Xlinker"; 442 nargs += 1; 443 args[nargs] = "--undefined=__cfaabi_appready_startup"; 444 nargs += 1; 445 446 // include the cfa library in case it's needed 447 args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str(); 448 nargs += 1; 449 args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str(); 450 nargs += 1; 451 args[nargs] = "-Wl,--push-state,--as-needed"; 452 nargs += 1; 453 args[nargs] = "-lcfathread"; 454 nargs += 1; 455 args[nargs] = "-Wl,--pop-state"; 456 nargs += 1; 457 args[nargs] = "-lcfa"; 458 nargs += 1; 459 args[nargs] = "-lpthread"; 460 nargs += 1; 461 args[nargs] = "-ldl"; 462 nargs += 1; 463 args[nargs] = "-lrt"; 464 nargs += 1; 465 args[nargs] = "-lm"; 466 nargs += 1; 467 } // if 468 469 // Add exception flags (unconditionally) 470 args[nargs] = "-fexceptions"; 471 nargs += 1; 472 473 // add the correct set of flags based on the type of compile this is 474 475 args[nargs] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str(); 476 nargs += 1; 477 args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str(); 478 nargs += 1; 479 args[nargs] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str(); 480 nargs += 1; 481 args[nargs] = "-D__CFA__"; 482 nargs += 1; 483 args[nargs] = "-D__CFORALL__"; 484 nargs += 1; 485 args[nargs] = "-D__cforall"; 486 nargs += 1; 359 args[nargs++] = "-Xlinker"; 360 args[nargs++] = "--undefined=__cfaabi_dbg_bits_write"; 361 args[nargs++] = "-Xlinker"; 362 args[nargs++] = "--undefined=__cfaabi_interpose_startup"; 363 args[nargs++] = "-Xlinker"; 364 args[nargs++] = "--undefined=__cfaabi_appready_startup"; 365 366 // include the cfa library in case it is needed 367 args[nargs++] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str(); 368 args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str(); 369 args[nargs++] = "-Wl,--push-state,--as-needed"; 370 args[nargs++] = "-lcfathread"; 371 args[nargs++] = "-Wl,--pop-state"; 372 args[nargs++] = "-lcfa"; 373 args[nargs++] = "-lpthread"; 374 args[nargs++] = "-ldl"; 375 args[nargs++] = "-lrt"; 376 args[nargs++] = "-lm"; 377 } // if 378 379 args[nargs++] = "-fexceptions"; // add exception flags (unconditionally) 380 381 // add flags based on the type of compile 382 383 args[nargs++] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str(); 384 args[nargs++] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str(); 385 args[nargs++] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str(); 386 args[nargs++] = "-D__CFA__"; 387 args[nargs++] = "-D__CFORALL__"; 388 args[nargs++] = "-D__cforall"; 487 389 488 390 if ( cpp_flag ) { 489 args[nargs] = "-D__CPP__"; 490 nargs += 1; 491 } // if 492 493 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list 494 nargs += 1; 391 args[nargs++] = "-D__CPP__"; 392 } // if 393 495 394 if ( CFA_flag ) { 496 args[sargs] = "-D__CFA_FLAG__=-N"; 497 args[nargs] = "-D__CFA_PREPROCESS_"; 498 nargs += 1; 499 } else { 500 args[sargs] = "-D__CFA_FLAG__=-L"; 501 } // if 502 sargs += 1; 395 Putenv( argv, "-N" ); 396 Putenv( argv, "-CFA" ); 397 // -CFA implies cc1 stage 2, but gcc does not pass the -o file to this stage because it believe the file is for 398 // the linker. Hence, the -o file is explicit passed to cc1 stage 2 and used as cfa-cpp's output file. 399 if ( o_file ) Putenv( argv, string( "-o=" ) + argv[o_file] ); 400 } else { 401 Putenv( argv, "-L" ); 402 } // if 403 404 Putenv( argv, "--prelude-dir=" + libdir + (intree ? "/prelude" : "") ); 503 405 504 406 if ( debug ) { 505 407 heading += " (debug)"; 506 args[nargs] = "-D__CFA_DEBUG__"; 507 nargs += 1; 408 args[nargs++] = "-D__CFA_DEBUG__"; 508 409 } else { 509 410 heading += " (no debug)"; 510 411 } // if 511 412 512 if ( Bprefix.length() == 0 ) {413 if ( bprefix.length() == 0 ) { 513 414 if(disttree) { 514 Bprefix = dir(argv[0]);415 bprefix = dir(argv[0]); 515 416 } else if(intree) { 516 Bprefix = srcdriverdir;417 bprefix = srcdriverdir; 517 418 } else { 518 Bprefix = installlibdir;419 bprefix = installlibdir; 519 420 } 520 521 if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/'; 522 args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); 523 nargs += 1; 524 } // if 525 526 args[nargs] = "-Xlinker"; // used by backtrace 527 nargs += 1; 528 args[nargs] = "-export-dynamic"; 529 nargs += 1; 421 if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/'; 422 Putenv( argv, ( *new string( string("-B=") + bprefix ) ).c_str() ); 423 } // if 424 425 args[nargs++] = "-Xlinker"; // used by backtrace 426 args[nargs++] = "-export-dynamic"; 530 427 531 428 // execute the compilation command … … 541 438 542 439 if ( prefix( compiler_name, "gcc" ) ) { // allow suffix on gcc name 543 args[nargs] = "-no-integrated-cpp"; 544 nargs += 1; 545 args[nargs] = "-Wno-deprecated"; 546 nargs += 1; 547 #ifdef HAVE_CAST_FUNCTION_TYPE 548 args[nargs] = "-Wno-cast-function-type"; 549 nargs += 1; 550 #endif // HAVE_CAST_FUNCTION_TYPE 440 args[nargs++] = "-no-integrated-cpp"; 441 args[nargs++] = "-Wno-deprecated"; 442 #ifdef HAVE_CAST_FUNCTION_TYPE 443 args[nargs++] = "-Wno-cast-function-type"; 444 #endif // HAVE_CAST_FUNCTION_TYPE 551 445 if ( ! std_flag ) { // default c11, if none specified 552 args[nargs] = "-std=gnu11"; 553 nargs += 1; 554 } // if 555 args[nargs] = "-fgnu89-inline"; 556 nargs += 1; 557 args[nargs] = "-D__int8_t_defined"; // prevent gcc type-size attributes 558 nargs += 1; 559 args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str(); 560 nargs += 1; 446 args[nargs++] = "-std=gnu11"; 447 } // if 448 args[nargs++] = "-fgnu89-inline"; 449 args[nargs++] = "-D__int8_t_defined"; // prevent gcc type-size attributes 450 args[nargs++] = ( *new string( string("-B") + bprefix ) ).c_str(); 561 451 } else { 562 452 cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl; … … 564 454 } // if 565 455 566 args[nargs] = NULL; // terminate with NULL456 args[nargs] = nullptr; // terminate 567 457 568 458 #ifdef __DEBUG_H__ 569 459 cerr << "nargs: " << nargs << endl; 570 460 cerr << "args:" << endl; 571 for ( int i = 0; args[i] != NULL; i += 1 ) {572 cerr << " \"" << args[i] << "\" ";461 for ( int i = 0; args[i] != nullptr; i += 1 ) { 462 cerr << " \"" << args[i] << "\"" << endl; 573 463 } // for 574 464 cerr << endl; … … 591 481 if ( argc == 2 ) exit( EXIT_SUCCESS ); // if only the -v flag is specified, do not invoke gcc 592 482 593 for ( int i = 0; args[i] != NULL; i += 1 ) {483 for ( int i = 0; args[i] != nullptr; i += 1 ) { 594 484 cerr << args[i] << " "; 595 485 } // for … … 605 495 606 496 execvp( args[0], (char *const *)args ); // should not return 607 perror( "CFA Translator error: cfa level,execvp" );497 perror( "CFA Translator error: execvp" ); 608 498 exit( EXIT_FAILURE ); 609 499 } // main
Note:
See TracChangeset
for help on using the changeset viewer.