Changeset cde3891 for driver/cfa.cc


Ignore:
Timestamp:
Jan 23, 2019, 4:52:16 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
a200795
Parents:
9b086ca (diff), 1d832f4 (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:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    r9b086ca rcde3891  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 23 15:41:55 2018
    13 // Update Count     : 270
     12// Last Modified On : Tue Jan 15 20:56:03 2019
     13// Update Count     : 280
    1414//
    1515
     
    4343const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    4444
    45 void suffix( string arg, const char * args[], int & nargs ) {
     45bool suffix( string arg, const char * args[], int & nargs ) {
    4646        //std::cerr << arg << std::endl;
    4747        size_t dot = arg.find_last_of( "." );
    4848        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    49         if ( dot == string::npos ) return;
     49        if ( dot == string::npos ) return false;
    5050        string sx = arg.substr( dot + 1 );
    5151        for ( int i = 0; i < NumSuffixes; i += 1 ) {
     
    5555                        args[nargs] = "c";
    5656                        nargs += 1;
    57                         return;
     57                        return true;
    5858                } // if
    5959        } // for
     60        return false;
    6061} // suffix
    6162
     
    113114        bool std_flag = false;                                                          // -std= flag
    114115        bool noincstd_flag = false;                                                     // -no-include-stdhdr= flag
    115         bool xflag = false;                                                                     // user supplied -x flag
    116116        bool debugging __attribute(( unused )) = false;         // -g flag
    117117        bool m32 = false;                                    // -m32 flag
     
    128128        #ifdef __DEBUG_H__
    129129        cerr << "CFA:" << endl;
     130        for ( int i = 1; i < argc; i += 1 ) {
     131            cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     132        } // for
    130133        #endif // __DEBUG_H__
    131134
     
    133136
    134137        for ( int i = 1; i < argc; i += 1 ) {
    135                 #ifdef __DEBUG_H__
    136                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    137                 #endif // __DEBUG_H__
    138138                arg = argv[i];                                                                  // convert to string value
    139                 #ifdef __DEBUG_H__
    140                 cerr << "arg:\"" << arg << "\"" << endl;
    141                 #endif // __DEBUG_H__
    142139                if ( prefix( arg, "-" ) ) {
    143140                        // pass through arguments
     
    202199                                args[nargs] = argv[i];                                  // pass the argument along
    203200                                nargs += 1;
    204                         } else if ( arg == "-x" ) {
    205                                 xflag = true;
    206                                 args[nargs] = argv[i];                                  // pass the argument along
    207                                 nargs += 1;
    208                                 i += 1;                                                                 // advance to argument
    209                                 args[nargs] = argv[i];                                  // pass the argument along
    210                                 nargs += 1;
    211                                 // args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x
    212                                 // nargs += 1;
    213                         } else if ( prefix( arg, "-x" ) ) {
    214                                 xflag = true;
    215                                 args[nargs] = argv[i];                                  // pass the argument along
    216                                 nargs += 1;
    217                                 // args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x
    218                                 // nargs += 1;
    219201                        } else if ( arg == "-w" ) {
    220202                                args[nargs] = argv[i];                                  // pass the argument along
     
    298280                        } // if
    299281                } else {
    300                         bool opt = false;
    301                         if ( ! xflag ) {
    302                                 suffix( arg, args, nargs );                             // check suffix
    303                                 // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x
    304                                 // nargs += 1;
    305                                 opt = true;
    306                         } // if
    307                         // concatenate other arguments
    308                         args[nargs] = argv[i];
    309                         nargs += 1;
    310                         if ( opt ) {
     282                        bool cfa = suffix( arg, args, nargs );          // check suffix
     283                        args[nargs] = argv[i];                                          // concatenate file
     284                        nargs += 1;
     285                        if ( cfa ) {
    311286                                args[nargs] = "-x";
    312287                                nargs += 1;
    313288                                args[nargs] = "none";
    314289                                nargs += 1;
    315                                 // args[nargs] = ( *new string( string("-D__GCC_X__=none") ) ).c_str(); // add the argument for -x
    316                                 // nargs += 1;
    317290                        } // if
    318291                        nonoptarg = true;
    319                         xflag = false;
    320292                } // if
    321293        } // for
     294
     295    args[nargs] = "-x";                                                                 // turn off language
     296    nargs += 1;
     297    args[nargs] = "none";
     298    nargs += 1;
    322299
    323300        #ifdef __x86_64__
     
    380357
    381358        string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
    382         if ( ! m32 && ! m64 && arch == "x86" ) {                        // no override and 32-bit architecture
    383                 args[nargs] = "-m32";
    384                 nargs += 1;
     359        if ( ! m32 && ! m64 ) {
     360                if ( arch == "x86" ) {
     361                        args[nargs] = "-m32";
     362                        nargs += 1;
     363                } else if ( arch == "x64" ) {
     364                        args[nargs] = "-m64";
     365                        nargs += 1;
     366                }  // if
    385367        } // if
    386368        const char * config = debug ? "debug": "nodebug";
     
    402384        nargs += 1;
    403385
     386        for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries
     387                args[nargs] = libs[i];
     388                nargs += 1;
     389        } // for
     390
    404391        if ( link ) {
    405392                args[nargs] = "-Xlinker";
     
    421408
    422409                // include the cfa library in case it's needed
    423                 args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src" : "")) ).c_str();
     410                args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     411                nargs += 1;
     412                args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    424413                nargs += 1;
    425414                args[nargs] = "-lcfa";
     
    430419                nargs += 1;
    431420                args[nargs] = "-lrt";
     421                nargs += 1;
     422                args[nargs] = "-lm";
    432423                nargs += 1;
    433424        } // if
     
    514505                args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
    515506                nargs += 1;
    516                 args[nargs] = "-lm";
    517                 nargs += 1;
    518507        } else {
    519508                cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
    520509                exit( EXIT_FAILURE );
    521510        } // if
    522 
    523         for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries
    524                 args[nargs] = libs[i];
    525                 nargs += 1;
    526         } // for
    527511
    528512        args[nargs] = NULL;                                                                     // terminate with NULL
Note: See TracChangeset for help on using the changeset viewer.