Changeset 3d5701e for driver/cc1.cc
- Timestamp:
 - Feb 25, 2020, 1:17:33 PM (6 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
 - Children:
 - 7dc2e015
 - Parents:
 - 9fb8f01 (diff), dd9e1ca (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/cc1.cc (modified) (17 diffs)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
driver/cc1.cc
r9fb8f01 r3d5701e 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 23 15:06:27201913 // Update Count : 3 7112 // Last Modified On : Sun Oct 20 08:14:33 2019 13 // Update Count : 385 14 14 // 15 15 … … 33 33 34 34 35 static string installlibdir( CFA_LIBDIR ); // fixed location of cc1 and cfa-cpp commands when installed 36 static string compiler_path( CFA_BACKEND_CC ); // path/name of C compiler 35 static string compiler_path( CFA_BACKEND_CC ); // C compiler path/name 37 36 static bool CFA_flag = false; // -CFA flag 38 37 static bool save_temps = false; // -save-temps flag 39 38 static string o_file; 39 static string bprefix; 40 40 41 41 … … 58 58 59 59 60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); 60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "N__=" suffix 61 61 62 62 static void checkEnv1( const char * args[], int & nargs ) { // stage 1 … … 70 70 71 71 if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) { 72 string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4) );72 string val( arg.substr( arg.find_first_of( "=" ) + 1 ) ); 73 73 if ( prefix( val, "-compiler=" ) ) { 74 74 compiler_path = val.substr( 10 ); … … 89 89 90 90 if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) { 91 string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4) );91 string val( arg.substr( arg.find_first_of( "=" ) + 1 ) ); 92 92 if ( prefix( val, "-compiler=" ) ) { 93 93 compiler_path = val.substr( 10 ); … … 98 98 } else if ( prefix( val, "-o=" ) ) { // output file for -CFA 99 99 o_file = val.substr( 3 ); 100 } else { 101 args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str(); 100 } else if ( prefix( val, "-B=" ) ) { // location of cfa-cpp 101 bprefix = val.substr( 3 ); 102 } else { // normal flag for cfa-cpp 103 args[nargs++] = ( *new string( arg.substr( arg.find_first_of( "=" ) + 1 ) ) ).c_str(); 102 104 } // if 103 105 } // if … … 106 108 107 109 108 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i ";110 static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa"; 109 111 static int tmpfilefd = -1; 110 112 static bool startrm = false; … … 291 293 292 294 execvp( args[0], (char * const *)args ); // should not return 293 perror( "CC1 Translator error: stage 1, execvp" ); 295 perror( "CC1 Translator error: stage 1 cpp, execvp" ); 296 cerr << " invoked " << args[0] << endl; 294 297 exit( EXIT_FAILURE ); 295 298 } // if … … 332 335 #endif // __DEBUG_H__ 333 336 337 enum { 338 Color_Auto = 0, 339 Color_Always = 1, 340 Color_Never = 2, 341 } color_arg = Color_Auto; 342 343 const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" }; 344 334 345 // process all the arguments 335 346 … … 338 349 if ( prefix( arg, "-" ) ) { 339 350 // strip inappropriate flags 351 352 if ( prefix( arg, "-fdiagnostics-color=" ) ) { 353 string choice = arg.substr(20); 354 if(choice == "always") color_arg = Color_Always; 355 else if(choice == "never" ) color_arg = Color_Never; 356 else if(choice == "auto" ) color_arg = Color_Auto; 357 } else if ( arg == "-fno-diagnostics-color" ) { 358 color_arg = Color_Auto; 359 } 340 360 341 361 if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" || … … 411 431 } // if 412 432 } else { 413 tmpfilefd = mkstemps( tmpname, 2);433 tmpfilefd = mkstemps( tmpname, 4 ); 414 434 if ( tmpfilefd == -1 ) { 415 435 perror( "CC1 Translator error: stage 2, mkstemp" ); … … 427 447 428 448 if ( fork() == 0 ) { // child runs CFA 429 cargs[0] = ( *new string( installlibdir + "cfa-cpp" ) ).c_str(); 430 449 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str(); 431 450 cargs[ncargs++] = cpp_in; 432 451 … … 438 457 cargs[ncargs++] = cfa_cpp_out.c_str(); 439 458 } // if 440 cargs[ncargs] = nullptr; // terminate argument list 459 460 cargs[ncargs++] = color_names[color_arg]; 461 462 cargs[ncargs] = nullptr; // terminate argument list 441 463 442 464 #ifdef __DEBUG_H__ … … 448 470 449 471 execvp( cargs[0], (char * const *)cargs ); // should not return 450 perror( "CC1 Translator error: stage 2, execvp" ); 472 perror( "CC1 Translator error: stage 2 cfa-cpp, execvp" ); 473 cerr << " invoked " << cargs[0] << endl; 451 474 exit( EXIT_FAILURE ); 452 475 } // if … … 484 507 args[0] = compiler_path.c_str(); 485 508 args[nargs++] = "-S"; // only compile and put assembler output in specified file 486 if ( save_temps ) { // make gcc accept .ifa suffix 487 args[nargs++] = "-x"; 488 args[nargs++] = "cpp-output"; 489 } // if 509 args[nargs++] = "-x"; 510 args[nargs++] = "cpp-output"; 511 490 512 args[nargs++] = cfa_cpp_out.c_str(); 491 513 args[nargs] = nullptr; // terminate argument list … … 500 522 501 523 execvp( args[0], (char * const *)args ); // should not return 502 perror( "CC1 Translator error: stage 2, execvp" ); 524 perror( "CC1 Translator error: stage 2 cc1, execvp" ); 525 cerr << " invoked " << args[0] << endl; 503 526 exit( EXIT_FAILURE ); // tell gcc not to go any further 504 527 } // if 505 528 506 529 wait( &code ); // wait for child to finish 530 rmtmpfile(); // remove tmpname 507 531 508 532 if ( WIFSIGNALED(code) ) { // child failed ? 509 rmtmpfile(); // remove tmpname510 533 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl; 511 534 exit( EXIT_FAILURE ); … … 516 539 #endif // __DEBUG_H__ 517 540 518 rmtmpfile(); // remove tmpname519 541 exit( WEXITSTATUS( code ) ); // stop regardless of success or failure 520 542 } // Stage2  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.