Changeset 2c60af75 for driver/cfa.cc


Ignore:
Timestamp:
Aug 23, 2019, 6:43:43 AM (5 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:
ef22ad6
Parents:
e0bd0f9
Message:

move cfa-cpp into stage 2 of cc1, and update cfa to facilitate the change

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    re0bd0f9 r2c60af75  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 10 08:44:15 2019
    13 // Update Count     : 311
     12// Last Modified On : Thu Aug 22 22:29:50 2019
     13// Update Count     : 403
    1414//
    1515
     
    2828#include "config.h"                                                                             // configure info
    2929
    30 
    3130using std::cerr;
    3231using std::endl;
     
    3433using std::to_string;
    3534
    36 
    3735//#define __DEBUG_H__
    3836
    3937
    40 bool prefix( string arg, string pre ) {
     38void Putenv( char * argv[], string arg ) {
     39        static int flags = 0;                                                           // environment variables must have unique names
     40
     41        if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) != 0 ) {
     42                cerr << argv[0] << " error, cannot set environment variable." << endl;
     43                exit( EXIT_FAILURE );
     44        } // if
     45} // Putenv
     46
     47
     48bool prefix( const string & arg, const string & pre ) { // check if string has prefix
    4149        return arg.substr( 0, pre.size() ) == pre;
    4250} // prefix
    4351
    44 bool suffix( string arg ) {
     52bool suffix( const string & arg ) {                                             // check if string has suffix
    4553        enum { NumSuffixes = 3 };
    4654        static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
    47         //std::cerr << arg << std::endl;
     55
    4856        size_t dot = arg.find_last_of( "." );
    49         //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    5057        if ( dot == string::npos ) return false;
    5158        const string * end = suffixes + NumSuffixes;
     
    5461
    5562
    56 void shuffle( const char * args[], int S, int E, int N ) {
    57         // S & E index 1 passed the end so adjust with -1
    58         #ifdef __DEBUG_H__
    59         cerr << "shuffle:" << S << " " << E << " " << N << endl;
    60         #endif // __DEBUG_H__
    61         for ( int j = E-1 + N; j > S-1 + N; j -=1 ) {
    62                 #ifdef __DEBUG_H__
    63                 cerr << "\t" << j << " " << j-N << endl;
    64                 #endif // __DEBUG_H__
    65                 args[j] = args[j-N];
    66         } // for
    67 } // shuffle
    68 
    69 static inline bool dirExists( const string & path ) {
     63static inline bool dirExists( const string & path ) {   // check if directory exists
    7064    struct stat info;
    71     if(stat( path.c_str(), &info ) != 0)
    72         return false;
    73     else if(info.st_mode & S_IFDIR)
    74         return true;
    75     else
    76         return false;
    77 } //dirExists
    78 
    79 
     65    if ( stat( path.c_str(), &info ) != 0 ) return false;
     66    if ( info.st_mode & S_IFDIR ) return true;
     67        return false;
     68} // dirExists
     69
     70
     71#define xstr(s) str(s)
    8072#define str(s) #s
    8173
    8274int main( int argc, char * argv[] ) {
    8375        string Version( CFA_VERSION_LONG );                                     // current version number from CONFIG
    84         string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
     76        string Major( xstr( CFA_VERSION_MAJOR ) ), Minor( xstr( CFA_VERSION_MINOR ) ), Patch( xstr( CFA_VERSION_PATCH ) );
    8577
    8678        string installincdir( CFA_INCDIR );                                     // fixed location of include files
     
    112104        bool m64 = false;                                                                       // -m64 flag
    113105        bool intree = false;
     106        int o_file = 0;                                                                         // -o filename position
    114107
    115108        const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
     
    135128
    136129                        if ( arg == "-Xlinker" || arg == "-o" ) {
    137                                 args[nargs] = argv[i];                                  // pass the argument along
    138                                 nargs += 1;
     130                                args[nargs++] = argv[i];                                // pass argument along
    139131                                i += 1;
    140132                                if ( i == argc ) continue;                              // next argument available ?
    141                                 args[nargs] = argv[i];                                  // pass the argument along
    142                                 nargs += 1;
     133                                args[nargs++] = argv[i];                                // pass argument along
     134                                if ( arg == "-o" ) o_file = i;                  // remember file
    143135                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
    144136                                i += 1;
    145                                 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + argv[i] ) ).c_str();
    146                                 nargs += 1;
     137                                Putenv( argv, argv[i] );
    147138
    148139                                // CFA specific arguments
     
    151142                                CFA_flag = true;                                                // strip the -CFA flag
    152143                                link = false;
    153                                 args[nargs] = "-E";                                             // replace the argument with -E
    154                                 nargs += 1;
     144                                args[nargs++] = "-fsyntax-only";                // stop after stage 2
    155145                        } else if ( arg == "-debug" ) {
    156146                                debug = true;                                                   // strip the debug flag
    157147                        } else if ( arg == "-nodebug" ) {
    158                                 debug = false;                                                  // strip the debug flag
     148                                debug = false;                                                  // strip the nodebug flag
    159149                        } else if ( arg == "-nolib" ) {
    160150                                nolib = true;                                                   // strip the nodebug flag
     
    176166                                if ( i == argc ) continue;                              // next argument available ?
    177167                                compiler_path = argv[i];
    178                                 if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
    179                                         cerr << argv[0] << " error, cannot set environment variable." << endl;
    180                                         exit( EXIT_FAILURE );
    181                                 } // if
     168                                Putenv( argv, arg + "=" + argv[i] );
    182169
    183170                                // C specific arguments
     
    185172                        } else if ( arg == "-v" ) {
    186173                                verbose = true;                                                 // verbosity required
    187                                 args[nargs] = argv[i];                                  // pass the argument along
    188                                 nargs += 1;
     174                                args[nargs++] = argv[i];                                // pass argument along
    189175                        } else if ( arg == "-g" ) {
    190176                                debugging = true;                                               // symbolic debugging required
    191                                 args[nargs] = argv[i];                                  // pass the argument along
    192                                 nargs += 1;
     177                                args[nargs++] = argv[i];                                // pass argument along
    193178                        } else if ( prefix( arg, "-x" ) ) {                     // file suffix ?
    194179                                string lang;
    195                                 args[nargs] = argv[i];                                  // pass the argument along
    196                                 nargs += 1;
     180                                args[nargs++] = argv[i];                                // pass argument along
    197181                                if ( arg.length() == 2 ) {                              // separate argument ?
    198182                                        i += 1;
    199183                                        if ( i == argc ) continue;                      // next argument available ?
    200184                                        lang = argv[i];
    201                                         args[nargs] = argv[i];                          // pass the argument along
    202                                         nargs += 1;
     185                                        args[nargs++] = argv[i];                        // pass argument along
    203186                                } else {
    204187                                        lang = arg.substr( 2 );
     
    207190                        } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
    208191                                std_flag = true;                                                // -std=XX provided
    209                                 args[nargs] = argv[i];                                  // pass the argument along
    210                                 nargs += 1;
     192                                args[nargs++] = argv[i];                                // pass argument along
    211193                        } else if ( arg == "-w" ) {
    212                                 args[nargs] = argv[i];                                  // pass the argument along
    213                                 nargs += 1;
    214                                 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
    215                                 nargs += 1;
     194                                args[nargs++] = argv[i];                                // pass argument along
     195                                Putenv( argv, arg );
    216196                        } else if ( prefix( arg, "-W" ) ) {                     // check before next tests
    217197                                if ( arg == "-Werror" || arg == "-Wall" ) {
    218                                         args[nargs] = argv[i];                          // pass the argument along
    219                                         nargs += 1;
    220                                         args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
    221                                         nargs += 1;
     198                                        args[nargs++] = argv[i];                        // pass argument along
     199                                        Putenv( argv, argv[i] );
    222200                                } else {
    223201                                        unsigned int adv = prefix( arg, "-Wno-" ) ? 5 : 2;
    224                                         args[nargs] = argv[i];                          // conditionally pass the argument along
    225                                         const char * warning = argv[i] + adv;    // extract warning
     202                                        args[nargs] = argv[i];                          // conditionally pass argument along
     203                                        const char * warning = argv[i] + adv; // extract warning
    226204                                        if ( SemanticWarning_Exist( warning ) ) { // replace the argument for cfa-cpp
    227                                                 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str();
     205                                                Putenv( argv, arg );
    228206                                        } // if
    229207                                        nargs += 1;
     
    231209                        } else if ( prefix( arg, "-B" ) ) {
    232210                                Bprefix = arg.substr(2);                                // strip the -B flag
    233                                 args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
    234                                 nargs += 1;
    235                         } else if ( prefix( arg, "-b" ) ) {
    236                                 if ( arg.length() == 2 ) {                              // separate argument ?
    237                                         i += 1;
    238                                         if ( i == argc ) continue;                      // next argument available ?
    239                                         arg += argv[i];                                         // concatenate argument
    240                                 } // if
    241                                 // later versions of gcc require the -b option to appear at the start of the command line
    242                                 shuffle( args, sargs, nargs, 1 );               // make room at front of argument list
    243                                 args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
    244                                 if ( putenv( (char *)( *new string( string( "__GCC_MACHINE__=" ) + arg ) ).c_str() ) != 0 ) {
    245                                         cerr << argv[0] << " error, cannot set environment variable." << endl;
    246                                         exit( EXIT_FAILURE );
    247                                 } // if
    248                                 sargs += 1;
    249                                 nargs += 1;
    250                         } else if ( prefix( arg, "-V" ) ) {
    251                                 if ( arg.length() == 2 ) {                              // separate argument ?
    252                                         i += 1;
    253                                         if ( i == argc ) continue;                      // next argument available ?
    254                                         arg += argv[i];                                         // concatenate argument
    255                                 } // if
    256                                 // later versions of gcc require the -V option to appear at the start of the command line
    257                                 shuffle( args, sargs, nargs, 1 );               // make room at front of argument list
    258                                 args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
    259                                 if ( putenv( (char *)( *new string( string( "__GCC_VERSION__=" ) + arg ) ).c_str() ) != 0 ) {
    260                                         cerr << argv[0] << " error, cannot set environment variable." << endl;
    261                                         exit( EXIT_FAILURE );
    262                                 } // if
    263                                 sargs += 1;
    264                                 nargs += 1;
     211                                args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
    265212                        } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) {
    266                                 args[nargs] = argv[i];                                  // pass the argument along
    267                                 nargs += 1;
     213                                args[nargs++] = argv[i];                                // pass argument along
    268214                                if ( arg == "-E" || arg == "-M" || arg == "-MM" ) {
    269215                                        cpp_flag = true;                                        // cpp only
     
    272218                        } else if ( arg[1] == 'l' ) {
    273219                                // if the user specifies a library, load it after user code
    274                                 libs[nlibs] = argv[i];
    275                                 nlibs += 1;
     220                                libs[nlibs++] = argv[i];
    276221                        } else if ( arg == "-m32" ) {
    277222                                m32 = true;
    278223                                m64 = false;
    279                                 args[nargs] = argv[i];
    280                                 nargs += 1;
     224                                args[nargs++] = argv[i];
    281225                        } else if ( arg == "-m64" ) {
    282226                                m64 = true;
    283227                                m32 = false;
    284                                 args[nargs] = argv[i];
    285                                 nargs += 1;
     228                                args[nargs++] = argv[i];
    286229                        } else {
    287230                                // concatenate any other arguments
    288                                 args[nargs] = argv[i];
    289                                 nargs += 1;
     231                                args[nargs++] = argv[i];
    290232                        } // if
    291233                } else {
    292234                        bool cfa = suffix( arg );                                       // check suffix
    293235                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
    294                                 args[nargs] = "-x";
    295                                 nargs += 1;
    296                                 args[nargs] = "c";
    297                                 nargs += 1;
     236                                args[nargs++] = "-x";
     237                                args[nargs++] = "c";
    298238                        } // if
    299                         args[nargs] = argv[i];                                          // concatenate file
    300                         nargs += 1;
     239                        args[nargs++] = argv[i];                                        // concatenate files
    301240                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
    302                                 args[nargs] = "-x";
    303                                 nargs += 1;
    304                                 args[nargs] = "none";
    305                                 nargs += 1;
     241                                args[nargs++] = "-x";
     242                                args[nargs++] = "none";
    306243                        } // if
    307244                        nonoptarg = true;
     
    310247
    311248        #ifdef __x86_64__
    312         args[nargs] = "-mcx16";                                                         // allow double-wide CAA
    313         nargs += 1;
     249        args[nargs++] = "-mcx16";                                                       // allow double-wide CAA
    314250        #endif // __x86_64__
    315251
     
    322258        #endif // __DEBUG_H__
    323259
    324         if ( cpp_flag && CFA_flag ) {
    325                 cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
    326                 exit( EXIT_FAILURE );
    327         } // if
     260        // if ( cpp_flag && CFA_flag ) {
     261        //      cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
     262        //      exit( EXIT_FAILURE );
     263        // } // if
    328264
    329265        // add the CFA include-library paths, which allow direct access to header files without directory qualification
    330         if( !intree ) {
    331                 args[nargs] = "-I" CFA_INCDIR;
    332                 nargs += 1;
     266        if ( ! intree ) {
     267                args[nargs++] = "-I" CFA_INCDIR;
    333268                if ( ! noincstd_flag ) {                                                // do not use during build
    334                         args[nargs] = "-I" CFA_INCDIR "stdhdr";
    335                         nargs += 1;
     269                        args[nargs++] = "-I" CFA_INCDIR "stdhdr";
    336270                } // if
    337                 args[nargs] = "-I" CFA_INCDIR "concurrency";
    338                 nargs += 1;
    339                 args[nargs] = "-I" CFA_INCDIR "containers";
    340                 nargs += 1;
    341         } else {
    342                 args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
    343                 nargs += 1;
     271                args[nargs++] = "-I" CFA_INCDIR "concurrency";
     272                args[nargs++] = "-I" CFA_INCDIR "containers";
     273        } else {
     274                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src";
    344275                if ( ! noincstd_flag ) {                                                // do not use during build
    345                         args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
    346                         nargs += 1;
     276                        args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
    347277                } // if
    348                 args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
    349                 nargs += 1;
    350                 args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
    351                 nargs += 1;
    352         }
     278                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
     279                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
     280        } // if
    353281
    354282        // add stdbool to get defines for bool/true/false
    355         args[nargs] = "-imacros";
    356         nargs += 1;
    357         args[nargs] = "stdbool.h";
    358         nargs += 1;
     283        args[nargs++] = "-imacros";
     284        args[nargs++] = "stdbool.h";
    359285
    360286        string libbase;
    361         if( !intree ) {
     287        if ( ! intree ) {
    362288                libbase = CFA_LIBDIR;
    363289        } else {
    364290                libbase = TOP_BUILDDIR "libcfa/";
    365                 args[nargs] = "-D__CFA_FLAG__=-t";
    366                 nargs += 1;
    367         }
     291                Putenv( argv, "-t" );
     292        } // if
    368293
    369294        string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
    370295        if ( ! m32 && ! m64 ) {
    371296                if ( arch == "x86" ) {
    372                         args[nargs] = "-m32";
    373                         nargs += 1;
     297                        args[nargs++] = "-m32";
    374298                } else if ( arch == "x64" ) {
    375                         args[nargs] = "-m64";
    376                         nargs += 1;
     299                        args[nargs++] = "-m64";
    377300                }  // if
    378301        } // if
    379         const char * config = nolib ? "nolib" : (debug ? "debug": "nodebug");
    380         string libdir = libbase + arch + "-" + config;
    381 
    382         if ( ! nolib && ! dirExists( libdir ) ) {
    383                 cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
    384                 cerr << "Was looking for " << libdir << endl;
    385                 libdir = libbase + arch + "-" + "nolib";
    386         } // if
    387 
     302
     303        string libdir = libbase + arch + "-" + (nolib ? "nolib" : (debug ? "debug": "nodebug"));
    388304        if ( ! dirExists( libdir ) ) {
    389                 cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
    390                 cerr << "Was looking for " << libdir << endl;
     305                cerr << argv[0] << " internal error, cannot find prelude directory " << libdir << endl;
    391306                exit( EXIT_FAILURE );
    392307        } // if
    393308
    394         args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
    395         nargs += 1;
    396 
    397309        for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries
    398                 args[nargs] = libs[i];
    399                 nargs += 1;
     310                args[nargs++] = libs[i];
    400311        } // for
    401312
    402313        if ( link ) {
    403                 args[nargs] = "-Xlinker";
    404                 nargs += 1;
    405                 args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
    406                 nargs += 1;
    407                 args[nargs] = "-Xlinker";
    408                 nargs += 1;
    409                 args[nargs] = "--undefined=__cfaabi_interpose_startup";
    410                 nargs += 1;
    411                 args[nargs] = "-Xlinker";
    412                 nargs += 1;
    413                 args[nargs] = "--undefined=__cfaabi_appready_startup";
    414                 nargs += 1;
     314                args[nargs++] = "-Xlinker";
     315                args[nargs++] = "--undefined=__cfaabi_dbg_bits_write";
     316                args[nargs++] = "-Xlinker";
     317                args[nargs++] = "--undefined=__cfaabi_interpose_startup";
     318                args[nargs++] = "-Xlinker";
     319                args[nargs++] = "--undefined=__cfaabi_appready_startup";
    415320
    416321                // include the cfa library in case it's needed
    417                 args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    418                 nargs += 1;
    419                 args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    420                 nargs += 1;
    421                 args[nargs] = "-Wl,--push-state,--as-needed";
    422                 nargs += 1;
    423                 args[nargs] = "-lcfathread";
    424                 nargs += 1;
    425                 args[nargs] = "-Wl,--pop-state";
    426                 nargs += 1;
    427                 args[nargs] = "-lcfa";
    428                 nargs += 1;
    429                 args[nargs] = "-lpthread";
    430                 nargs += 1;
    431                 args[nargs] = "-ldl";
    432                 nargs += 1;
    433                 args[nargs] = "-lrt";
    434                 nargs += 1;
    435                 args[nargs] = "-lm";
    436                 nargs += 1;
    437         } // if
    438 
    439         // Add exception flags (unconditionally)
    440         args[nargs] = "-fexceptions";
    441         nargs += 1;
    442 
    443         // add the correct set of flags based on the type of compile this is
    444 
    445         args[nargs] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
    446         nargs += 1;
    447         args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
    448         nargs += 1;
    449         args[nargs] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
    450         nargs += 1;
    451         args[nargs] = "-D__CFA__";
    452         nargs += 1;
    453         args[nargs] = "-D__CFORALL__";
    454         nargs += 1;
    455         args[nargs] = "-D__cforall";
    456         nargs += 1;
     322                args[nargs++] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     323                args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     324                args[nargs++] = "-Wl,--push-state,--as-needed";
     325                args[nargs++] = "-lcfathread";
     326                args[nargs++] = "-Wl,--pop-state";
     327                args[nargs++] = "-lcfa";
     328                args[nargs++] = "-lpthread";
     329                args[nargs++] = "-ldl";
     330                args[nargs++] = "-lrt";
     331                args[nargs++] = "-lm";
     332        } // if
     333
     334        args[nargs++] = "-fexceptions";                                         // add exception flags (unconditionally)
     335
     336        // add flags based on the type of compile
     337
     338        args[nargs++] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
     339        args[nargs++] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
     340        args[nargs++] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
     341        args[nargs++] = "-D__CFA__";
     342        args[nargs++] = "-D__CFORALL__";
     343        args[nargs++] = "-D__cforall";
    457344
    458345        if ( cpp_flag ) {
    459                 args[nargs] = "-D__CPP__";
    460                 nargs += 1;
    461         } // if
    462 
    463         shuffle( args, sargs, nargs, 1 );                                       // make room at front of argument list
    464         nargs += 1;
     346                args[nargs++] = "-D__CPP__";
     347        } // if
     348
    465349        if ( CFA_flag ) {
    466                 args[sargs] = "-D__CFA_FLAG__=-N";
    467                 args[nargs] = "-D__CFA_PREPROCESS_";
    468                 nargs += 1;
    469         } else {
    470                 args[sargs] = "-D__CFA_FLAG__=-L";
    471         } // if
    472         sargs += 1;
     350                Putenv( argv, "-N" );
     351                Putenv( argv, "-CFA" );
     352                if ( o_file ) Putenv( argv, string( "-o=" ) + argv[o_file] );
     353        } else {
     354                Putenv( argv, "-L" );
     355        } // if
     356
     357        Putenv( argv, "--prelude-dir=" + libdir + (intree ? "/prelude" : "") );
    473358
    474359        if ( debug ) {
    475360                heading += " (debug)";
    476                 args[nargs] = "-D__CFA_DEBUG__";
    477                 nargs += 1;
     361                args[nargs++] = "-D__CFA_DEBUG__";
    478362        } else {
    479363                heading += " (no debug)";
     
    483367                Bprefix = ! intree ? installlibdir : srcdriverdir;
    484368                if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
    485                 args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
    486                 nargs += 1;
    487         } // if
    488 
    489         args[nargs] = "-Xlinker";                                                       // used by backtrace
    490         nargs += 1;
    491         args[nargs] = "-export-dynamic";
    492         nargs += 1;
     369                args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
     370        } // if
     371
     372        args[nargs++] = "-Xlinker";                                                     // used by backtrace
     373        args[nargs++] = "-export-dynamic";
    493374
    494375        // execute the compilation command
     
    504385
    505386        if ( prefix( compiler_name, "gcc" ) ) {                         // allow suffix on gcc name
    506                 args[nargs] = "-no-integrated-cpp";
    507                 nargs += 1;
    508                 args[nargs] = "-Wno-deprecated";
    509                 nargs += 1;
    510 #ifdef HAVE_CAST_FUNCTION_TYPE
    511                 args[nargs] = "-Wno-cast-function-type";
    512                 nargs += 1;
    513 #endif // HAVE_CAST_FUNCTION_TYPE
     387                args[nargs++] = "-no-integrated-cpp";
     388                args[nargs++] = "-Wno-deprecated";
     389                #ifdef HAVE_CAST_FUNCTION_TYPE
     390                args[nargs++] = "-Wno-cast-function-type";
     391                #endif // HAVE_CAST_FUNCTION_TYPE
    514392                if ( ! std_flag ) {                                                             // default c11, if none specified
    515                         args[nargs] = "-std=gnu11";
    516                         nargs += 1;
     393                        args[nargs++] = "-std=gnu11";
    517394                } // if
    518                 args[nargs] = "-fgnu89-inline";
    519                 nargs += 1;
    520                 args[nargs] = "-D__int8_t_defined";                             // prevent gcc type-size attributes
    521                 nargs += 1;
    522                 args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
    523                 nargs += 1;
     395                args[nargs++] = "-fgnu89-inline";
     396                args[nargs++] = "-D__int8_t_defined";                   // prevent gcc type-size attributes
     397                args[nargs++] = ( *new string( string("-B") + Bprefix ) ).c_str();
    524398        } else {
    525399                cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
     
    527401        } // if
    528402
    529         args[nargs] = NULL;                                                                     // terminate with NULL
     403        args[nargs] = NULL;                                                                     // terminate
    530404
    531405        #ifdef __DEBUG_H__
     
    568442
    569443        execvp( args[0], (char *const *)args );                         // should not return
    570         perror( "CFA Translator error: cfa level, execvp" );
     444        perror( "CFA Translator error: execvp" );
    571445        exit( EXIT_FAILURE );
    572446} // main
Note: See TracChangeset for help on using the changeset viewer.