- Timestamp:
- Aug 17, 2020, 6:18:34 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 794db28
- Parents:
- 762fbc1
- Location:
- driver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/cc1.cc
r762fbc1 r36de20d 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 13 21:03:15202013 // Update Count : 4 0712 // Last Modified On : Sun Aug 16 21:03:02 2020 13 // Update Count : 413 14 14 // 15 15 … … 24 24 #include <unistd.h> // execvp, fork, unlink 25 25 #include <sys/wait.h> // wait 26 #include <fcntl.h> 26 #include <fcntl.h> // creat 27 27 28 28 … … 59 59 60 60 61 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // " N__=" suffix61 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "__CFA_FLAG__=" suffix 62 62 63 63 static void checkEnv1( const char * args[], int & nargs ) { // stage 1 … … 111 111 } // checkEnv2 112 112 113 114 static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa"; 113 #define CFA_SUFFIX ".ifa" 114 115 static char tmpname[] = P_tmpdir "/CFAXXXXXX" CFA_SUFFIX; 115 116 static int tmpfilefd = -1; 116 117 static bool startrm = false; … … 321 322 322 323 if ( WIFSIGNALED(code) ) { // child failed ? 324 rmtmpfile(); // remove tmpname 323 325 cerr << "CC1 Translator error: stage 1, child failed " << WTERMSIG(code) << endl; 324 326 exit( EXIT_FAILURE ); 325 327 } // if 326 328 327 exit( WEXITSTATUS( code) );// bad cpp result stops top-level gcc329 exit( WEXITSTATUS( code ) ); // bad cpp result stops top-level gcc 328 330 } // Stage1 329 331 … … 373 375 } else if ( arg == "-fno-diagnostics-color" ) { 374 376 color_arg = Color_Auto; 375 } 377 } // if 376 378 377 379 if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" || 378 // Currently CFA does not suppose precompiled .h files.379 prefix( arg, "--output-pch" ) ) {380 // Currently CFA does not suppose precompiled .h files. 381 prefix( arg, "--output-pch" ) ) { 380 382 381 383 // strip inappropriate flags with an argument … … 441 443 } // if 442 444 443 cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + ".ifa";445 cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + CFA_SUFFIX; 444 446 if ( creat( cfa_cpp_out.c_str(), 0666 ) == -1 ) { 445 447 perror( "CC1 Translator error: stage 2, creat" ); … … 462 464 // output. Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file. 463 465 464 if ( fork() == 0 ) { // child runs CFA 466 if ( fork() == 0 ) { // child runs CFA preprocessor 465 467 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str(); 466 468 cargs[ncargs++] = cpp_in; … … 520 522 #endif // __DEBUG_H__ 521 523 522 if ( fork() == 0 ) { // child runs CFA524 if ( fork() == 0 ) { // child runs gcc 523 525 args[0] = compiler_path.c_str(); 524 526 args[nargs++] = "-S"; // only compile and put assembler output in specified file -
driver/cfa.cc
r762fbc1 r36de20d 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 14 07:22:03202013 // Update Count : 4 3712 // Last Modified On : Sun Aug 16 23:05:59 2020 13 // Update Count : 447 14 14 // 15 15 … … 18 18 #include <cstdlib> // putenv, exit 19 19 #include <climits> // PATH_MAX 20 #include <string> // STL version 21 #include <algorithm> // find 22 20 23 #include <unistd.h> // execvp 21 #include <string> // STL version22 #include <string.h> // strcmp23 #include <algorithm> // find24 25 24 #include <sys/types.h> 26 25 #include <sys/stat.h> … … 34 33 using std::to_string; 35 34 36 // 35 //#define __DEBUG_H__ 37 36 38 37 #define xstr(s) str(s) 39 38 #define str(s) #s 40 39 41 // "N__=" suffix 42 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); 40 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "__CFA_FLAG__=" suffix 43 41 44 42 static void Putenv( char * argv[], string arg ) { … … 156 154 PathMode path = FromProc(); 157 155 158 const char * args[argc + 100]; // cfa command line values, plus some space for additional flags156 const char * args[argc + 100]; // cfa command line values, plus some space for additional flags 159 157 int sargs = 1; // starting location for arguments in args list 160 158 int nargs = sargs; // number of arguments in args list; 0 => command name 161 159 162 const char * libs[argc + 20]; // non-user libraries must come separately, plus some added libraries and flags160 const char * libs[argc + 20]; // non-user libraries must come separately, plus some added libraries and flags 163 161 int nlibs = 0; 164 162 … … 183 181 args[nargs++] = argv[i]; // pass argument along 184 182 if ( arg == "-o" ) o_file = i; // remember file 183 184 // CFA specific arguments 185 185 186 } else if ( strncmp(arg.c_str(), "-XCFA", 5) == 0 ) { // CFA pass through 186 187 if ( arg.size() == 5 ) { … … 201 202 } else if ( arg == "-nodebug" ) { 202 203 debug = false; // strip the nodebug flag 203 } else if ( arg == "-nolib" ) {204 nolib = true; // strip the nodebug flag205 204 } else if ( arg == "-quiet" ) { 206 205 quiet = true; // strip the quiet flag 207 206 } else if ( arg == "-noquiet" ) { 208 207 quiet = false; // strip the noquiet flag 208 } else if ( arg == "-no-include-stdhdr" ) { 209 noincstd_flag = true; // strip the no-include-stdhdr flag 210 } else if ( arg == "-nolib" ) { 211 nolib = true; // strip the nolib flag 209 212 } else if ( arg == "-help" ) { 210 213 help = true; // strip the help flag 211 214 } else if ( arg == "-nohelp" ) { 212 215 help = false; // strip the nohelp flag 213 } else if ( arg == "-no-include-stdhdr" ) {214 noincstd_flag = true; // strip the no-include-stdhdr flag215 216 } else if ( arg == "-cfalib") { 216 217 compiling_libs = true; … … 334 335 string libbase; 335 336 switch(path) { 336 case Installed:337 case Installed: 337 338 args[nargs++] = "-I" CFA_INCDIR; 338 339 // do not use during build … … 344 345 libbase = CFA_LIBDIR; 345 346 break; 346 case BuildTree:347 case Distributed:347 case BuildTree: 348 case Distributed: 348 349 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src"; 349 350 // do not use during build … … 379 380 string libdir = libbase + arch + "-" + config; 380 381 381 if ( path != Distributed) {382 if ( path != Distributed ) { 382 383 if ( ! nolib && ! dirExists( libdir ) ) { 383 384 cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl; … … 399 400 string preludedir; 400 401 switch(path) { 401 case Installed : preludedir = libdir; break;402 case BuildTree : preludedir = libdir + "/prelude"; break;403 case Distributed : preludedir = dir(argv[0]); break;404 } 402 case Installed : preludedir = libdir; break; 403 case BuildTree : preludedir = libdir + "/prelude"; break; 404 case Distributed : preludedir = dir(argv[0]); break; 405 } // switch 405 406 406 407 Putenv( argv, "--prelude-dir=" + preludedir ); … … 474 475 if ( bprefix.length() == 0 ) { 475 476 switch(path) { 476 case Installed : bprefix = installlibdir; break;477 case BuildTree : bprefix = srcdriverdir ; break;478 case Distributed : bprefix = dir(argv[0]) ; break;479 } 480 if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/';481 Putenv( argv, string("-B=") + bprefix );482 } // if477 case Installed : bprefix = installlibdir; break; 478 case BuildTree : bprefix = srcdriverdir ; break; 479 case Distributed : bprefix = dir(argv[0]) ; break; 480 } // switch 481 } // if 482 if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/'; 483 Putenv( argv, string("-B=") + bprefix ); 483 484 484 485 args[nargs++] = "-Xlinker"; // used by backtrace … … 502 503 args[nargs++] = "-Wno-cast-function-type"; 503 504 #endif // HAVE_CAST_FUNCTION_TYPE 504 if ( ! std_flag ) { // default c11, if none specified505 args[nargs++] = "-std=gnu11"; 505 if ( ! std_flag && ! x_flag ) { 506 args[nargs++] = "-std=gnu11"; // default c11, if none specified 506 507 } // if 507 508 args[nargs++] = "-fgnu89-inline"; … … 553 554 // execute the command and return the result 554 555 555 execvp( args[0], (char * const *)args );// should not return556 execvp( args[0], (char * const *)args ); // should not return 556 557 perror( "CFA Translator error: execvp" ); 557 558 exit( EXIT_FAILURE );
Note: See TracChangeset
for help on using the changeset viewer.