Changeset 36de20d for driver/cfa.cc
- Timestamp:
- Aug 17, 2020, 6:18:34 PM (2 years ago)
- Branches:
- arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 794db28
- Parents:
- 762fbc1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.