- Timestamp:
- Aug 18, 2020, 11:35:50 AM (5 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:
- 93526ef
- Parents:
- d2b5d2d (diff), 36de20d (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. - Location:
- driver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/cc1.cc
rd2b5d2d r794db28 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
rd2b5d2d r794db28 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 13 17:22:02202013 // Update Count : 4 3512 // Last Modified On : Sun Aug 16 23:05:59 2020 13 // Update Count : 447 14 14 // 15 15 16 16 #include <iostream> 17 #include <cstdio> // perror 18 #include <cstdlib> // putenv, exit 19 #include <climits> // PATH_MAX 20 #include <unistd.h> // execvp 21 #include <string> // STL version 22 #include <string.h> // strcmp 23 #include <algorithm> // find 24 17 #include <cstdio> // perror 18 #include <cstdlib> // putenv, exit 19 #include <climits> // PATH_MAX 20 #include <string> // STL version 21 #include <algorithm> // find 22 23 #include <unistd.h> // execvp 25 24 #include <sys/types.h> 26 25 #include <sys/stat.h> … … 34 33 using std::to_string; 35 34 36 // #define __DEBUG_H__ 37 38 // "N__=" suffix 39 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); 40 41 void Putenv( char * argv[], string arg ) { 35 //#define __DEBUG_H__ 36 37 #define xstr(s) str(s) 38 #define str(s) #s 39 40 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "__CFA_FLAG__=" suffix 41 42 static void Putenv( char * argv[], string arg ) { 42 43 // environment variables must have unique names 43 44 static int flags = 0; … … 49 50 } // Putenv 50 51 51 // check if string has prefix 52 bool prefix( const string & arg, const string & pre ) { 52 static bool prefix( const string & arg, const string & pre ) { // check if string has prefix 53 53 return arg.substr( 0, pre.size() ) == pre; 54 54 } // prefix 55 55 56 inline bool ends_with(const string & str, const string & sfix) {56 static inline bool ends_with(const string & str, const string & sfix) { 57 57 if (sfix.size() > str.size()) return false; 58 58 return std::equal(str.rbegin(), str.rbegin() + sfix.size(), sfix.rbegin(), sfix.rend()); … … 60 60 61 61 // check if string has suffix 62 bool suffix( const string & arg ) {62 static bool suffix( const string & arg ) { 63 63 enum { NumSuffixes = 3 }; 64 64 static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" }; … … 70 70 } // suffix 71 71 72 73 72 static inline bool dirExists( const string & path ) { // check if directory exists 74 73 struct stat info; … … 79 78 static inline string dir(const string & path) { 80 79 return path.substr(0, path.find_last_of('/')); 81 } 80 } // dir 82 81 83 82 // Different path modes … … 118 117 } 119 118 120 121 #define xstr(s) str(s)122 #define str(s) #s123 119 124 120 int main( int argc, char * argv[] ) { … … 158 154 PathMode path = FromProc(); 159 155 160 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 161 157 int sargs = 1; // starting location for arguments in args list 162 158 int nargs = sargs; // number of arguments in args list; 0 => command name 163 159 164 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 165 161 int nlibs = 0; 166 162 … … 185 181 args[nargs++] = argv[i]; // pass argument along 186 182 if ( arg == "-o" ) o_file = i; // remember file 183 184 // CFA specific arguments 185 187 186 } else if ( strncmp(arg.c_str(), "-XCFA", 5) == 0 ) { // CFA pass through 188 187 if ( arg.size() == 5 ) { … … 203 202 } else if ( arg == "-nodebug" ) { 204 203 debug = false; // strip the nodebug flag 205 } else if ( arg == "-nolib" ) {206 nolib = true; // strip the nodebug flag207 204 } else if ( arg == "-quiet" ) { 208 205 quiet = true; // strip the quiet flag 209 206 } else if ( arg == "-noquiet" ) { 210 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 211 212 } else if ( arg == "-help" ) { 212 213 help = true; // strip the help flag 213 214 } else if ( arg == "-nohelp" ) { 214 215 help = false; // strip the nohelp flag 215 } else if ( arg == "-no-include-stdhdr" ) {216 noincstd_flag = true; // strip the no-include-stdhdr flag217 216 } else if ( arg == "-cfalib") { 218 217 compiling_libs = true; … … 336 335 string libbase; 337 336 switch(path) { 338 case Installed:337 case Installed: 339 338 args[nargs++] = "-I" CFA_INCDIR; 340 339 // do not use during build … … 346 345 libbase = CFA_LIBDIR; 347 346 break; 348 case BuildTree:349 case Distributed:347 case BuildTree: 348 case Distributed: 350 349 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src"; 351 350 // do not use during build … … 381 380 string libdir = libbase + arch + "-" + config; 382 381 383 if ( path != Distributed) {382 if ( path != Distributed ) { 384 383 if ( ! nolib && ! dirExists( libdir ) ) { 385 384 cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl; … … 401 400 string preludedir; 402 401 switch(path) { 403 case Installed : preludedir = libdir; break;404 case BuildTree : preludedir = libdir + "/prelude"; break;405 case Distributed : preludedir = dir(argv[0]); break;406 } 402 case Installed : preludedir = libdir; break; 403 case BuildTree : preludedir = libdir + "/prelude"; break; 404 case Distributed : preludedir = dir(argv[0]); break; 405 } // switch 407 406 408 407 Putenv( argv, "--prelude-dir=" + preludedir ); … … 476 475 if ( bprefix.length() == 0 ) { 477 476 switch(path) { 478 case Installed : bprefix = installlibdir; break;479 case BuildTree : bprefix = srcdriverdir ; break;480 case Distributed : bprefix = dir(argv[0]) ; break;481 } 482 if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/';483 Putenv( argv, string("-B=") + bprefix );484 } // 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 ); 485 484 486 485 args[nargs++] = "-Xlinker"; // used by backtrace … … 504 503 args[nargs++] = "-Wno-cast-function-type"; 505 504 #endif // HAVE_CAST_FUNCTION_TYPE 506 if ( ! std_flag ) { // default c11, if none specified507 args[nargs++] = "-std=gnu11"; 505 if ( ! std_flag && ! x_flag ) { 506 args[nargs++] = "-std=gnu11"; // default c11, if none specified 508 507 } // if 509 508 args[nargs++] = "-fgnu89-inline"; … … 555 554 // execute the command and return the result 556 555 557 execvp( args[0], (char * const *)args );// should not return556 execvp( args[0], (char * const *)args ); // should not return 558 557 perror( "CFA Translator error: execvp" ); 559 558 exit( EXIT_FAILURE );
Note:
See TracChangeset
for help on using the changeset viewer.