Changeset 3d5701e for driver/cc1.cc


Ignore:
Timestamp:
Feb 25, 2020, 1:17:33 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
7dc2e015
Parents:
9fb8f01 (diff), dd9e1ca (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.
Message:

resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    r9fb8f01 r3d5701e  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 23 15:06:27 2019
    13 // Update Count     : 371
     12// Last Modified On : Sun Oct 20 08:14:33 2019
     13// Update Count     : 385
    1414//
    1515
     
    3333
    3434
    35 static string installlibdir( CFA_LIBDIR );                              // fixed location of cc1 and cfa-cpp commands when installed
    36 static string compiler_path( CFA_BACKEND_CC );                  // path/name of C compiler
     35static string compiler_path( CFA_BACKEND_CC );                  // C compiler path/name
    3736static bool CFA_flag = false;                                                   // -CFA flag
    3837static bool save_temps = false;                                                 // -save-temps flag
    3938static string o_file;
     39static string bprefix;
    4040
    4141
     
    5858
    5959
    60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
     60static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
    6161
    6262static void checkEnv1( const char * args[], int & nargs ) { // stage 1
     
    7070
    7171                if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    72                         string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
     72                        string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    7373                        if ( prefix( val, "-compiler=" ) ) {
    7474                                compiler_path = val.substr( 10 );
     
    8989
    9090                if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    91                         string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
     91                        string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    9292                        if ( prefix( val, "-compiler=" ) ) {
    9393                                compiler_path = val.substr( 10 );
     
    9898                        } else if ( prefix( val, "-o=" ) ) {            // output file for -CFA
    9999                                o_file = val.substr( 3 );
    100                         } else {
    101                                 args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str();
     100                        } else if ( prefix( val, "-B=" ) ) {            // location of cfa-cpp
     101                                bprefix = val.substr( 3 );
     102                        } else {                                                                        // normal flag for cfa-cpp
     103                                args[nargs++] = ( *new string( arg.substr( arg.find_first_of( "=" ) + 1 ) ) ).c_str();
    102104                        } // if
    103105                } // if
     
    106108
    107109
    108 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i";
     110static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa";
    109111static int tmpfilefd = -1;
    110112static bool startrm = false;
     
    291293
    292294                execvp( args[0], (char * const *)args );                // should not return
    293                 perror( "CC1 Translator error: stage 1, execvp" );
     295                perror( "CC1 Translator error: stage 1 cpp, execvp" );
     296                cerr << " invoked " << args[0] << endl;
    294297                exit( EXIT_FAILURE );
    295298        } // if
     
    332335        #endif // __DEBUG_H__
    333336
     337        enum {
     338                Color_Auto   = 0,
     339                Color_Always = 1,
     340                Color_Never  = 2,
     341        } color_arg = Color_Auto;
     342
     343        const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" };
     344
    334345        // process all the arguments
    335346
     
    338349                if ( prefix( arg, "-" ) ) {
    339350                        // strip inappropriate flags
     351
     352                        if ( prefix( arg, "-fdiagnostics-color=" ) ) {
     353                                string choice = arg.substr(20);
     354                                     if(choice == "always") color_arg = Color_Always;
     355                                else if(choice == "never" ) color_arg = Color_Never;
     356                                else if(choice == "auto"  ) color_arg = Color_Auto;
     357                        } else if ( arg == "-fno-diagnostics-color" ) {
     358                                color_arg = Color_Auto;
     359                        }
    340360
    341361                        if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
     
    411431                        } // if
    412432                } else {
    413                         tmpfilefd = mkstemps( tmpname, 2 );
     433                        tmpfilefd = mkstemps( tmpname, 4 );
    414434                        if ( tmpfilefd == -1 ) {
    415435                                perror( "CC1 Translator error: stage 2, mkstemp" );
     
    427447
    428448        if ( fork() == 0 ) {                                                            // child runs CFA
    429                 cargs[0] = ( *new string( installlibdir + "cfa-cpp" ) ).c_str();
    430 
     449                cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
    431450                cargs[ncargs++] = cpp_in;
    432451
     
    438457                        cargs[ncargs++] = cfa_cpp_out.c_str();
    439458                } // if
    440                 cargs[ncargs] = nullptr;                                                        // terminate argument list
     459
     460                cargs[ncargs++] = color_names[color_arg];
     461
     462                cargs[ncargs] = nullptr;                                                // terminate argument list
    441463
    442464                #ifdef __DEBUG_H__
     
    448470
    449471                execvp( cargs[0], (char * const *)cargs );              // should not return
    450                 perror( "CC1 Translator error: stage 2, execvp" );
     472                perror( "CC1 Translator error: stage 2 cfa-cpp, execvp" );
     473                cerr << " invoked " << cargs[0] << endl;
    451474                exit( EXIT_FAILURE );
    452475        } // if
     
    484507                args[0] = compiler_path.c_str();
    485508                args[nargs++] = "-S";                                                   // only compile and put assembler output in specified file
    486                 if ( save_temps ) {                                                             // make gcc accept .ifa suffix
    487                         args[nargs++] = "-x";
    488                         args[nargs++] = "cpp-output";
    489                 } // if
     509                args[nargs++] = "-x";
     510                args[nargs++] = "cpp-output";
     511
    490512                args[nargs++] = cfa_cpp_out.c_str();
    491513                args[nargs] = nullptr;                                                  // terminate argument list
     
    500522
    501523                execvp( args[0], (char * const *)args );                // should not return
    502                 perror( "CC1 Translator error: stage 2, execvp" );
     524                perror( "CC1 Translator error: stage 2 cc1, execvp" );
     525                cerr << " invoked " << args[0] << endl;
    503526                exit( EXIT_FAILURE );                                                   // tell gcc not to go any further
    504527        } // if
    505528
    506529        wait( &code );                                                                          // wait for child to finish
     530        rmtmpfile();                                                                            // remove tmpname
    507531
    508532        if ( WIFSIGNALED(code) ) {                                                      // child failed ?
    509                 rmtmpfile();                                                                    // remove tmpname
    510533                cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
    511534                exit( EXIT_FAILURE );
     
    516539        #endif // __DEBUG_H__
    517540
    518         rmtmpfile();                                                                            // remove tmpname
    519541        exit( WEXITSTATUS( code ) );                                            // stop regardless of success or failure
    520542} // Stage2
Note: See TracChangeset for help on using the changeset viewer.