Changeset 7cd8827 for driver/cfa.cc


Ignore:
Timestamp:
Aug 14, 2018, 4:10:58 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
636e1b9
Parents:
c3a8ecd (diff), 5a5d31a (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' of plg2:software/cfa/cfa-cc

File:
1 moved

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    rc3a8ecd r7cd8827  
    2121#include <string.h>                                                                             // strcmp
    2222
     23#include <sys/types.h>
     24#include <sys/stat.h>
     25
    2326#include "Common/SemanticError.h"
    2427#include "config.h"                                                                             // configure info
     
    6669} // shuffle
    6770
     71static inline bool dirExists(const string & path) {
     72    struct stat info;
     73    if(stat( path.c_str(), &info ) != 0)
     74        return false;
     75    else if(info.st_mode & S_IFDIR)
     76        return true;
     77    else
     78        return false;
     79} //dirExists
     80
    6881
    6982#define str(s) #s
     
    7386        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
    7487
    75         string installincdir( CFA_INCDIR );                                     // fixed location of include files
    76         string installlibdir( CFA_LIBDIR );                                     // fixed location of cc1 and cfa-cpp commands
     88        string installincdir( CFA_INCDIR );                         // fixed location of include files
     89        string installlibdir( CFA_LIBDIR );                         // fixed location of cc1 and cfa-cpp commands when installed
     90        string srcdriverdir ( TOP_BUILDDIR "driver");                // fixed location of cc1 and cfa-cpp commands when in tree
    7791
    7892        string heading;                                                                         // banner printed at start of cfa compilation
     
    96110        bool xflag = false;                                                                     // user supplied -x flag
    97111        bool debugging __attribute(( unused )) = false;         // -g flag
     112        bool m32 = false;                                    // -m32 flag
     113        bool m64 = false;                                    // -m64 flag
     114        bool intree = false;
    98115
    99116        const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
     
    154171                        } else if ( arg == "-no-include-stdhdr" ) {
    155172                                noincstd_flag = true;                                   // strip the no-include-stdhdr flag
     173                        } else if ( arg == "-in-tree" ) {
     174                                intree = true;
    156175                        } else if ( arg == "-compiler" ) {
    157176                                // use the user specified compiler
     
    258277                                libs[nlibs] = argv[i];
    259278                                nlibs += 1;
     279                        } else if ( arg == "-m32" ) {
     280                                m32 = true;
     281                                m64 = false;
     282                                args[nargs] = argv[i];
     283                                nargs += 1;
     284                        } else if ( arg == "-m64" ) {
     285                                m64 = true;
     286                                m32 = false;
     287                                args[nargs] = argv[i];
     288                                nargs += 1;
    260289                        } else {
    261290                                // concatenate any other arguments
     
    309338
    310339        // add the CFA include-library paths, which allow direct access to header files without directory qualification
    311         args[nargs] = "-I" CFA_INCDIR;
    312         nargs += 1;
    313         if ( ! noincstd_flag ) {                                                        // do not use during build
    314                 args[nargs] = "-I" CFA_INCDIR "/stdhdr";
    315                 nargs += 1;
    316         } // if
    317         args[nargs] = "-I" CFA_INCDIR "/concurrency";
    318         nargs += 1;
    319         args[nargs] = "-I" CFA_INCDIR "/containers";
    320         nargs += 1;
     340        if( !intree ) {
     341                args[nargs] = "-I" CFA_INCDIR;
     342                nargs += 1;
     343                if ( ! noincstd_flag ) {                                                        // do not use during build
     344                        args[nargs] = "-I" CFA_INCDIR "/stdhdr";
     345                        nargs += 1;
     346                } // if
     347                args[nargs] = "-I" CFA_INCDIR "/concurrency";
     348                nargs += 1;
     349                args[nargs] = "-I" CFA_INCDIR "/containers";
     350                nargs += 1;
     351        } else {
     352                args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
     353                nargs += 1;
     354                if ( ! noincstd_flag ) {                                                        // do not use during build
     355                        args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
     356                        nargs += 1;
     357                } // if
     358                args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
     359                nargs += 1;
     360                args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
     361                nargs += 1;
     362        }
    321363
    322364        // add stdbool to get defines for bool/true/false
     
    326368        nargs += 1;
    327369
    328         #ifdef HAVE_LIBCFA
     370        string libbase;
     371        if( !intree ) {
     372                libbase = CFA_LIBDIR;
     373        } else {
     374                libbase = TOP_BUILDDIR "libcfa/";
     375                args[nargs] = "-D__CFA_FLAG__=-t";
     376                nargs += 1;
     377        }
     378
     379        const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
     380        const char * config = debug ? "debug": "nodebug";
     381        string libdir = libbase + arch + "-" + config;
     382        if( !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        }
     387
     388        if( !dirExists(libdir) ) {
     389                cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
     390                cerr << "Was looking for " << libdir << endl;
     391                exit( EXIT_FAILURE );
     392        }
     393
     394        args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
     395        nargs += 1;
     396
    329397        if ( link ) {
    330                 #if ! defined(HAVE_LIBCFA_RELEASE)
    331                 if ( ! debug ) {
    332                         cerr << "error: Option -nodebug is unavailable, libcfa was not installed." << endl;
    333                         exit( EXIT_FAILURE );
    334                 } // if
    335                 #endif
    336                 #if ! defined(HAVE_LIBCFA_DEBUG)
    337                 if ( debug ) {
    338                         cerr << "error: Option -debug is unavailable, libcfa-d was not installed." << endl;
    339                         exit( EXIT_FAILURE );
    340                 } // if
    341                 #endif
    342 
    343398                args[nargs] = "-Xlinker";
    344399                nargs += 1;
     
    359414
    360415                // include the cfa library in case it's needed
    361                 args[nargs] = "-L" CFA_LIBDIR;
    362                 nargs += 1;
    363                 if ( debug ) {
    364                         args[nargs] = "-lcfa-d";
    365                 } else {
    366                         args[nargs] = "-lcfa";
    367                 } // if
     416                args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src" : "")) ).c_str();
     417                nargs += 1;
     418                args[nargs] = "-lcfa";
    368419                nargs += 1;
    369420                args[nargs] = "-lpthread";
     
    374425                nargs += 1;
    375426        } // if
    376         #endif // HAVE_LIBCFA
    377427
    378428        // Add exception flags (unconditionally)
     
    420470
    421471        if ( Bprefix.length() == 0 ) {
    422                 Bprefix = installlibdir;
     472                Bprefix = !intree ? installlibdir : srcdriverdir;
    423473                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
    424474                nargs += 1;
    425475        } // if
    426476
    427     args[nargs] = "-Xlinker";                                                   // used by backtrace
    428     nargs += 1;
    429     args[nargs] = "-export-dynamic";
    430     nargs += 1;
     477        args[nargs] = "-Xlinker";                                                       // used by backtrace
     478        nargs += 1;
     479        args[nargs] = "-export-dynamic";
     480        nargs += 1;
    431481
    432482        // execute the compilation command
Note: See TracChangeset for help on using the changeset viewer.