source: driver/cfa.cc@ b8b6c442

ADT 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 b8b6c442 was dfb7c96, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

temporary patch to implicitly add -m32 for 32-bit compiles

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