- Timestamp:
- Sep 25, 2018, 11:35:34 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- c6bbcdb
- Parents:
- 341bb80 (diff), 7428ad9 (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:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/as.cc
r341bb80 r6d44da1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // as.c -- 7 // as.c -- map assembler file, scan for debug information. If found, expand file by one character and insert Cforall 8 // language code on the N line from the start of the debug information. 8 9 // 9 10 // Author : Peter A. Buhr 10 11 // Created On : Wed Aug 1 10:49:42 2018 11 12 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 2 17:50:09201813 // Update Count : 9 013 // Last Modified On : Sat Sep 8 08:40:16 2018 14 // Update Count : 97 14 15 // 15 16 … … 23 24 24 25 //#define __DEBUG_H__ 26 27 #ifdef __DEBUG_H__ 28 #include <iostream> 29 using namespace std; 30 #endif // __DEBUG_H__ 25 31 26 32 int main( const int argc, const char * argv[] ) { … … 38 44 off_t size = mystat.st_size; 39 45 40 char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); 41 if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); }; 46 if ( size ) { // cannot map 0 sized file 47 char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); 48 if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); }; 42 49 43 if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?44 // Expand file by one byte to hold 2 character Cforall language code.45 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };50 if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ? 51 // Expand file by one byte to hold 2 character Cforall language code. 52 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); }; 46 53 47 for ( int i = 0; i < 8; i += 1 ) {// move N (magic) lines forward48 cursor = strstr( cursor, "\n" ) + 1;49 } // for54 for ( int i = 0; i < 8; i += 1 ) { // move N (magic) lines forward 55 cursor = strstr( cursor, "\n" ) + 1; 56 } // for 50 57 51 cursor -= 2;// backup over "c\n" language value52 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };58 cursor -= 2; // backup over "c\n" language value 59 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); }; 53 60 54 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right61 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right 55 62 56 *(cursor) = '2'; // replace C language value with CFA 57 *(cursor + 1) = '5'; 63 *(cursor) = '2'; // replace C language value with CFA 64 *(cursor + 1) = '5'; 65 } // if 66 67 if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk 58 68 } // if 59 60 if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk61 69 62 70 argv[0] = "as"; -
driver/cc1.cc
r341bb80 r6d44da1 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 19 10:46:11201813 // Update Count : 1 1112 // Last Modified On : Mon Sep 3 16:57:05 2018 13 // Update Count : 125 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__=" );35 34 string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" ); 36 35 string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" ); … … 47 46 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 48 47 49 bool suffix( string arg) {48 void suffix( string arg, const char * args[], int & nargs ) { 50 49 //std::cerr << arg << std::endl; 51 50 size_t dot = arg.find_last_of( "." ); 52 51 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 53 if ( dot == string::npos ) return false;52 if ( dot == string::npos ) return; 54 53 string sx = arg.substr( dot + 1 ); 55 54 for ( int i = 0; i < NumSuffixes; i += 1 ) { 56 if ( sx == suffixes[i] ) return true; 57 } // for 58 return false; 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 59 63 } // suffix 60 64 61 65 62 void checkEnv( const char * args[], int &nargs ) {66 void checkEnv( const char * args[], int & nargs ) { 63 67 char *value; 64 68 65 value = getenv( "__C OMPILER__" );69 value = getenv( "__CFA_COMPILER__" ); 66 70 if ( value != NULL ) { 67 71 compiler_name = value; … … 110 114 void Stage1( const int argc, const char * const argv[] ) { 111 115 int code; 112 int i;113 116 114 117 string arg; … … 133 136 cerr << "Stage1" << endl; 134 137 #endif // __DEBUG_H__ 138 checkEnv( args, nargs ); // arguments passed via environment variables 139 #ifdef __DEBUG_H__ 140 for ( int i = 1; i < argc; i += 1 ) { 141 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 142 } // for 143 #endif // __DEBUG_H__ 135 144 136 145 // process all the arguments 137 146 138 checkEnv( args, nargs ); // arguments passed via environment variables 139 140 for ( i = 1; i < argc; i += 1 ) { 141 #ifdef __DEBUG_H__ 142 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 143 #endif // __DEBUG_H__ 147 for ( int i = 1; i < argc; i += 1 ) { 144 148 arg = argv[i]; 145 #ifdef __DEBUG_H__146 cerr << "arg:\"" << arg << "\"" << endl;147 #endif // __DEBUG_H__148 149 if ( prefix( arg, "-" ) ) { 149 150 // strip g++ flags that are inappropriate or cause duplicates in subsequent passes … … 179 180 ncargs += 1; 180 181 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 along185 // 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 along190 // nargs += 1;191 // i += 1; // and the argument192 182 } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) { 193 183 bprefix = arg.substr( D__GCC_BPREFIX__.size() ); … … 245 235 #ifdef __DEBUG_H__ 246 236 cerr << "args:"; 247 for ( i = 1; i < nargs; i += 1 ) {237 for ( int i = 1; i < nargs; i += 1 ) { 248 238 cerr << " " << args[i]; 249 239 } // for … … 263 253 264 254 args[0] = compiler_name.c_str(); 255 suffix( cpp_in, args, nargs ); // check suffix 265 256 args[nargs] = cpp_in; 266 257 nargs += 1; … … 275 266 #ifdef __DEBUG_H__ 276 267 cerr << "nargs: " << nargs << endl; 277 for ( i = 0; args[i] != NULL; i += 1 ) {268 for ( int i = 0; args[i] != NULL; i += 1 ) { 278 269 cerr << args[i] << " "; 279 270 } // for … … 310 301 311 302 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 303 suffix( cpp_in, args, nargs ); // check suffix 318 304 args[nargs] = cpp_in; // input to cpp 319 305 nargs += 1; … … 322 308 #ifdef __DEBUG_H__ 323 309 cerr << "cpp nargs: " << nargs << endl; 324 for ( i = 0; args[i] != NULL; i += 1 ) {310 for ( int i = 0; args[i] != NULL; i += 1 ) { 325 311 cerr << args[i] << " "; 326 312 } // for … … 354 340 355 341 if ( fork() == 0 ) { // child runs CFA 356 cargs[0] = ( *new string( bprefix + " /cfa-cpp" ) ).c_str();342 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str(); 357 343 358 344 // Source file-name used to generate routine names containing global initializations for TU. … … 375 361 #ifdef __DEBUG_H__ 376 362 cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl; 377 for ( i = 0; cargs[i] != NULL; i += 1 ) {363 for ( int i = 0; cargs[i] != NULL; i += 1 ) { 378 364 cerr << cargs[i] << " "; 379 365 } // for … … 405 391 406 392 void Stage2( const int argc, const char * const * argv ) { 407 int i;408 409 393 string arg; 410 394 … … 417 401 cerr << "Stage2" << endl; 418 402 #endif // __DEBUG_H__ 403 checkEnv( args, nargs ); // arguments passed via environment variables 404 #ifdef __DEBUG_H__ 405 for ( int i = 1; i < argc; i += 1 ) { 406 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 407 } // for 408 #endif // __DEBUG_H__ 419 409 420 410 // process all the arguments 421 411 422 checkEnv( args, nargs ); // arguments passed via environment variables 423 424 for ( i = 1; i < argc; i += 1 ) { 425 #ifdef __DEBUG_H__ 426 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 427 #endif // __DEBUG_H__ 412 for ( int i = 1; i < argc; i += 1 ) { 428 413 arg = argv[i]; 429 #ifdef __DEBUG_H__430 cerr << "arg:\"" << arg << "\"" << endl;431 #endif // __DEBUG_H__432 414 if ( prefix( arg, "-" ) ) { 433 415 // strip inappropriate flags … … 474 456 #ifdef __DEBUG_H__ 475 457 cerr << "args:"; 476 for ( i = 1; i < nargs; i += 1 ) {458 for ( int i = 1; i < nargs; i += 1 ) { 477 459 cerr << " " << args[i]; 478 460 } // for … … 490 472 #ifdef __DEBUG_H__ 491 473 cerr << "stage2 nargs: " << nargs << endl; 492 for ( i = 0; args[i] != NULL; i += 1 ) {474 for ( int i = 0; args[i] != NULL; i += 1 ) { 493 475 cerr << args[i] << " "; 494 476 } // for … … 504 486 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) { 505 487 #ifdef __DEBUG_H__ 506 for ( int i = 0; env[i] != NULL; i += 1 ) {488 for ( int int i = 0; env[i] != NULL; i += 1 ) { 507 489 cerr << env[i] << endl; 508 490 } // for -
driver/cfa.cc
r341bb80 r6d44da1 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 10 18:17:58201813 // Update Count : 2 5912 // Last Modified On : Mon Sep 3 16:47:59 2018 13 // Update Count : 275 14 14 // 15 15 … … 43 43 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 44 44 45 bool suffix( string arg ) {45 bool suffix( string arg, const char * args[], int & nargs ) { 46 46 //std::cerr << arg << std::endl; 47 47 size_t dot = arg.find_last_of( "." ); … … 50 50 string sx = arg.substr( dot + 1 ); 51 51 for ( int i = 0; i < NumSuffixes; i += 1 ) { 52 if ( sx == suffixes[i] ) return true; 52 if ( sx == suffixes[i] ) { 53 args[nargs] = "-x"; 54 nargs += 1; 55 args[nargs] = "c"; 56 nargs += 1; 57 return true; 58 } // if 53 59 } // for 54 60 return false; … … 86 92 string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) ); 87 93 88 string installincdir( CFA_INCDIR ); 89 string installlibdir( CFA_LIBDIR ); 90 string srcdriverdir ( TOP_BUILDDIR "driver"); 94 string installincdir( CFA_INCDIR ); // fixed location of include files 95 string installlibdir( CFA_LIBDIR ); // fixed location of cc1 and cfa-cpp commands when installed 96 string srcdriverdir ( TOP_BUILDDIR "driver"); // fixed location of cc1 and cfa-cpp commands when in tree 91 97 92 98 string heading; // banner printed at start of cfa compilation … … 123 129 #ifdef __DEBUG_H__ 124 130 cerr << "CFA:" << endl; 131 for ( int i = 1; i < argc; i += 1 ) { 132 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 133 } // for 125 134 #endif // __DEBUG_H__ 126 135 … … 128 137 129 138 for ( int i = 1; i < argc; i += 1 ) { 130 #ifdef __DEBUG_H__131 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;132 #endif // __DEBUG_H__133 139 arg = argv[i]; // convert to string value 134 #ifdef __DEBUG_H__135 cerr << "arg:\"" << arg << "\"" << endl;136 #endif // __DEBUG_H__137 140 if ( prefix( arg, "-" ) ) { 138 141 // pass through arguments … … 178 181 if ( i == argc ) continue; // next argument available ? 179 182 compiler_path = argv[i]; 180 if ( putenv( (char *)( *new string( string( "__ U_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {183 if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) { 181 184 cerr << argv[0] << " error, cannot set environment variable." << endl; 182 185 exit( EXIT_FAILURE ); … … 197 200 args[nargs] = argv[i]; // pass the argument along 198 201 nargs += 1; 199 } else if ( arg == "-x" ) {200 xflag = true;201 args[nargs] = argv[i]; // pass the argument along202 nargs += 1;203 i += 1; // advance to argument204 args[nargs] = argv[i]; // pass the argument along205 nargs += 1;206 // args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x207 // nargs += 1;208 } else if ( prefix( arg, "-x" ) ) {209 xflag = true;210 args[nargs] = argv[i]; // pass the argument along211 nargs += 1;212 // args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x213 // nargs += 1;214 202 } else if ( arg == "-w" ) { 215 203 args[nargs] = argv[i]; // pass the argument along … … 293 281 } // if 294 282 } else { 295 bool opt = false; 296 if ( ! xflag && suffix( arg ) ) { 283 bool cfa = suffix( arg, args, nargs ); // check suffix 284 args[nargs] = argv[i]; // concatenate file 285 nargs += 1; 286 if ( cfa ) { 297 287 args[nargs] = "-x"; 298 288 nargs += 1; 299 args[nargs] = "c";300 nargs += 1;301 // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x302 // nargs += 1;303 opt = true;304 } // if305 // concatenate other arguments306 args[nargs] = argv[i];307 nargs += 1;308 if ( opt ) {309 args[nargs] = "-x";310 nargs += 1;311 289 args[nargs] = "none"; 312 290 nargs += 1; 313 // args[nargs] = ( *new string( string("-D__GCC_X__=none") ) ).c_str(); // add the argument for -x314 // nargs += 1;315 291 } // if 316 292 nonoptarg = true; … … 319 295 } // for 320 296 297 args[nargs] = "-x"; // turn off language 298 nargs += 1; 299 args[nargs] = "none"; 300 nargs += 1; 301 321 302 #ifdef __x86_64__ 322 303 args[nargs] = "-mcx16"; // allow double-wide CAA … … 341 322 args[nargs] = "-I" CFA_INCDIR; 342 323 nargs += 1; 343 if ( ! noincstd_flag ) { 344 args[nargs] = "-I" CFA_INCDIR " /stdhdr";324 if ( ! noincstd_flag ) { // do not use during build 325 args[nargs] = "-I" CFA_INCDIR "stdhdr"; 345 326 nargs += 1; 346 327 } // if 347 args[nargs] = "-I" CFA_INCDIR " /concurrency";348 nargs += 1; 349 args[nargs] = "-I" CFA_INCDIR " /containers";328 args[nargs] = "-I" CFA_INCDIR "concurrency"; 329 nargs += 1; 330 args[nargs] = "-I" CFA_INCDIR "containers"; 350 331 nargs += 1; 351 332 } else { 352 333 args[nargs] = "-I" TOP_SRCDIR "libcfa/src"; 353 334 nargs += 1; 354 if ( ! noincstd_flag ) { 335 if ( ! noincstd_flag ) { // do not use during build 355 336 args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr"; 356 337 nargs += 1; … … 377 358 } 378 359 379 const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU); 360 string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU); 361 if ( ! m32 && ! m64 ) { 362 if ( arch == "x86" ) { 363 args[nargs] = "-m32"; 364 nargs += 1; 365 } else if ( arch == "x64" ) { 366 args[nargs] = "-m64"; 367 nargs += 1; 368 } // if 369 } // if 380 370 const char * config = debug ? "debug": "nodebug"; 381 371 string libdir = libbase + arch + "-" + config; 382 if( !dirExists(libdir) ) { 372 373 if ( ! dirExists( libdir ) ) { 383 374 cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl; 384 375 cerr << "Was looking for " << libdir << endl; 385 376 libdir = libbase + arch + "-" + "nolib"; 386 } 387 388 if ( !dirExists(libdir) ) {377 } // if 378 379 if ( ! dirExists( libdir ) ) { 389 380 cerr << argv[0] << " internal error, cannot find prelude directory." << endl; 390 381 cerr << "Was looking for " << libdir << endl; 391 382 exit( EXIT_FAILURE ); 392 } 383 } // if 393 384 394 385 args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str(); … … 472 463 473 464 if ( Bprefix.length() == 0 ) { 474 Bprefix = !intree ? installlibdir : srcdriverdir; 465 Bprefix = ! intree ? installlibdir : srcdriverdir; 466 if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/'; 475 467 args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); 476 468 nargs += 1; … … 506 498 args[nargs] = "-D__int8_t_defined"; // prevent gcc type-size attributes 507 499 nargs += 1; 508 args[nargs] = ( *new string( string("-B") + Bprefix + "/") ).c_str();500 args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str(); 509 501 nargs += 1; 510 502 args[nargs] = "-lm";
Note: See TracChangeset
for help on using the changeset viewer.