Changes in driver/cc1.cc [bec4d24:bf71cfd]
- File:
-
- 1 edited
-
driver/cc1.cc (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/cc1.cc
rbec4d24 rbf71cfd 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 3 16:57:05201813 // Update Count : 1 2512 // Last Modified On : Thu Jul 19 10:46:11 2018 13 // Update Count : 111 14 14 // 15 15 … … 32 32 string compiler_name( CFA_BACKEND_CC ); // path/name of C compiler 33 33 34 string D__GCC_X__( "-D__GCC_X__=" ); 34 35 string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" ); 35 36 string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" ); … … 46 47 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 47 48 48 void suffix( string arg, const char * args[], int & nargs) {49 bool suffix( string arg ) { 49 50 //std::cerr << arg << std::endl; 50 51 size_t dot = arg.find_last_of( "." ); 51 52 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 52 if ( dot == string::npos ) return ;53 if ( dot == string::npos ) return false; 53 54 string sx = arg.substr( dot + 1 ); 54 55 for ( int i = 0; i < NumSuffixes; i += 1 ) { 55 if ( sx == suffixes[i] ) { 56 args[nargs] = "-x"; 57 nargs += 1; 58 args[nargs] = "c"; 59 nargs += 1; 60 return; 61 } // if 62 } // for 56 if ( sx == suffixes[i] ) return true; 57 } // for 58 return false; 63 59 } // suffix 64 60 65 61 66 void checkEnv( const char * args[], int &nargs ) {62 void checkEnv( const char *args[], int &nargs ) { 67 63 char *value; 68 64 69 value = getenv( "__C FA_COMPILER__" );65 value = getenv( "__COMPILER__" ); 70 66 if ( value != NULL ) { 71 67 compiler_name = value; … … 114 110 void Stage1( const int argc, const char * const argv[] ) { 115 111 int code; 112 int i; 116 113 117 114 string arg; … … 136 133 cerr << "Stage1" << endl; 137 134 #endif // __DEBUG_H__ 135 136 // process all the arguments 137 138 138 checkEnv( args, nargs ); // arguments passed via environment variables 139 #ifdef __DEBUG_H__ 140 for ( int i = 1; i < argc; i += 1 ) { 139 140 for ( i = 1; i < argc; i += 1 ) { 141 #ifdef __DEBUG_H__ 141 142 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 142 } // for 143 #endif // __DEBUG_H__ 144 145 // process all the arguments 146 147 for ( int i = 1; i < argc; i += 1 ) { 143 #endif // __DEBUG_H__ 148 144 arg = argv[i]; 145 #ifdef __DEBUG_H__ 146 cerr << "arg:\"" << arg << "\"" << endl; 147 #endif // __DEBUG_H__ 149 148 if ( prefix( arg, "-" ) ) { 150 149 // strip g++ flags that are inappropriate or cause duplicates in subsequent passes … … 180 179 ncargs += 1; 181 180 i += 1; // and the argument 181 // } else if ( prefix( arg, D__GCC_X__ ) ) { 182 // args[nargs] = "-x"; 183 // nargs += 1; 184 // args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along 185 // nargs += 1; 186 // } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) { 187 // args[nargs] = "-x"; 188 // nargs += 1; 189 // args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along 190 // nargs += 1; 191 // i += 1; // and the argument 182 192 } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) { 183 193 bprefix = arg.substr( D__GCC_BPREFIX__.size() ); … … 235 245 #ifdef __DEBUG_H__ 236 246 cerr << "args:"; 237 for ( i nt i= 1; i < nargs; i += 1 ) {247 for ( i = 1; i < nargs; i += 1 ) { 238 248 cerr << " " << args[i]; 239 249 } // for … … 253 263 254 264 args[0] = compiler_name.c_str(); 255 suffix( cpp_in, args, nargs ); // check suffix256 265 args[nargs] = cpp_in; 257 266 nargs += 1; … … 266 275 #ifdef __DEBUG_H__ 267 276 cerr << "nargs: " << nargs << endl; 268 for ( i nt i= 0; args[i] != NULL; i += 1 ) {277 for ( i = 0; args[i] != NULL; i += 1 ) { 269 278 cerr << args[i] << " "; 270 279 } // for … … 301 310 302 311 args[0] = compiler_name.c_str(); 303 suffix( cpp_in, args, nargs ); // check suffix 312 if ( suffix( cpp_in ) ) { 313 args[nargs] = "-x"; 314 nargs += 1; 315 args[nargs] = "c"; 316 nargs += 1; 317 } // if 304 318 args[nargs] = cpp_in; // input to cpp 305 319 nargs += 1; … … 308 322 #ifdef __DEBUG_H__ 309 323 cerr << "cpp nargs: " << nargs << endl; 310 for ( i nt i= 0; args[i] != NULL; i += 1 ) {324 for ( i = 0; args[i] != NULL; i += 1 ) { 311 325 cerr << args[i] << " "; 312 326 } // for … … 340 354 341 355 if ( fork() == 0 ) { // child runs CFA 342 cargs[0] = ( *new string( bprefix + " cfa-cpp" ) ).c_str();356 cargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str(); 343 357 344 358 // Source file-name used to generate routine names containing global initializations for TU. … … 361 375 #ifdef __DEBUG_H__ 362 376 cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl; 363 for ( i nt i= 0; cargs[i] != NULL; i += 1 ) {377 for ( i = 0; cargs[i] != NULL; i += 1 ) { 364 378 cerr << cargs[i] << " "; 365 379 } // for … … 391 405 392 406 void Stage2( const int argc, const char * const * argv ) { 407 int i; 408 393 409 string arg; 394 410 … … 401 417 cerr << "Stage2" << endl; 402 418 #endif // __DEBUG_H__ 419 420 // process all the arguments 421 403 422 checkEnv( args, nargs ); // arguments passed via environment variables 404 #ifdef __DEBUG_H__ 405 for ( int i = 1; i < argc; i += 1 ) { 423 424 for ( i = 1; i < argc; i += 1 ) { 425 #ifdef __DEBUG_H__ 406 426 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 407 } // for 408 #endif // __DEBUG_H__ 409 410 // process all the arguments 411 412 for ( int i = 1; i < argc; i += 1 ) { 427 #endif // __DEBUG_H__ 413 428 arg = argv[i]; 429 #ifdef __DEBUG_H__ 430 cerr << "arg:\"" << arg << "\"" << endl; 431 #endif // __DEBUG_H__ 414 432 if ( prefix( arg, "-" ) ) { 415 433 // strip inappropriate flags … … 456 474 #ifdef __DEBUG_H__ 457 475 cerr << "args:"; 458 for ( i nt i= 1; i < nargs; i += 1 ) {476 for ( i = 1; i < nargs; i += 1 ) { 459 477 cerr << " " << args[i]; 460 478 } // for … … 472 490 #ifdef __DEBUG_H__ 473 491 cerr << "stage2 nargs: " << nargs << endl; 474 for ( i nt i= 0; args[i] != NULL; i += 1 ) {492 for ( i = 0; args[i] != NULL; i += 1 ) { 475 493 cerr << args[i] << " "; 476 494 } // for … … 486 504 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) { 487 505 #ifdef __DEBUG_H__ 488 for ( int i nt i= 0; env[i] != NULL; i += 1 ) {506 for ( int i = 0; env[i] != NULL; i += 1 ) { 489 507 cerr << env[i] << endl; 490 508 } // for
Note:
See TracChangeset
for help on using the changeset viewer.