Changeset 36de20d


Ignore:
Timestamp:
Aug 17, 2020, 6:18:34 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
794db28
Parents:
762fbc1
Message:

formatting, update how bprefix is handled from the command line versus default value

Location:
driver
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    r762fbc1 r36de20d  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 13 21:03:15 2020
    13 // Update Count     : 407
     12// Last Modified On : Sun Aug 16 21:03:02 2020
     13// Update Count     : 413
    1414//
    1515
     
    2424#include <unistd.h>                                                                             // execvp, fork, unlink
    2525#include <sys/wait.h>                                                                   // wait
    26 #include <fcntl.h>
     26#include <fcntl.h>                                                                              // creat
    2727
    2828
     
    5959
    6060
    61 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
     61static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "__CFA_FLAG__=" suffix
    6262
    6363static void checkEnv1( const char * args[], int & nargs ) { // stage 1
     
    111111} // checkEnv2
    112112
    113 
    114 static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa";
     113#define CFA_SUFFIX ".ifa"
     114
     115static char tmpname[] = P_tmpdir "/CFAXXXXXX" CFA_SUFFIX;
    115116static int tmpfilefd = -1;
    116117static bool startrm = false;
     
    321322
    322323        if ( WIFSIGNALED(code) ) {                                                      // child failed ?
     324                rmtmpfile();                                                                    // remove tmpname
    323325                cerr << "CC1 Translator error: stage 1, child failed " << WTERMSIG(code) << endl;
    324326                exit( EXIT_FAILURE );
    325327        } // if
    326328
    327         exit( WEXITSTATUS(code) );                                                      // bad cpp result stops top-level gcc
     329        exit( WEXITSTATUS( code ) );                                            // bad cpp result stops top-level gcc
    328330} // Stage1
    329331
     
    373375                        } else if ( arg == "-fno-diagnostics-color" ) {
    374376                                color_arg = Color_Auto;
    375                         }
     377                        } // if
    376378
    377379                        if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
    378                                 // Currently CFA does not suppose precompiled .h files.
    379                                 prefix( arg, "--output-pch" ) ) {
     380                                 // Currently CFA does not suppose precompiled .h files.
     381                                 prefix( arg, "--output-pch" ) ) {
    380382
    381383                                // strip inappropriate flags with an argument
     
    441443                        } // if
    442444
    443                         cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + ".ifa";
     445                        cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + CFA_SUFFIX;
    444446                        if ( creat( cfa_cpp_out.c_str(), 0666 ) == -1 ) {
    445447                                perror( "CC1 Translator error: stage 2, creat" );
     
    462464        // output.  Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
    463465
    464         if ( fork() == 0 ) {                                                            // child runs CFA
     466        if ( fork() == 0 ) {                                                            // child runs CFA preprocessor
    465467                cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
    466468                cargs[ncargs++] = cpp_in;
     
    520522        #endif // __DEBUG_H__
    521523
    522         if ( fork() == 0 ) {                                                            // child runs CFA
     524        if ( fork() == 0 ) {                                                            // child runs gcc
    523525                args[0] = compiler_path.c_str();
    524526                args[nargs++] = "-S";                                                   // only compile and put assembler output in specified file
  • driver/cfa.cc

    r762fbc1 r36de20d  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 14 07:22:03 2020
    13 // Update Count     : 437
     12// Last Modified On : Sun Aug 16 23:05:59 2020
     13// Update Count     : 447
    1414//
    1515
     
    1818#include <cstdlib>                                                                              // putenv, exit
    1919#include <climits>                                                                              // PATH_MAX
     20#include <string>                                                                               // STL version
     21#include <algorithm>                                                                    // find
     22
    2023#include <unistd.h>                                                                             // execvp
    21 #include <string>                                                                               // STL version
    22 #include <string.h>                                                                             // strcmp
    23 #include <algorithm>                                                                    // find
    24 
    2524#include <sys/types.h>
    2625#include <sys/stat.h>
     
    3433using std::to_string;
    3534
    36 // #define __DEBUG_H__
     35//#define __DEBUG_H__
    3736
    3837#define xstr(s) str(s)
    3938#define str(s) #s
    4039
    41 // "N__=" suffix
    42 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
     40static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "__CFA_FLAG__=" suffix
    4341
    4442static void Putenv( char * argv[], string arg ) {
     
    156154        PathMode path = FromProc();
    157155
    158         const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
     156        const char * args[argc + 100];                                          // cfa command line values, plus some space for additional flags
    159157        int sargs = 1;                                                                          // starting location for arguments in args list
    160158        int nargs = sargs;                                                                      // number of arguments in args list; 0 => command name
    161159
    162         const char *libs[argc + 20];                                            // non-user libraries must come separately, plus some added libraries and flags
     160        const char * libs[argc + 20];                                           // non-user libraries must come separately, plus some added libraries and flags
    163161        int nlibs = 0;
    164162
     
    183181                                args[nargs++] = argv[i];                                // pass argument along
    184182                                if ( arg == "-o" ) o_file = i;                  // remember file
     183
     184                                // CFA specific arguments
     185
    185186                        } else if ( strncmp(arg.c_str(), "-XCFA", 5) == 0 ) { // CFA pass through
    186187                                if ( arg.size() == 5 ) {
     
    201202                        } else if ( arg == "-nodebug" ) {
    202203                                debug = false;                                                  // strip the nodebug flag
    203                         } else if ( arg == "-nolib" ) {
    204                                 nolib = true;                                                   // strip the nodebug flag
    205204                        } else if ( arg == "-quiet" ) {
    206205                                quiet = true;                                                   // strip the quiet flag
    207206                        } else if ( arg == "-noquiet" ) {
    208207                                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
    209212                        } else if ( arg == "-help" ) {
    210213                                help = true;                                                    // strip the help flag
    211214                        } else if ( arg == "-nohelp" ) {
    212215                                help = false;                                                   // strip the nohelp flag
    213                         } else if ( arg == "-no-include-stdhdr" ) {
    214                                 noincstd_flag = true;                                   // strip the no-include-stdhdr flag
    215216                        } else if ( arg == "-cfalib") {
    216217                                compiling_libs = true;
     
    334335        string libbase;
    335336        switch(path) {
    336         case Installed:
     337          case Installed:
    337338                args[nargs++] = "-I" CFA_INCDIR;
    338339                // do not use during build
     
    344345                libbase = CFA_LIBDIR;
    345346                break;
    346         case BuildTree:
    347         case Distributed:
     347          case BuildTree:
     348          case Distributed:
    348349                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src";
    349350                // do not use during build
     
    379380        string libdir = libbase + arch + "-" + config;
    380381
    381         if (path != Distributed) {
     382        if ( path != Distributed ) {
    382383                if ( ! nolib && ! dirExists( libdir ) ) {
    383384                        cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
     
    399400        string preludedir;
    400401        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
    405406
    406407        Putenv( argv, "--prelude-dir=" + preludedir );
     
    474475        if ( bprefix.length() == 0 ) {
    475476                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         } // if
     477                  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 );
    483484
    484485        args[nargs++] = "-Xlinker";                                                     // used by backtrace
     
    502503                args[nargs++] = "-Wno-cast-function-type";
    503504                #endif // HAVE_CAST_FUNCTION_TYPE
    504                 if ( ! std_flag ) {                                                             // default c11, if none specified
    505                         args[nargs++] = "-std=gnu11";
     505                if ( ! std_flag && ! x_flag ) {
     506                        args[nargs++] = "-std=gnu11";                           // default c11, if none specified
    506507                } // if
    507508                args[nargs++] = "-fgnu89-inline";
     
    553554        // execute the command and return the result
    554555
    555         execvp( args[0], (char *const *)args );                         // should not return
     556        execvp( args[0], (char * const *)args );                        // should not return
    556557        perror( "CFA Translator error: execvp" );
    557558        exit( EXIT_FAILURE );
Note: See TracChangeset for help on using the changeset viewer.