Changes in driver/cc1.cc [49d3128:bbb1b35]
- File:
-
- 1 edited
-
driver/cc1.cc (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/cc1.cc
r49d3128 rbbb1b35 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 20 08:14:33201913 // Update Count : 3 8512 // Last Modified On : Fri Aug 23 15:06:27 2019 13 // Update Count : 371 14 14 // 15 15 … … 33 33 34 34 35 static string compiler_path( CFA_BACKEND_CC ); // C compiler path/name 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 36 37 static bool CFA_flag = false; // -CFA flag 37 38 static bool save_temps = false; // -save-temps flag 38 39 static string o_file; 39 static string bprefix;40 40 41 41 … … 58 58 59 59 60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "N__=" suffix60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); 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( arg.find_first_of( "=" ) + 1) );72 string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ); 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( arg.find_first_of( "=" ) + 1) );91 string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ); 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 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(); 100 } else { 101 args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str(); 104 102 } // if 105 103 } // if … … 108 106 109 107 110 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i fa";108 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i"; 111 109 static int tmpfilefd = -1; 112 110 static bool startrm = false; … … 293 291 294 292 execvp( args[0], (char * const *)args ); // should not return 295 perror( "CC1 Translator error: stage 1 cpp, execvp" ); 296 cerr << " invoked " << args[0] << endl; 293 perror( "CC1 Translator error: stage 1, execvp" ); 297 294 exit( EXIT_FAILURE ); 298 295 } // if … … 335 332 #endif // __DEBUG_H__ 336 333 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 345 334 // process all the arguments 346 335 … … 349 338 if ( prefix( arg, "-" ) ) { 350 339 // 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 }360 340 361 341 if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" || … … 431 411 } // if 432 412 } else { 433 tmpfilefd = mkstemps( tmpname, 4);413 tmpfilefd = mkstemps( tmpname, 2 ); 434 414 if ( tmpfilefd == -1 ) { 435 415 perror( "CC1 Translator error: stage 2, mkstemp" ); … … 447 427 448 428 if ( fork() == 0 ) { // child runs CFA 449 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str(); 429 cargs[0] = ( *new string( installlibdir + "cfa-cpp" ) ).c_str(); 430 450 431 cargs[ncargs++] = cpp_in; 451 432 … … 457 438 cargs[ncargs++] = cfa_cpp_out.c_str(); 458 439 } // if 459 460 cargs[ncargs++] = color_names[color_arg]; 461 462 cargs[ncargs] = nullptr; // terminate argument list 440 cargs[ncargs] = nullptr; // terminate argument list 463 441 464 442 #ifdef __DEBUG_H__ … … 470 448 471 449 execvp( cargs[0], (char * const *)cargs ); // should not return 472 perror( "CC1 Translator error: stage 2 cfa-cpp, execvp" ); 473 cerr << " invoked " << cargs[0] << endl; 450 perror( "CC1 Translator error: stage 2, execvp" ); 474 451 exit( EXIT_FAILURE ); 475 452 } // if … … 507 484 args[0] = compiler_path.c_str(); 508 485 args[nargs++] = "-S"; // only compile and put assembler output in specified file 509 args[nargs++] = "-x"; 510 args[nargs++] = "cpp-output"; 511 486 if ( save_temps ) { // make gcc accept .ifa suffix 487 args[nargs++] = "-x"; 488 args[nargs++] = "cpp-output"; 489 } // if 512 490 args[nargs++] = cfa_cpp_out.c_str(); 513 491 args[nargs] = nullptr; // terminate argument list … … 522 500 523 501 execvp( args[0], (char * const *)args ); // should not return 524 perror( "CC1 Translator error: stage 2 cc1, execvp" ); 525 cerr << " invoked " << args[0] << endl; 502 perror( "CC1 Translator error: stage 2, execvp" ); 526 503 exit( EXIT_FAILURE ); // tell gcc not to go any further 527 504 } // if 528 505 529 506 wait( &code ); // wait for child to finish 507 508 if ( WIFSIGNALED(code) ) { // child failed ? 509 rmtmpfile(); // remove tmpname 510 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl; 511 exit( EXIT_FAILURE ); 512 } // if 513 514 #ifdef __DEBUG_H__ 515 cerr << "return code from gcc cc1:" << WEXITSTATUS(code) << endl; 516 #endif // __DEBUG_H__ 517 530 518 rmtmpfile(); // remove tmpname 531 532 if ( WIFSIGNALED(code) ) { // child failed ?533 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;534 exit( EXIT_FAILURE );535 } // if536 537 #ifdef __DEBUG_H__538 cerr << "return code from gcc cc1:" << WEXITSTATUS(code) << endl;539 #endif // __DEBUG_H__540 541 519 exit( WEXITSTATUS( code ) ); // stop regardless of success or failure 542 520 } // Stage2
Note:
See TracChangeset
for help on using the changeset viewer.