source: driver/cfa.cc @ def9d4e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since def9d4e was def9d4e, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

change linker-file order

  • Property mode set to 100644
File size: 17.7 KB
RevLine 
[b87a5ed]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[76c7f65e]7// cfa.cc --
[b87a5ed]8//
[51b7345]9// Author           : Peter A. Buhr
10// Created On       : Tue Aug 20 13:44:49 2002
[201aeb9]11// Last Modified By : Peter A. Buhr
[def9d4e]12// Last Modified On : Tue Jan 15 20:56:03 2019
13// Update Count     : 280
[b87a5ed]14//
[51b7345]15
16#include <iostream>
[b87a5ed]17#include <cstdio>                                                                               // perror
18#include <cstdlib>                                                                              // putenv, exit
19#include <unistd.h>                                                                             // execvp
20#include <string>                                                                               // STL version
[44bca7f]21#include <string.h>                                                                             // strcmp
[51b7345]22
[37fe352]23#include <sys/types.h>
24#include <sys/stat.h>
25
[44bca7f]26#include "Common/SemanticError.h"
[b87a5ed]27#include "config.h"                                                                             // configure info
[51b7345]28
29using std::cerr;
30using std::endl;
31using std::string;
[47a8d17]32using std::to_string;
[51b7345]33
34
35//#define __DEBUG_H__
36
37
38bool prefix( string arg, string pre ) {
[b87a5ed]39        return arg.substr( 0, pre.size() ) == pre;
[51b7345]40} // prefix
41
[dffaeac]42enum { NumSuffixes = 2 };
43const string suffixes[NumSuffixes] = { "cfa", "hfa", };
44
[bec4d24]45bool suffix( string arg, const char * args[], int & nargs ) {
[dffaeac]46        //std::cerr << arg << std::endl;
47        size_t dot = arg.find_last_of( "." );
48        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
49        if ( dot == string::npos ) return false;
50        string sx = arg.substr( dot + 1 );
51        for ( int i = 0; i < NumSuffixes; i += 1 ) {
[b740f0b]52                if ( sx == suffixes[i] ) {
53                        args[nargs] = "-x";
54                        nargs += 1;
55                        args[nargs] = "c";
56                        nargs += 1;
[bec4d24]57                        return true;
[b740f0b]58                } // if
[dffaeac]59        } // for
60        return false;
61} // suffix
62
[51b7345]63
64void shuffle( const char *args[], int S, int E, int N ) {
[b87a5ed]65        // S & E index 1 passed the end so adjust with -1
[dffaeac]66        #ifdef __DEBUG_H__
[b87a5ed]67        cerr << "shuffle:" << S << " " << E << " " << N << endl;
[dffaeac]68        #endif // __DEBUG_H__
[b87a5ed]69        for ( int j = E-1 + N; j > S-1 + N; j -=1 ) {
[dffaeac]70                #ifdef __DEBUG_H__
[b87a5ed]71                cerr << "\t" << j << " " << j-N << endl;
[dffaeac]72                #endif // __DEBUG_H__
[b87a5ed]73                args[j] = args[j-N];
74        } // for
[51b7345]75} // shuffle
76
[37fe352]77static inline bool dirExists(const string & path) {
78    struct stat info;
79    if(stat( path.c_str(), &info ) != 0)
80        return false;
81    else if(info.st_mode & S_IFDIR)
82        return true;
83    else
84        return false;
85} //dirExists
86
[51b7345]87
[4b1afb6]88#define str(s) #s
89
[51b7345]90int main( int argc, char *argv[] ) {
[4b1afb6]91        string Version( CFA_VERSION_LONG );                                     // current version number from CONFIG
92        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
[51b7345]93
[d6f4488]94        string installincdir( CFA_INCDIR );                                     // fixed location of include files
95        string installlibdir( CFA_LIBDIR );                                     // fixed location of cc1 and cfa-cpp commands when installed
96        string srcdriverdir ( TOP_BUILDDIR "driver");           // fixed location of cc1 and cfa-cpp commands when in tree
[51b7345]97
[b87a5ed]98        string heading;                                                                         // banner printed at start of cfa compilation
99        string arg;                                                                                     // current command-line argument during command-line parsing
100        string Bprefix;                                                                         // path where gcc looks for compiler command steps
101        string langstd;                                                                         // language standard
[51b7345]102
[e24f13a]103        string compiler_path( CFA_BACKEND_CC );                         // path/name of C compiler
[b87a5ed]104        string compiler_name;                                                           // name of C compiler
[51b7345]105
[b87a5ed]106        bool nonoptarg = false;                                                         // indicates non-option argument specified
107        bool link = true;                                                                       // linking as well as compiling
108        bool verbose = false;                                                           // -v flag
109        bool quiet = false;                                                                     // -quiet flag
110        bool debug = true;                                                                      // -debug flag
111        bool help = false;                                                                      // -help flag
112        bool CFA_flag = false;                                                          // -CFA flag
113        bool cpp_flag = false;                                                          // -E or -M flag, preprocessor only
[de62360d]114        bool std_flag = false;                                                          // -std= flag
[d746bc8]115        bool noincstd_flag = false;                                                     // -no-include-stdhdr= flag
[6e4b913]116        bool debugging __attribute(( unused )) = false;         // -g flag
[37fe352]117        bool m32 = false;                                    // -m32 flag
118        bool m64 = false;                                    // -m64 flag
119        bool intree = false;
[51b7345]120
[b87a5ed]121        const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
122        int sargs = 1;                                                                          // starting location for arguments in args list
123        int nargs = sargs;                                                                      // number of arguments in args list; 0 => command name
[51b7345]124
[b87a5ed]125        const char *libs[argc + 20];                                            // non-user libraries must come separately, plus some added libraries and flags
126        int nlibs = 0;
[51b7345]127
[dffaeac]128        #ifdef __DEBUG_H__
[b87a5ed]129        cerr << "CFA:" << endl;
[bec4d24]130        for ( int i = 1; i < argc; i += 1 ) {
131            cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
132        } // for
[dffaeac]133        #endif // __DEBUG_H__
[51b7345]134
[b87a5ed]135        // process command-line arguments
[51b7345]136
[b87a5ed]137        for ( int i = 1; i < argc; i += 1 ) {
138                arg = argv[i];                                                                  // convert to string value
139                if ( prefix( arg, "-" ) ) {
140                        // pass through arguments
141
142                        if ( arg == "-Xlinker" || arg == "-o" ) {
143                                args[nargs] = argv[i];                                  // pass the argument along
144                                nargs += 1;
145                                i += 1;
146                                if ( i == argc ) continue;                              // next argument available ?
147                                args[nargs] = argv[i];                                  // pass the argument along
148                                nargs += 1;
149                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
150                                i += 1;
151                                args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + argv[i] ) ).c_str();
152                                nargs += 1;
153
154                                // CFA specific arguments
155
156                        } else if ( arg == "-CFA" ) {
157                                CFA_flag = true;                                                // strip the -CFA flag
158                                link = false;
159                                args[nargs] = "-E";                                             // replace the argument with -E
160                                nargs += 1;
161                        } else if ( arg == "-debug" ) {
162                                debug = true;                                                   // strip the debug flag
163                        } else if ( arg == "-nodebug" ) {
164                                debug = false;                                                  // strip the nodebug flag
165                        } else if ( arg == "-quiet" ) {
166                                quiet = true;                                                   // strip the quiet flag
167                        } else if ( arg == "-noquiet" ) {
168                                quiet = false;                                                  // strip the noquiet flag
169                        } else if ( arg == "-help" ) {
170                                help = true;                                                    // strip the help flag
171                        } else if ( arg == "-nohelp" ) {
172                                help = false;                                                   // strip the nohelp flag
[d746bc8]173                        } else if ( arg == "-no-include-stdhdr" ) {
174                                noincstd_flag = true;                                   // strip the no-include-stdhdr flag
[37fe352]175                        } else if ( arg == "-in-tree" ) {
176                                intree = true;
[b87a5ed]177                        } else if ( arg == "-compiler" ) {
178                                // use the user specified compiler
179                                i += 1;
180                                if ( i == argc ) continue;                              // next argument available ?
181                                compiler_path = argv[i];
[d6f4488]182                                if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
[b87a5ed]183                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
184                                        exit( EXIT_FAILURE );
185                                } // if
186
[de62360d]187                                // C specific arguments
[b87a5ed]188
189                        } else if ( arg == "-v" ) {
190                                verbose = true;                                                 // verbosity required
191                                args[nargs] = argv[i];                                  // pass the argument along
192                                nargs += 1;
193                        } else if ( arg == "-g" ) {
194                                debugging = true;                                               // symbolic debugging required
195                                args[nargs] = argv[i];                                  // pass the argument along
196                                nargs += 1;
[e3215c5]197                        } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
[53ba273]198                                std_flag = true;                                                // -std=XX provided
[de62360d]199                                args[nargs] = argv[i];                                  // pass the argument along
200                                nargs += 1;
[44bca7f]201                        } else if ( arg == "-w" ) {
202                                args[nargs] = argv[i];                                  // pass the argument along
203                                nargs += 1;
204                                args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
205                                nargs += 1;
206                        } else if ( prefix( arg, "-W" ) ) {                     // check before next tests
207                                if ( arg == "-Werror" || arg == "-Wall" ) {
208                                        args[nargs] = argv[i];                          // pass the argument along
209                                        nargs += 1;
210                                        args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
211                                        nargs += 1;
212                                } else {
213                                        unsigned int adv = prefix( arg, "-Wno-" ) ? 5 : 2;
214                                        args[nargs] = argv[i];                          // conditionally pass the argument along
[af39199d]215                                        const char * warning = argv[i] + adv;     // extract warning
216                                        if ( SemanticWarning_Exist( warning ) ) { // replace the argument for cfa-cpp
217                                                args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str();
218                                        } // if
[44bca7f]219                                        nargs += 1;
220                                } // if
[b87a5ed]221                        } else if ( prefix( arg, "-B" ) ) {
222                                Bprefix = arg.substr(2);                                // strip the -B flag
223                                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
224                                nargs += 1;
225                        } else if ( prefix( arg, "-b" ) ) {
226                                if ( arg.length() == 2 ) {                              // separate argument ?
227                                        i += 1;
228                                        if ( i == argc ) continue;                      // next argument available ?
229                                        arg += argv[i];                                         // concatenate argument
230                                } // if
231                                // later versions of gcc require the -b option to appear at the start of the command line
232                                shuffle( args, sargs, nargs, 1 );               // make room at front of argument list
233                                args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
234                                if ( putenv( (char *)( *new string( string( "__GCC_MACHINE__=" ) + arg ) ).c_str() ) != 0 ) {
235                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
236                                        exit( EXIT_FAILURE );
237                                } // if
238                                sargs += 1;
239                                nargs += 1;
240                        } else if ( prefix( arg, "-V" ) ) {
241                                if ( arg.length() == 2 ) {                              // separate argument ?
242                                        i += 1;
243                                        if ( i == argc ) continue;                      // next argument available ?
244                                        arg += argv[i];                                         // concatenate argument
245                                } // if
246                                // later versions of gcc require the -V option to appear at the start of the command line
247                                shuffle( args, sargs, nargs, 1 );               // make room at front of argument list
248                                args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
249                                if ( putenv( (char *)( *new string( string( "__GCC_VERSION__=" ) + arg ) ).c_str() ) != 0 ) {
250                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
251                                        exit( EXIT_FAILURE );
252                                } // if
253                                sargs += 1;
254                                nargs += 1;
255                        } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) {
256                                args[nargs] = argv[i];                                  // pass the argument along
257                                nargs += 1;
258                                if ( arg == "-E" || arg == "-M" || arg == "-MM" ) {
259                                        cpp_flag = true;                                        // cpp only
260                                } // if
261                                link = false;                           // no linkage required
262                        } else if ( arg[1] == 'l' ) {
263                                // if the user specifies a library, load it after user code
264                                libs[nlibs] = argv[i];
265                                nlibs += 1;
[37fe352]266                        } else if ( arg == "-m32" ) {
267                                m32 = true;
268                                m64 = false;
269                                args[nargs] = argv[i];
270                                nargs += 1;
271                        } else if ( arg == "-m64" ) {
272                                m64 = true;
273                                m32 = false;
274                                args[nargs] = argv[i];
275                                nargs += 1;
[b87a5ed]276                        } else {
277                                // concatenate any other arguments
278                                args[nargs] = argv[i];
279                                nargs += 1;
280                        } // if
281                } else {
[bec4d24]282                        bool cfa = suffix( arg, args, nargs );          // check suffix
283                        args[nargs] = argv[i];                                          // concatenate file
[b87a5ed]284                        nargs += 1;
[bec4d24]285                        if ( cfa ) {
[dffaeac]286                                args[nargs] = "-x";
287                                nargs += 1;
288                                args[nargs] = "none";
289                                nargs += 1;
290                        } // if
[b87a5ed]291                        nonoptarg = true;
292                } // if
293        } // for
[51b7345]294
[b32ad080]295    args[nargs] = "-x";                                                                 // turn off language
[bec4d24]296    nargs += 1;
297    args[nargs] = "none";
298    nargs += 1;
299
[dffaeac]300        #ifdef __x86_64__
[a83d08b]301        args[nargs] = "-mcx16";                                                         // allow double-wide CAA
302        nargs += 1;
[dffaeac]303        #endif // __x86_64__
[e3215c5]304
[dffaeac]305        #ifdef __DEBUG_H__
[b87a5ed]306        cerr << "args:";
307        for ( int i = 1; i < nargs; i += 1 ) {
308                cerr << " " << args[i];
309        } // for
310        cerr << endl;
[dffaeac]311        #endif // __DEBUG_H__
[51b7345]312
[b87a5ed]313        if ( cpp_flag && CFA_flag ) {
314                cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
315                exit( EXIT_FAILURE );
316        } // if
[51b7345]317
[6e4b913]318        // add the CFA include-library paths, which allow direct access to header files without directory qualification
[a5121bf]319        if( !intree ) {
320                args[nargs] = "-I" CFA_INCDIR;
[d746bc8]321                nargs += 1;
[dfb7c96]322                if ( ! noincstd_flag ) {                                                // do not use during build
[b740f0b]323                        args[nargs] = "-I" CFA_INCDIR "stdhdr";
[a5121bf]324                        nargs += 1;
325                } // if
[b740f0b]326                args[nargs] = "-I" CFA_INCDIR "concurrency";
[a5121bf]327                nargs += 1;
[b740f0b]328                args[nargs] = "-I" CFA_INCDIR "containers";
[a5121bf]329                nargs += 1;
330        } else {
331                args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
332                nargs += 1;
[dfb7c96]333                if ( ! noincstd_flag ) {                                                // do not use during build
[a5121bf]334                        args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
335                        nargs += 1;
336                } // if
337                args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
338                nargs += 1;
339                args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
340                nargs += 1;
341        }
[76c7f65e]342
[a37133c]343        // add stdbool to get defines for bool/true/false
344        args[nargs] = "-imacros";
345        nargs += 1;
346        args[nargs] = "stdbool.h";
347        nargs += 1;
348
[a5121bf]349        string libbase;
[37fe352]350        if( !intree ) {
[a5121bf]351                libbase = CFA_LIBDIR;
[37fe352]352        } else {
[a5121bf]353                libbase = TOP_BUILDDIR "libcfa/";
[37fe352]354                args[nargs] = "-D__CFA_FLAG__=-t";
355                nargs += 1;
356        }
357
[dfb7c96]358        string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
[13a984c]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
[dfb7c96]367        } // if
[a5121bf]368        const char * config = debug ? "debug": "nodebug";
369        string libdir = libbase + arch + "-" + config;
[dfb7c96]370
371        if ( ! dirExists( libdir ) ) {
[a5121bf]372                cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
373                cerr << "Was looking for " << libdir << endl;
374                libdir = libbase + arch + "-" + "nolib";
[dfb7c96]375        } // if
[a5121bf]376
[dfb7c96]377        if ( ! dirExists( libdir ) ) {
[a5121bf]378                cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
379                cerr << "Was looking for " << libdir << endl;
380                exit( EXIT_FAILURE );
[dfb7c96]381        } // if
[a5121bf]382
383        args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
384        nargs += 1;
385
[def9d4e]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
[b87a5ed]391        if ( link ) {
[6bfe5cc]392                args[nargs] = "-Xlinker";
393                nargs += 1;
394                args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
395                nargs += 1;
396                args[nargs] = "-Xlinker";
397                nargs += 1;
398                args[nargs] = "--undefined=__cfaabi_interpose_startup";
399                nargs += 1;
[c2ea058]400                args[nargs] = "-Xlinker";
401                nargs += 1;
402                args[nargs] = "--undefined=__cfaabi_appready_startup";
403                nargs += 1;
[1997b4e]404                args[nargs] = "-Xlinker";
405                nargs += 1;
406                args[nargs] = "--undefined=__cfaabi_dbg_record";
407                nargs += 1;
[6bfe5cc]408
[b87a5ed]409                // include the cfa library in case it's needed
[eed6f5b]410                args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
[a5121bf]411                nargs += 1;
[8bdc1c36]412                args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
413                nargs += 1;
[37fe352]414                args[nargs] = "-lcfa";
[51b7345]415                nargs += 1;
[63f78f0]416                args[nargs] = "-lpthread";
417                nargs += 1;
[9d944b2]418                args[nargs] = "-ldl";
419                nargs += 1;
[c5ac6d5]420                args[nargs] = "-lrt";
421                nargs += 1;
[def9d4e]422                args[nargs] = "-lm";
423                nargs += 1;
[51b7345]424        } // if
425
[e9145a3]426        // Add exception flags (unconditionally)
427        args[nargs] = "-fexceptions";
428        nargs += 1;
429
[b87a5ed]430        // add the correct set of flags based on the type of compile this is
[8c17ab0]431
[ec129c4]432        args[nargs] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
[51b7345]433        nargs += 1;
[b87a5ed]434        args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
[51b7345]435        nargs += 1;
[ec129c4]436        args[nargs] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
[1db21619]437        nargs += 1;
[4c82a3c]438        args[nargs] = "-D__CFA__";
439        nargs += 1;
440        args[nargs] = "-D__CFORALL__";
[02e5ab6]441        nargs += 1;
[6acb935]442        args[nargs] = "-D__cforall";
443        nargs += 1;
[51b7345]444
[b87a5ed]445        if ( cpp_flag ) {
446                args[nargs] = "-D__CPP__";
447                nargs += 1;
448        } // if
[51b7345]449
[fa477f7]450        shuffle( args, sargs, nargs, 1 );                                       // make room at front of argument list
451        nargs += 1;
[b87a5ed]452        if ( CFA_flag ) {
[fa477f7]453                args[sargs] = "-D__CFA_FLAG__=-N";
[4c82a3c]454                args[nargs] = "-D__CFA_PREPROCESS_";
[b87a5ed]455                nargs += 1;
[fa477f7]456        } else {
457                args[sargs] = "-D__CFA_FLAG__=-L";
[b87a5ed]458        } // if
[fa477f7]459        sargs += 1;
[51b7345]460
[b87a5ed]461        if ( debug ) {
462                heading += " (debug)";
463                args[nargs] = "-D__CFA_DEBUG__";
464                nargs += 1;
465        } else {
466                heading += " (no debug)";
467        } // if
[51b7345]468
[b87a5ed]469        if ( Bprefix.length() == 0 ) {
[b740f0b]470                Bprefix = ! intree ? installlibdir : srcdriverdir;
471                if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
[b87a5ed]472                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
473                nargs += 1;
474        } // if
[51b7345]475
[37fe352]476        args[nargs] = "-Xlinker";                                                       // used by backtrace
477        nargs += 1;
478        args[nargs] = "-export-dynamic";
479        nargs += 1;
[6bfe5cc]480
[b87a5ed]481        // execute the compilation command
[51b7345]482
[b87a5ed]483        args[0] = compiler_path.c_str();                                        // set compiler command for exec
484        // find actual name of the compiler independent of the path to it
485        int p = compiler_path.find_last_of( '/' );                      // scan r -> l for first '/'
486        if ( p == -1 ) {
487                compiler_name = compiler_path;
488        } else {
489                compiler_name = *new string( compiler_path.substr( p + 1 ) );
490        } // if
[51b7345]491
[b87a5ed]492        if ( prefix( compiler_name, "gcc" ) ) {                         // allow suffix on gcc name
493                args[nargs] = "-no-integrated-cpp";
494                nargs += 1;
[76c7f65e]495                args[nargs] = "-Wno-deprecated";
[b87a5ed]496                nargs += 1;
[157d094]497                if ( ! std_flag ) {                                                             // default c11, if none specified
498                        args[nargs] = "-std=gnu11";
[de62360d]499                        nargs += 1;
500                } // if
[76c7f65e]501                args[nargs] = "-fgnu89-inline";
[6e991d6]502                nargs += 1;
[201aeb9]503                args[nargs] = "-D__int8_t_defined";                             // prevent gcc type-size attributes
504                nargs += 1;
[b740f0b]505                args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
[b87a5ed]506                nargs += 1;
507        } else {
[e24f13a]508                cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
[b87a5ed]509                exit( EXIT_FAILURE );
510        } // if
[51b7345]511
[b87a5ed]512        args[nargs] = NULL;                                                                     // terminate with NULL
[51b7345]513
[dffaeac]514        #ifdef __DEBUG_H__
[b87a5ed]515        cerr << "nargs: " << nargs << endl;
516        cerr << "args:" << endl;
517        for ( int i = 0; args[i] != NULL; i += 1 ) {
518                cerr << " \"" << args[i] << "\"" << endl;
519        } // for
[dffaeac]520        #endif // __DEBUG_H__
[51b7345]521
[b87a5ed]522        if ( ! quiet ) {
523                cerr << "CFA " << "Version " << Version << heading << endl;
524
525                if ( help ) {
526                        cerr <<
527                                "-debug\t\t\t: use cfa runtime with debug checking" << endl <<
528                                "-help\t\t\t: print this help message" << endl <<
529                                "-quiet\t\t\t: print no messages from the cfa command" << endl <<
530                                "-CFA\t\t\t: run the cpp preprocessor and the cfa-cpp translator" << endl <<
531                                "-XCFA -cfa-cpp-flag\t: pass next flag as-is to the cfa-cpp translator" << endl <<
532                                "...\t\t\t: any other " << compiler_name << " flags" << endl;
533                } // if
[51b7345]534        } // if
535
[b87a5ed]536        if ( verbose ) {
537                if ( argc == 2 ) exit( EXIT_SUCCESS );                  // if only the -v flag is specified, do not invoke gcc
[51b7345]538
[b87a5ed]539                for ( int i = 0; args[i] != NULL; i += 1 ) {
540                        cerr << args[i] << " ";
541                } // for
542                cerr << endl;
543        } // if
[51b7345]544
[b87a5ed]545        if ( ! nonoptarg ) {
546                cerr << argv[0] << " error, no input files" << endl;
547                exit( EXIT_FAILURE );
548        } // if
[51b7345]549
[b87a5ed]550        // execute the command and return the result
[51b7345]551
[b87a5ed]552        execvp( args[0], (char *const *)args );                         // should not return
553        perror( "CFA Translator error: cfa level, execvp" );
554        exit( EXIT_FAILURE );
[51b7345]555} // main
556
557// Local Variables: //
[b87a5ed]558// tab-width: 4 //
559// mode: c++ //
[51b7345]560// compile-command: "make install" //
561// End: //
Note: See TracBrowser for help on using the repository browser.