Changeset 90152a4 for driver/cc1.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (8 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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 moved
-
driver/cc1.cc (moved) (moved from src/driver/cc1.cc ) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/cc1.cc
rf9feab8 r90152a4 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 18 08:14:21 201713 // Update Count : 8112 // 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__=" ); … … 43 44 } // prefix 44 45 46 enum { NumSuffixes = 2 }; 47 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 48 49 bool suffix( string arg ) { 50 //std::cerr << arg << std::endl; 51 size_t dot = arg.find_last_of( "." ); 52 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 53 if ( dot == string::npos ) return false; 54 string sx = arg.substr( dot + 1 ); 55 for ( int i = 0; i < NumSuffixes; i += 1 ) { 56 if ( sx == suffixes[i] ) return true; 57 } // for 58 return false; 59 } // suffix 60 45 61 46 62 void checkEnv( const char *args[], int &nargs ) { … … 50 66 if ( value != NULL ) { 51 67 compiler_name = value; 52 #ifdef __DEBUG_H__68 #ifdef __DEBUG_H__ 53 69 cerr << "env arg:\"" << compiler_name << "\"" << endl; 54 #endif // __DEBUG_H__70 #endif // __DEBUG_H__ 55 71 } // if 56 72 … … 58 74 if ( value != NULL ) { 59 75 args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along 60 #ifdef __DEBUG_H__76 #ifdef __DEBUG_H__ 61 77 cerr << "env arg:\"" << args[nargs] << "\"" << endl; 62 #endif // __DEBUG_H__78 #endif // __DEBUG_H__ 63 79 nargs += 1; 64 80 } // if … … 67 83 if ( value != NULL ) { 68 84 args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along 69 #ifdef __DEBUG_H__85 #ifdef __DEBUG_H__ 70 86 cerr << "env arg:\"" << args[nargs] << "\"" << endl; 71 #endif // __DEBUG_H__87 #endif // __DEBUG_H__ 72 88 nargs += 1; 73 89 } // if … … 114 130 signal( SIGTERM, sigTermHandler ); 115 131 116 #ifdef __DEBUG_H__132 #ifdef __DEBUG_H__ 117 133 cerr << "Stage1" << endl; 118 #endif // __DEBUG_H__134 #endif // __DEBUG_H__ 119 135 120 136 // process all the arguments … … 123 139 124 140 for ( i = 1; i < argc; i += 1 ) { 125 #ifdef __DEBUG_H__141 #ifdef __DEBUG_H__ 126 142 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 127 #endif // __DEBUG_H__143 #endif // __DEBUG_H__ 128 144 arg = argv[i]; 129 #ifdef __DEBUG_H__145 #ifdef __DEBUG_H__ 130 146 cerr << "arg:\"" << arg << "\"" << endl; 131 #endif // __DEBUG_H__147 #endif // __DEBUG_H__ 132 148 if ( prefix( arg, "-" ) ) { 133 149 // strip g++ flags that are inappropriate or cause duplicates in subsequent passes … … 163 179 ncargs += 1; 164 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 165 192 } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) { 166 193 bprefix = arg.substr( D__GCC_BPREFIX__.size() ); … … 184 211 args[nargs] = argv[i]; // pass the argument along 185 212 nargs += 1; 186 #ifdef __DEBUG_H__213 #ifdef __DEBUG_H__ 187 214 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 188 #endif // __DEBUG_H__215 #endif // __DEBUG_H__ 189 216 } else if ( arg == "-MD" || arg == "-MMD" ) { 190 217 args[nargs] = "-MF"; // insert before file … … 193 220 args[nargs] = argv[i]; // pass the argument along 194 221 nargs += 1; 195 #ifdef __DEBUG_H__222 #ifdef __DEBUG_H__ 196 223 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 197 #endif // __DEBUG_H__224 #endif // __DEBUG_H__ 198 225 } // if 199 226 } // if … … 201 228 if ( cpp_in == NULL ) { 202 229 cpp_in = argv[i]; 203 #ifdef __DEBUG_H__230 #ifdef __DEBUG_H__ 204 231 cerr << "cpp_in:\"" << cpp_in << "\"" << endl; 205 #endif // __DEBUG_H__232 #endif // __DEBUG_H__ 206 233 } else if ( cpp_out == NULL ) { 207 234 cpp_out = argv[i]; 208 #ifdef __DEBUG_H__235 #ifdef __DEBUG_H__ 209 236 cerr << "cpp_out:\"" << cpp_out << "\""<< endl; 210 #endif // __DEBUG_H__237 #endif // __DEBUG_H__ 211 238 } else { 212 239 cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl; … … 216 243 } // for 217 244 218 #ifdef __DEBUG_H__245 #ifdef __DEBUG_H__ 219 246 cerr << "args:"; 220 247 for ( i = 1; i < nargs; i += 1 ) { … … 224 251 if ( cpp_out != NULL ) cerr << " " << cpp_out; 225 252 cerr << endl; 226 #endif // __DEBUG_H__253 #endif // __DEBUG_H__ 227 254 228 255 if ( cpp_in == NULL ) { … … 246 273 args[nargs] = NULL; // terminate argument list 247 274 248 #ifdef __DEBUG_H__275 #ifdef __DEBUG_H__ 249 276 cerr << "nargs: " << nargs << endl; 250 277 for ( i = 0; args[i] != NULL; i += 1 ) { … … 252 279 } // for 253 280 cerr << endl; 254 #endif // __DEBUG_H__281 #endif // __DEBUG_H__ 255 282 256 283 execvp( args[0], (char *const *)args ); // should not return … … 267 294 } // if 268 295 269 #ifdef __DEBUG_H__296 #ifdef __DEBUG_H__ 270 297 cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl; 271 #endif // __DEBUG_H__298 #endif // __DEBUG_H__ 272 299 273 300 // Run the C preprocessor and save the output in tmpfile. … … 283 310 284 311 args[0] = compiler_name.c_str(); 312 if ( suffix( cpp_in ) ) { 313 args[nargs] = "-x"; 314 nargs += 1; 315 args[nargs] = "c"; 316 nargs += 1; 317 } // if 285 318 args[nargs] = cpp_in; // input to cpp 286 319 nargs += 1; 287 320 args[nargs] = NULL; // terminate argument list 288 321 289 #ifdef __DEBUG_H__322 #ifdef __DEBUG_H__ 290 323 cerr << "cpp nargs: " << nargs << endl; 291 324 for ( i = 0; args[i] != NULL; i += 1 ) { … … 293 326 } // for 294 327 cerr << endl; 295 #endif // __DEBUG_H__328 #endif // __DEBUG_H__ 296 329 297 330 execvp( args[0], (char *const *)args ); // should not return … … 302 335 wait( &code ); // wait for child to finish 303 336 304 #ifdef __DEBUG_H__337 #ifdef __DEBUG_H__ 305 338 cerr << "return code from cpp:" << WEXITSTATUS(code) << endl; 306 #endif // __DEBUG_H__339 #endif // __DEBUG_H__ 307 340 308 341 if ( WIFSIGNALED(code) != 0 ) { // child failed ? … … 340 373 cargs[ncargs] = NULL; // terminate argument list 341 374 342 #ifdef __DEBUG_H__375 #ifdef __DEBUG_H__ 343 376 cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl; 344 377 for ( i = 0; cargs[i] != NULL; i += 1 ) { … … 346 379 } // for 347 380 cerr << endl; 348 #endif // __DEBUG_H__381 #endif // __DEBUG_H__ 349 382 350 383 execvp( cargs[0], (char * const *)cargs ); // should not return … … 355 388 wait( &code ); // wait for child to finish 356 389 357 #ifdef __DEBUG_H__390 #ifdef __DEBUG_H__ 358 391 cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl; 359 #endif // __DEBUG_H__392 #endif // __DEBUG_H__ 360 393 361 394 // Must unlink here because file must exist across execvp. … … 381 414 int nargs = 1; // number of arguments in args list; 0 => command name 382 415 383 #ifdef __DEBUG_H__416 #ifdef __DEBUG_H__ 384 417 cerr << "Stage2" << endl; 385 #endif // __DEBUG_H__418 #endif // __DEBUG_H__ 386 419 387 420 // process all the arguments … … 390 423 391 424 for ( i = 1; i < argc; i += 1 ) { 392 #ifdef __DEBUG_H__425 #ifdef __DEBUG_H__ 393 426 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 394 #endif // __DEBUG_H__427 #endif // __DEBUG_H__ 395 428 arg = argv[i]; 396 #ifdef __DEBUG_H__429 #ifdef __DEBUG_H__ 397 430 cerr << "arg:\"" << arg << "\"" << endl; 398 #endif // __DEBUG_H__431 #endif // __DEBUG_H__ 399 432 if ( prefix( arg, "-" ) ) { 400 433 // strip inappropriate flags 401 434 402 435 if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" || 403 // Currently CFA does not suppose precompiled .h files.404 prefix( arg, "--output-pch" ) ) {436 // Currently CFA does not suppose precompiled .h files. 437 prefix( arg, "--output-pch" ) ) { 405 438 406 439 // strip inappropriate flags with an argument … … 408 441 } else if ( arg == "-auxbase" || arg == "-auxbase-strip" || arg == "-dumpbase" ) { 409 442 i += 1; 410 #ifdef __DEBUG_H__443 #ifdef __DEBUG_H__ 411 444 cerr << "arg:\"" << argv[i] << "\"" << endl; 412 #endif // __DEBUG_H__445 #endif // __DEBUG_H__ 413 446 414 447 // all other flags … … 421 454 args[nargs] = argv[i]; // pass the argument along 422 455 nargs += 1; 423 #ifdef __DEBUG_H__456 #ifdef __DEBUG_H__ 424 457 cerr << "arg:\"" << argv[i] << "\"" << endl; 425 #endif // __DEBUG_H__458 #endif // __DEBUG_H__ 426 459 } // if 427 460 } // if … … 429 462 if ( cpp_in == NULL ) { 430 463 cpp_in = argv[i]; 431 #ifdef __DEBUG_H__464 #ifdef __DEBUG_H__ 432 465 cerr << "cpp_in:\"" << cpp_in << "\"" << endl; 433 #endif // __DEBUG_H__466 #endif // __DEBUG_H__ 434 467 } else { 435 468 cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl; … … 439 472 } // for 440 473 441 #ifdef __DEBUG_H__474 #ifdef __DEBUG_H__ 442 475 cerr << "args:"; 443 476 for ( i = 1; i < nargs; i += 1 ) { … … 446 479 cerr << endl; 447 480 if ( cpp_in != NULL ) cerr << " " << cpp_in; 448 #endif // __DEBUG_H__481 #endif // __DEBUG_H__ 449 482 450 483 args[0] = compiler_name.c_str(); … … 455 488 args[nargs] = NULL; // terminate argument list 456 489 457 #ifdef __DEBUG_H__490 #ifdef __DEBUG_H__ 458 491 cerr << "stage2 nargs: " << nargs << endl; 459 492 for ( i = 0; args[i] != NULL; i += 1 ) { … … 461 494 } // for 462 495 cerr << endl; 463 #endif // __DEBUG_H__496 #endif // __DEBUG_H__ 464 497 465 498 execvp( args[0], (char * const *)args ); // should not return … … 470 503 471 504 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) { 472 #ifdef __DEBUG_H__505 #ifdef __DEBUG_H__ 473 506 for ( int i = 0; env[i] != NULL; i += 1 ) { 474 507 cerr << env[i] << endl; 475 508 } // for 476 #endif // __DEBUG_H__509 #endif // __DEBUG_H__ 477 510 478 511 string arg = argv[1];
Note:
See TracChangeset
for help on using the changeset viewer.