source: driver/cfa.cc@ 3fad907

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 3fad907 was 1f690b3, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

  • 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//
[51b73452]9// Author : Peter A. Buhr
10// Created On : Tue Aug 20 13:44:49 2002
[201aeb9]11// Last Modified By : Peter A. Buhr
[b32ad080]12// Last Modified On : Fri Sep 14 23:02:59 2018
13// Update Count : 277
[b87a5ed]14//
[51b73452]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
[51b73452]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
[51b73452]28
29using std::cerr;
30using std::endl;
31using std::string;
[47a8d17]32using std::to_string;
[51b73452]33
34
35//#define __DEBUG_H__
36
37
38bool prefix( string arg, string pre ) {
[b87a5ed]39 return arg.substr( 0, pre.size() ) == pre;
[51b73452]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
[51b73452]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
[51b73452]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
[51b73452]87
[4b1afb6]88#define str(s) #s
89
[51b73452]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 ) );
[51b73452]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
[51b73452]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
[51b73452]102
[e24f13a]103 string compiler_path( CFA_BACKEND_CC ); // path/name of C compiler
[b87a5ed]104 string compiler_name; // name of C compiler
[51b73452]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;
[51b73452]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
[51b73452]124
[b87a5ed]125 const char *libs[argc + 20]; // non-user libraries must come separately, plus some added libraries and flags
126 int nlibs = 0;
[51b73452]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__
[51b73452]134
[b87a5ed]135 // process command-line arguments
[51b73452]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
[51b73452]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__
[51b73452]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
[51b73452]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
[b87a5ed]386 if ( link ) {
[6bfe5cc]387 args[nargs] = "-Xlinker";
388 nargs += 1;
389 args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
390 nargs += 1;
391 args[nargs] = "-Xlinker";
392 nargs += 1;
393 args[nargs] = "--undefined=__cfaabi_interpose_startup";
394 nargs += 1;
[c2ea058]395 args[nargs] = "-Xlinker";
396 nargs += 1;
397 args[nargs] = "--undefined=__cfaabi_appready_startup";
398 nargs += 1;
[1997b4e]399 args[nargs] = "-Xlinker";
400 nargs += 1;
401 args[nargs] = "--undefined=__cfaabi_dbg_record";
402 nargs += 1;
[6bfe5cc]403
[b87a5ed]404 // include the cfa library in case it's needed
[eed6f5b]405 args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
[a5121bf]406 nargs += 1;
[8bdc1c36]407 args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
408 nargs += 1;
[37fe352]409 args[nargs] = "-lcfa";
[51b73452]410 nargs += 1;
[63f78f0]411 args[nargs] = "-lpthread";
412 nargs += 1;
[9d944b2]413 args[nargs] = "-ldl";
414 nargs += 1;
[c5ac6d5]415 args[nargs] = "-lrt";
416 nargs += 1;
[51b73452]417 } // if
418
[e9145a3]419 // Add exception flags (unconditionally)
420 args[nargs] = "-fexceptions";
421 nargs += 1;
422
[b87a5ed]423 // add the correct set of flags based on the type of compile this is
[8c17ab0]424
[ec129c4]425 args[nargs] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
[51b73452]426 nargs += 1;
[b87a5ed]427 args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
[51b73452]428 nargs += 1;
[ec129c4]429 args[nargs] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
[1db21619]430 nargs += 1;
[4c82a3c]431 args[nargs] = "-D__CFA__";
432 nargs += 1;
433 args[nargs] = "-D__CFORALL__";
[02e5ab6]434 nargs += 1;
[6acb935]435 args[nargs] = "-D__cforall";
436 nargs += 1;
[51b73452]437
[b87a5ed]438 if ( cpp_flag ) {
439 args[nargs] = "-D__CPP__";
440 nargs += 1;
441 } // if
[51b73452]442
[fa477f7]443 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list
444 nargs += 1;
[b87a5ed]445 if ( CFA_flag ) {
[fa477f7]446 args[sargs] = "-D__CFA_FLAG__=-N";
[4c82a3c]447 args[nargs] = "-D__CFA_PREPROCESS_";
[b87a5ed]448 nargs += 1;
[fa477f7]449 } else {
450 args[sargs] = "-D__CFA_FLAG__=-L";
[b87a5ed]451 } // if
[fa477f7]452 sargs += 1;
[51b73452]453
[b87a5ed]454 if ( debug ) {
455 heading += " (debug)";
456 args[nargs] = "-D__CFA_DEBUG__";
457 nargs += 1;
458 } else {
459 heading += " (no debug)";
460 } // if
[51b73452]461
[b87a5ed]462 if ( Bprefix.length() == 0 ) {
[b740f0b]463 Bprefix = ! intree ? installlibdir : srcdriverdir;
464 if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
[b87a5ed]465 args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
466 nargs += 1;
467 } // if
[51b73452]468
[37fe352]469 args[nargs] = "-Xlinker"; // used by backtrace
470 nargs += 1;
471 args[nargs] = "-export-dynamic";
472 nargs += 1;
[6bfe5cc]473
[b87a5ed]474 // execute the compilation command
[51b73452]475
[b87a5ed]476 args[0] = compiler_path.c_str(); // set compiler command for exec
477 // find actual name of the compiler independent of the path to it
478 int p = compiler_path.find_last_of( '/' ); // scan r -> l for first '/'
479 if ( p == -1 ) {
480 compiler_name = compiler_path;
481 } else {
482 compiler_name = *new string( compiler_path.substr( p + 1 ) );
483 } // if
[51b73452]484
[b87a5ed]485 if ( prefix( compiler_name, "gcc" ) ) { // allow suffix on gcc name
486 args[nargs] = "-no-integrated-cpp";
487 nargs += 1;
[76c7f65e]488 args[nargs] = "-Wno-deprecated";
[b87a5ed]489 nargs += 1;
[157d094]490 if ( ! std_flag ) { // default c11, if none specified
491 args[nargs] = "-std=gnu11";
[de62360d]492 nargs += 1;
493 } // if
[76c7f65e]494 args[nargs] = "-fgnu89-inline";
[6e991d6]495 nargs += 1;
[201aeb9]496 args[nargs] = "-D__int8_t_defined"; // prevent gcc type-size attributes
497 nargs += 1;
[b740f0b]498 args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
[b87a5ed]499 nargs += 1;
[d3b7937]500 args[nargs] = "-lm";
501 nargs += 1;
[b87a5ed]502 } else {
[e24f13a]503 cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
[b87a5ed]504 exit( EXIT_FAILURE );
505 } // if
[51b73452]506
[b87a5ed]507 for ( int i = 0; i < nlibs; i += 1 ) { // copy non-user libraries after all user libraries
508 args[nargs] = libs[i];
509 nargs += 1;
510 } // for
[51b73452]511
[b87a5ed]512 args[nargs] = NULL; // terminate with NULL
[51b73452]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__
[51b73452]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
[51b73452]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
[51b73452]538
[b87a5ed]539 for ( int i = 0; args[i] != NULL; i += 1 ) {
540 cerr << args[i] << " ";
541 } // for
542 cerr << endl;
543 } // if
[51b73452]544
[b87a5ed]545 if ( ! nonoptarg ) {
546 cerr << argv[0] << " error, no input files" << endl;
547 exit( EXIT_FAILURE );
548 } // if
[51b73452]549
[b87a5ed]550 // execute the command and return the result
[51b73452]551
[b87a5ed]552 execvp( args[0], (char *const *)args ); // should not return
553 perror( "CFA Translator error: cfa level, execvp" );
554 exit( EXIT_FAILURE );
[51b73452]555} // main
556
557// Local Variables: //
[b87a5ed]558// tab-width: 4 //
559// mode: c++ //
[51b73452]560// compile-command: "make install" //
561// End: //
Note: See TracBrowser for help on using the repository browser.