Changeset 37fe352 for driver


Ignore:
Timestamp:
Aug 5, 2018, 4:11:41 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
28582b2
Parents:
4dcaed2
Message:

Added proper multi-lib handling, tests still do not work and arm support is broken

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    r4dcaed2 r37fe352  
    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
     
    96109        bool xflag = false;                                                                     // user supplied -x flag
    97110        bool debugging __attribute(( unused )) = false;         // -g flag
     111        bool m32 = false;                                    // -m32 flag
     112        bool m64 = false;                                    // -m64 flag
     113        bool intree = false;
    98114
    99115        const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
     
    154170                        } else if ( arg == "-no-include-stdhdr" ) {
    155171                                noincstd_flag = true;                                   // strip the no-include-stdhdr flag
     172                        } else if ( arg == "-in-tree" ) {
     173                                noincstd_flag = true;
     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
     
    320349        nargs += 1;
    321350
     351        string libdir;
     352        if( !intree ) {
     353                const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
     354                const char * config = debug ? "debug": "nodebug";
     355                libdir = string(CFA_LIBDIR) + arch + config;
     356                if( !dirExists(libdir) ) {
     357                        cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
     358                        cerr << "Was looking for " << libdir << endl;
     359                        libdir = string(CFA_LIBDIR) + arch + "nolib";
     360                }
     361
     362                if( !dirExists(libdir) ) {
     363                        cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
     364                        cerr << "Was looking for " << libdir << endl;
     365                        exit( EXIT_FAILURE );
     366                }
     367
     368                args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir) ).c_str();
     369                nargs += 1;
     370        } else {
     371                args[nargs] = "-D__CFA_FLAG__=-t";
     372                nargs += 1;
     373        }
     374
    322375        if ( link ) {
    323376                args[nargs] = "-Xlinker";
     
    335388
    336389                // include the cfa library in case it's needed
    337                 args[nargs] = "-L" CFA_LIBDIR;
    338                 nargs += 1;
    339                 if ( debug ) {
    340                         args[nargs] = "-lcfa-d";
    341                 } else {
    342                         args[nargs] = "-lcfa";
    343                 } // if
     390                if( !intree ) {
     391                        args[nargs] = ( *new string( string("-L" ) + libdir) ).c_str();
     392                        nargs += 1;
     393                }
     394                args[nargs] = "-lcfa";
    344395                nargs += 1;
    345396                args[nargs] = "-lpthread";
     
    400451        } // if
    401452
    402     args[nargs] = "-Xlinker";                                                   // used by backtrace
    403     nargs += 1;
    404     args[nargs] = "-export-dynamic";
    405     nargs += 1;
     453        args[nargs] = "-Xlinker";                                                       // used by backtrace
     454        nargs += 1;
     455        args[nargs] = "-export-dynamic";
     456        nargs += 1;
    406457
    407458        // execute the compilation command
Note: See TracChangeset for help on using the changeset viewer.