Changes in / [970141d:85142648]


Ignore:
Files:
2 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r970141d r85142648  
    2121.deps
    2222.dirstamp
    23 /bin
    24 /lib
    25 /include
    26 /share
    27 /build
     23bin
     24lib
     25include
     26share
     27build
    2828*.class
    2929
  • Makefile.in

    r970141d r85142648  
    294294FGREP = @FGREP@
    295295GREP = @GREP@
    296 HAS_DISTCC = @HAS_DISTCC@
    297296HOST_FLAGS = @HOST_FLAGS@
    298297INSTALL = @INSTALL@
  • benchmark/Makefile.in

    r970141d r85142648  
    244244FGREP = @FGREP@
    245245GREP = @GREP@
    246 HAS_DISTCC = @HAS_DISTCC@
    247246HOST_FLAGS = @HOST_FLAGS@
    248247INSTALL = @INSTALL@
  • configure

    r970141d r85142648  
    663663ac_ct_DUMPBIN
    664664DUMPBIN
     665LD
    665666FGREP
    666667EGREP
     
    700701LDFLAGS
    701702CXXFLAGS
     703CXX
    702704CFA_FLAGS
    703705LIBCFA_TARGET_MAKEFILES
     
    721723CFA_INCDIR
    722724CFA_PREFIX
    723 HAS_DISTCC
    724 LD
    725 CXX
    726 ENABLE_DISTCC_FALSE
    727 ENABLE_DISTCC_TRUE
    728725DOendif
    729726DOifskipcompile
     
    800797enable_silent_rules
    801798with_cfa_name
    802 enable_distcc
    803799with_target_hosts
    804800enable_gprofiler
     
    14631459  --enable-silent-rules   less verbose build output (undo: "make V=1")
    14641460  --disable-silent-rules  verbose build output (undo: "make V=0")
    1465   --enable-distcc     whether or not to enable distributed compilation
    14661461  --enable-gprofiler     whether or not to enable gprofiler tools (if available)
    14671462  --enable-demangler     whether or not to build the demangler (executable and library)
     
    31853180
    31863181DOendif='endif'
    3187 
    3188 
    3189 
    3190 #==============================================================================
    3191 # distcc support
    3192 
    3193 # Check whether --enable-distcc was given.
    3194 if test "${enable_distcc+set}" = set; then :
    3195   enableval=$enable_distcc; enable_distcc=$enableval
    3196 else
    3197   enable_distcc=no
    3198 fi
    3199 
    3200 
    3201  if test x$enable_distcc = xyes; then
    3202   ENABLE_DISTCC_TRUE=
    3203   ENABLE_DISTCC_FALSE='#'
    3204 else
    3205   ENABLE_DISTCC_TRUE='#'
    3206   ENABLE_DISTCC_FALSE=
    3207 fi
    3208 
    3209 HAS_DISTCC="False"
    3210 
    3211 if test x$enable_distcc = xyes; then
    3212         CXX="distcc ${CXX}"
    3213         LD="distcc ${LD} -lstdc++"
    3214         HAS_DISTCC="True"
    3215         echo "Enabling distributed builds"
    3216 fi
    3217 
    3218 
    32193182
    32203183
     
    1705417017fi
    1705517018
    17056 if test -z "${ENABLE_DISTCC_TRUE}" && test -z "${ENABLE_DISTCC_FALSE}"; then
    17057   as_fn_error $? "conditional \"ENABLE_DISTCC\" was never defined.
    17058 Usually this means the macro was only invoked conditionally." "$LINENO" 5
    17059 fi
    1706017019if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
    1706117020  as_fn_error $? "conditional \"AMDEP\" was never defined.
  • configure.ac

    r970141d r85142648  
    5656AC_SUBST([DOendif])
    5757AM_SUBST_NOTMAKE([DOendif])
    58 
    59 #==============================================================================
    60 # distcc support
    61 
    62 AC_ARG_ENABLE(distcc,
    63         [  --enable-distcc     whether or not to enable distributed compilation],
    64         enable_distcc=$enableval, enable_distcc=no)
    65 
    66 AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])
    67 HAS_DISTCC="False"
    68 
    69 if test x$enable_distcc = xyes; then
    70         CXX="distcc ${CXX}"
    71         LD="distcc ${LD} -lstdc++"
    72         HAS_DISTCC="True"
    73         echo "Enabling distributed builds"
    74 fi
    75 
    76 AC_SUBST(CXX)
    77 AC_SUBST(LD)
    78 AC_SUBST(HAS_DISTCC)
    7958
    8059#==============================================================================
  • doc/bibliography/pl.bib

    r970141d r85142648  
    943943}
    944944
     945@misc{Cforall,
     946    contributer = {pabuhr@plg},
     947    key         = {Cforall},
     948    author      = {{\textsf{C}{$\mathbf{\forall}$} Features}},
     949    howpublished= {\href{https://plg.uwaterloo.ca/~cforall/features}{https://\-plg.uwaterloo.ca/\-$\sim$cforall/\-features}},
     950}
     951
     952@misc{CforallBenchMarks,
     953    contributer = {pabuhr@plg},
     954    key         = {Cforall Benchmarks},
     955    author      = {{\textsf{C}{$\mathbf{\forall}$} Benchmarks}},
     956    howpublished= {\href{https://plg.uwaterloo.ca/~cforall/benchmark.tar}{https://\-plg.uwaterloo.ca/\-$\sim$cforall/\-benchmark.tar}},
     957}
     958
     959@mastersthesis{Esteves04,
     960    keywords    = {Cforall, parametric polymorphism, overloading},
     961    contributer = {pabuhr@plg},
     962    author      = {Rodolfo Gabriel Esteves},
     963    title       = {\textsf{C}$\mathbf{\forall}$, a Study in Evolutionary Design in Programming Languages},
     964    school      = {School of Computer Science, University of Waterloo},
     965    year        = 2004,
     966    address     = {Waterloo, Ontario, Canada, N2L 3G1},
     967    note        = {\href{http://plg.uwaterloo.ca/theses/EstevesThesis.pdf}{http://\-plg.uwaterloo.ca/\-theses/\-EstevesThesis.pdf}},
     968}
     969
     970@misc{CFAStackEvaluation,
     971    contributer = {a3moss@plg},
     972    author      = {Aaron Moss},
     973    title       = {\textsf{C}$\mathbf{\forall}$ Stack Evaluation Programs},
     974    year        = 2018,
     975    howpublished= {\href{https://cforall.uwaterloo.ca/CFAStackEvaluation.zip}{https://cforall.uwaterloo.ca/\-CFAStackEvaluation.zip}},
     976}
     977
    945978@article{Moss18,
    946979    keywords    = {type systems, polymorphism, tuples, Cforall},
     
    955988    pages       = {2111-2146},
    956989    note        = {\href{http://dx.doi.org/10.1002/spe.2624}{http://\-dx.doi.org/\-10.1002/\-spe.2624}},
    957 }
    958 
    959 @misc{CforallBenchMarks,
    960     contributer = {pabuhr@plg},
    961     key         = {Cforall Benchmarks},
    962     author      = {{\textsf{C}{$\mathbf{\forall}$} Benchmarks}},
    963     howpublished= {\href{https://plg.uwaterloo.ca/~cforall/benchmark.tar}{https://\-plg.uwaterloo.ca/\-$\sim$cforall/\-benchmark.tar}},
    964 }
    965 
    966 @misc{Cforall,
    967     contributer = {pabuhr@plg},
    968     key         = {Cforall},
    969     author      = {{\textsf{C}{$\mathbf{\forall}$} Features}},
    970     howpublished= {\href{https://plg.uwaterloo.ca/~cforall/features}{https://\-plg.uwaterloo.ca/\-$\sim$cforall/\-features}},
    971 }
    972 
    973 @misc{CFAStackEvaluation,
    974     contributer = {a3moss@plg},
    975     author      = {Aaron Moss},
    976     title       = {\textsf{C}$\mathbf{\forall}$ Stack Evaluation Programs},
    977     year        = 2018,
    978     howpublished= {\href{https://cforall.uwaterloo.ca/CFAStackEvaluation.zip}{https://cforall.uwaterloo.ca/\-CFAStackEvaluation.zip}},
    979 }
    980 
    981 @mastersthesis{Esteves04,
    982     keywords    = {Cforall, parametric polymorphism, overloading},
    983     contributer = {pabuhr@plg},
    984     author      = {Rodolfo Gabriel Esteves},
    985     title       = {\textsf{C}$\mathbf{\forall}$, a Study in Evolutionary Design in Programming Languages},
    986     school      = {School of Computer Science, University of Waterloo},
    987     year        = 2004,
    988     address     = {Waterloo, Ontario, Canada, N2L 3G1},
    989     note        = {\href{http://plg.uwaterloo.ca/theses/EstevesThesis.pdf}{http://\-plg.uwaterloo.ca/\-theses/\-EstevesThesis.pdf}},
    990 }
    991 
    992 @phdthesis{Moss19,
    993     keywords    = {type system, generic type, resolution algorithm, type environment, Cforall},
    994     author      = {Aaron Moss},
    995     title       = {\textsf{C}$\mathbf{\forall}$ Type System Implementation},
    996     school      = {School of Computer Science, University of Waterloo},
    997     year        = 2019,
    998     optaddress  = {Waterloo, Ontario, Canada, N2L 3G1},
    999     note        = {\href{https://uwspace.uwaterloo.ca/handle/10012/14584}{https://\-uwspace.uwaterloo.ca/\-handle/\-10012/\-14584}},
    1000990}
    1001991
     
    11111101
    11121102@techreport{Prokopec11,
    1113     keywords    = {ctrie, concurrent map},
    1114     contributer = {a3moss@uwaterloo.ca},
    1115     title       ={Cache-aware lock-free concurrent hash tries},
    1116     author      ={Prokopec, Aleksandar and Bagwell, Phil and Odersky, Martin},
    1117     institution ={EPFL},
    1118     year        ={2011}
     1103  keywords = {ctrie, concurrent map},
     1104  contributer = {a3moss@uwaterloo.ca},
     1105  title={Cache-aware lock-free concurrent hash tries},
     1106  author={Prokopec, Aleksandar and Bagwell, Phil and Odersky, Martin},
     1107  institution={EPFL},
     1108  year={2011}
    11191109}
    11201110
     
    11681158
    11691159@phdthesis{Norrish98,
    1170     title       = {C formalised in HOL},
    1171     author      = {Norrish, Michael},
    1172     year        = {1998},
    1173     school      = {University of Cambridge}
     1160  title={C formalised in HOL},
     1161  author={Norrish, Michael},
     1162  year={1998},
     1163  school={University of Cambridge}
    11741164}
    11751165
     
    11801170    title       = {Checked C: Making C Safe by Extension},
    11811171    booktitle   = {2018 IEEE Cybersecurity Development (SecDev)},
     1172    year        = {2018},
     1173    month       = {September},
     1174    pages       = {53-60},
    11821175    publisher   = {IEEE},
    1183     year        = {2018},
    1184     month       = sep,
    1185     pages       = {53-60},
    11861176    url         = {https://www.microsoft.com/en-us/research/publication/checkedc-making-c-safe-by-extension/},
    11871177}
     
    12951285
    12961286@inproceedings{Odersky01,
    1297     keywords    = {Scala},
    1298     contributer = {a3moss@uwaterloo.ca},
    1299     author      = {Odersky, Martin and Zenger, Christoph and Zenger, Matthias},
    1300     title       = {Colored Local Type Inference},
    1301     booktitle   = {Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages},
    1302     series      = {POPL '01},
    1303     year        = {2001},
    1304     isbn        = {1-58113-336-7},
    1305     location    = {London, United Kingdom},
    1306     pages       = {41--53},
    1307     numpages    = {13},
    1308     url         = {http://doi.acm.org/10.1145/360204.360207},
    1309     doi         = {10.1145/360204.360207},
    1310     acmid       = {360207},
    1311     publisher   = {ACM},
    1312     address     = {New York, NY, USA},
     1287 keywords = {Scala},
     1288 contributer = {a3moss@uwaterloo.ca},
     1289 author = {Odersky, Martin and Zenger, Christoph and Zenger, Matthias},
     1290 title = {Colored Local Type Inference},
     1291 booktitle = {Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages},
     1292 series = {POPL '01},
     1293 year = {2001},
     1294 isbn = {1-58113-336-7},
     1295 location = {London, United Kingdom},
     1296 pages = {41--53},
     1297 numpages = {13},
     1298 url = {http://doi.acm.org/10.1145/360204.360207},
     1299 doi = {10.1145/360204.360207},
     1300 acmid = {360207},
     1301 publisher = {ACM},
     1302 address = {New York, NY, USA},
    13131303}
    13141304
     
    17031693
    17041694@inproceedings{Prokopec12,
    1705     keywords    = {ctrie, hash trie, concurrent map},
    1706     contributer = {a3moss@uwaterloo.ca},
    1707     title       = {Concurrent tries with efficient non-blocking snapshots},
    1708     author      = {Prokopec, Aleksandar and Bronson, Nathan Grasso and Bagwell, Phil and Odersky, Martin},
    1709     booktitle   = {ACM SIGPLAN Notices},
    1710     volume      = {47},
    1711     number      = {8},
    1712     pages       = {151--160},
    1713     year        = {2012},
    1714     organization={ACM}
     1695  keywords={ctrie, hash trie, concurrent map},
     1696  contributer={a3moss@uwaterloo.ca},
     1697  title={Concurrent tries with efficient non-blocking snapshots},
     1698  author={Prokopec, Aleksandar and Bronson, Nathan Grasso and Bagwell, Phil and Odersky, Martin},
     1699  booktitle={ACM SIGPLAN Notices},
     1700  volume={47},
     1701  number={8},
     1702  pages={151--160},
     1703  year={2012},
     1704  organization={ACM}
    17151705}
    17161706
     
    17391729}
    17401730
    1741 @article{Delisle19,
     1731@article{Delisle18b,
    17421732    keywords    = {concurrency, Cforall},
    17431733    contributer = {pabuhr@plg},
    17441734    author      = {Thierry Delisle and Peter A. Buhr},
    1745     title       = {Advanced Control-flow and Concurrency in \textsf{C}$\mathbf{\forall}$},
    1746     year        = 2019,
     1735    title       = {Concurrency in \textsf{C}$\mathbf{\forall}$},
     1736    year        = 2018,
    17471737    journal     = spe,
    1748     pages       = {1-33},
     1738    pages       = {1-32},
    17491739    note        = {submitted},
    17501740}
     
    25102500
    25112501@misc{Dotty-github,
    2512     keywords    = {dotty,scala},
    2513     contributer = {a3moss@uwaterloo.ca},
    2514     author      = {Martin Odersky},
    2515     title       = {Dotty},
    2516     howpublished= {\href{https://github.com/lampepfl/dotty}{https://\-github.com/\-lampepfl/\-dotty}},
    2517     note        = {Acessed: 2019-02-22}
     2502    keywords = {dotty,scala},
     2503    contributer = {a3moss@uwaterloo.ca},
     2504    author = {Martin Odersky},
     2505    title = {Dotty},
     2506    howpublished = {\href{https://github.com/lampepfl/dotty}{https://\-github.com/\-lampepfl/\-dotty}},
     2507    note = {Acessed: 2019-02-22}
    25182508}
    25192509
     
    26662656    volume      = 10,
    26672657    number      = 3,
    2668     pages       = {120-123},
     2658    pages        = {120-123},
    26692659    comment     = {
    26702660        The ``two-pass'' algorithm.  An upward pass over a parse tree
     
    32463236
    32473237@article{Leroy09,
    3248     keywords    = {C formalization},
    3249     contributer = {a3moss@uwaterloo.ca},
    3250     author      = {Leroy, Xavier},
    3251     title       = {Formal Verification of a Realistic Compiler},
    3252     journal     = {Commun. ACM},
    3253     issue_date  = {July 2009},
    3254     volume      = {52},
    3255     number      = {7},
    3256     month       = jul,
    3257     year        = {2009},
    3258     issn        = {0001-0782},
    3259     pages       = {107--115},
    3260     numpages    = {9},
    3261     url         = {http://doi.acm.org/10.1145/1538788.1538814},
    3262     doi         = {10.1145/1538788.1538814},
    3263     acmid       = {1538814},
    3264     publisher   = {ACM},
    3265     address     = {New York, NY, USA},
     3238 keywords = {C formalization},
     3239 contributer = {a3moss@uwaterloo.ca},
     3240 author = {Leroy, Xavier},
     3241 title = {Formal Verification of a Realistic Compiler},
     3242 journal = {Commun. ACM},
     3243 issue_date = {July 2009},
     3244 volume = {52},
     3245 number = {7},
     3246 month = jul,
     3247 year = {2009},
     3248 issn = {0001-0782},
     3249 pages = {107--115},
     3250 numpages = {9},
     3251 url = {http://doi.acm.org/10.1145/1538788.1538814},
     3252 doi = {10.1145/1538788.1538814},
     3253 acmid = {1538814},
     3254 publisher = {ACM},
     3255 address = {New York, NY, USA},
    32663256}
    32673257
     
    41914181
    41924182@article{Morgado13,
    4193     keywords    = {expression resolution},
    4194     contributer = {a3moss@uwaterloo.ca},
    4195     title       = {Iterative and core-guided {MaxSAT} solving: A survey and assessment},
    4196     author      = {Morgado, Antonio and Heras, Federico and Liffiton, Mark and Planes, Jordi and Marques-Silva, Joao},
    4197     journal     = {Constraints},
    4198     volume      = {18},
    4199     number      = {4},
    4200     pages       = {478--534},
    4201     year        = {2013},
    4202     publisher   = {Springer}
     4183  keywords = {expression resolution},
     4184  contributer = {a3moss@uwaterloo.ca},
     4185  title={Iterative and core-guided {MaxSAT} solving: A survey and assessment},
     4186  author={Morgado, Antonio and Heras, Federico and Liffiton, Mark and Planes, Jordi and Marques-Silva, Joao},
     4187  journal={Constraints},
     4188  volume={18},
     4189  number={4},
     4190  pages={478--534},
     4191  year={2013},
     4192  publisher={Springer}
    42034193}
    42044194
     
    43994389}
    44004390
     4391
    44014392@article{Liskov86,
    44024393    keywords    = {synchronous communication, concurrency},
     
    44574448
    44584449@article{Pierce00,
    4459     keywords    = {Scala},
    4460     contributer = {a3moss@uwaterloo.ca},
    4461     author      = {Pierce, Benjamin C. and Turner, David N.},
    4462     title       = {Local Type Inference},
    4463     journal     = {ACM Trans. Program. Lang. Syst.},
    4464     issue_date  = {Jan. 2000},
    4465     volume      = {22},
    4466     number      = {1},
    4467     month       = jan,
    4468     year        = {2000},
    4469     issn        = {0164-0925},
    4470     pages       = {1--44},
    4471     numpages    = {44},
    4472     url         = {http://doi.acm.org/10.1145/345099.345100},
    4473     doi         = {10.1145/345099.345100},
    4474     acmid       = {345100},
    4475     publisher   = {ACM},
    4476     address     = {New York, NY, USA},
    4477     keywords    = {polymorphism, subtyping, type inference},
     4450 keywords = {Scala},
     4451 contributer = {a3moss@uwaterloo.ca},
     4452 author = {Pierce, Benjamin C. and Turner, David N.},
     4453 title = {Local Type Inference},
     4454 journal = {ACM Trans. Program. Lang. Syst.},
     4455 issue_date = {Jan. 2000},
     4456 volume = {22},
     4457 number = {1},
     4458 month = jan,
     4459 year = {2000},
     4460 issn = {0164-0925},
     4461 pages = {1--44},
     4462 numpages = {44},
     4463 url = {http://doi.acm.org/10.1145/345099.345100},
     4464 doi = {10.1145/345099.345100},
     4465 acmid = {345100},
     4466 publisher = {ACM},
     4467 address = {New York, NY, USA},
     4468 keywords = {polymorphism, subtyping, type inference},
    44784469}
    44794470
     
    54585449
    54595450@inproceedings{Krebbers14,
    5460     keywords    = {c formalization},
    5461     contributer = {a3moss@uwaterloo.ca},
    5462     author      = {Krebbers, Robbert},
    5463     title       = {An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C},
    5464     booktitle   = {Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages},
    5465     series      = {POPL '14},
    5466     year        = {2014},
    5467     isbn        = {978-1-4503-2544-8},
    5468     location    = {San Diego, California, USA},
    5469     pages       = {101--112},
    5470     numpages    = {12},
    5471     url         = {http://doi.acm.org/10.1145/2535838.2535878},
    5472     doi         = {10.1145/2535838.2535878},
    5473     acmid       = {2535878},
    5474     publisher   = {ACM},
    5475     address     = {New York, NY, USA},
     5451 keywords = {c formalization},
     5452 contributer = {a3moss@uwaterloo.ca},
     5453 author = {Krebbers, Robbert},
     5454 title = {An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C},
     5455 booktitle = {Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages},
     5456 series = {POPL '14},
     5457 year = {2014},
     5458 isbn = {978-1-4503-2544-8},
     5459 location = {San Diego, California, USA},
     5460 pages = {101--112},
     5461 numpages = {12},
     5462 url = {http://doi.acm.org/10.1145/2535838.2535878},
     5463 doi = {10.1145/2535838.2535878},
     5464 acmid = {2535878},
     5465 publisher = {ACM},
     5466 address = {New York, NY, USA},
    54765467}
    54775468
     
    75407531
    75417532@article{SysVABI,
    7542     keywords    = {System V ABI},
    7543     contributer = {a3moss@uwaterloo.ca},
    7544     title       = {System {V} application binary interface},
    7545     author      = {Matz, Michael and Hubicka, Jan and Jaeger, Andreas and Mitchell, Mark},
    7546     journal     = {AMD64 Architecture Processor Supplement, Draft v0},
    7547     volume      = {99},
    7548     year        = {2013}
     7533  keywords = {System V ABI},
     7534  contributer = {a3moss@uwaterloo.ca},
     7535  title={System {V} application binary interface},
     7536  author={Matz, Michael and Hubicka, Jan and Jaeger, Andreas and Mitchell, Mark},
     7537  journal={AMD64 Architecture Processor Supplement, Draft v0},
     7538  volume={99},
     7539  year={2013}
    75497540}
    75507541
     
    77737764
    77747765@techreport{Black90,
    7775     title       = {Typechecking polymorphism in {Emerald}},
    7776     author      = {Black, Andrew P and Hutchinson, Norman C},
    7777     year        = {1990},
    7778     institution = {Cambridge Research Laboratory, Digital Equipment Corporation}
     7766  title={Typechecking polymorphism in {Emerald}},
     7767  author={Black, Andrew P and Hutchinson, Norman C},
     7768  year={1990},
     7769  institution={Cambridge Research Laboratory, Digital Equipment Corporation}
    77797770}
    77807771
  • driver/Makefile.in

    r970141d r85142648  
    231231FGREP = @FGREP@
    232232GREP = @GREP@
    233 HAS_DISTCC = @HAS_DISTCC@
    234233HOST_FLAGS = @HOST_FLAGS@
    235234INSTALL = @INSTALL@
  • driver/cc1.cc

    r970141d r85142648  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  9 17:50:53 2019
    13 // Update Count     : 384
     12// Last Modified On : Mon Sep  3 16:57:05 2018
     13// Update Count     : 125
    1414//
    1515
     
    1919#include <string>
    2020using std::string;
    21 #include <algorithm>                                                                    // find
    2221#include <cstdio>                                                                               // stderr, stdout, perror, fprintf
    2322#include <cstdlib>                                                                              // getenv, exit, mkstemp
    2423#include <unistd.h>                                                                             // execvp, fork, unlink
    2524#include <sys/wait.h>                                                                   // wait
    26 #include <fcntl.h>
    27 
    2825
    2926#include "config.h"                                                                             // configure info
     
    3330
    3431
    35 static string compiler_path( CFA_BACKEND_CC );                  // C compiler path/name
    36 static bool CFA_flag = false;                                                   // -CFA flag
    37 static bool save_temps = false;                                                 // -save-temps flag
    38 static string o_file;
    39 static string bprefix;
    40 
    41 
    42 static bool prefix( const string & arg, const string & pre ) {
     32string compiler_name( CFA_BACKEND_CC );                                 // path/name of C compiler
     33
     34string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" );
     35string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
     36
     37char tmpname[] = P_tmpdir "/CFAXXXXXX";
     38int tmpfilefd = -1;
     39
     40
     41bool prefix( string arg, string pre ) {
    4342        return arg.substr( 0, pre.size() ) == pre;
    4443} // prefix
    4544
    46 static void suffix( const string & arg, const char * args[], int & nargs ) {
    47         enum { NumSuffixes = 3 };
    48         static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
    49 
     45enum { NumSuffixes = 2 };
     46const string suffixes[NumSuffixes] = { "cfa", "hfa", };
     47
     48void suffix( string arg, const char * args[], int & nargs ) {
     49        //std::cerr << arg << std::endl;
    5050        size_t dot = arg.find_last_of( "." );
     51        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    5152        if ( dot == string::npos ) return;
    52         const string * end = suffixes + NumSuffixes;
    53         if ( std::find( suffixes, end, arg.substr( dot + 1 ) ) != end ) {
    54                 args[nargs++] = "-x";
    55                 args[nargs++] = "c";
    56         } // if
     53        string sx = arg.substr( dot + 1 );
     54        for ( int i = 0; i < NumSuffixes; i += 1 ) {
     55                if ( sx == suffixes[i] ) {
     56                        args[nargs] = "-x";
     57                        nargs += 1;
     58                        args[nargs] = "c";
     59                        nargs += 1;
     60                        return;
     61                } // if
     62        } // for
    5763} // suffix
    5864
    5965
    60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
    61 
    62 static void checkEnv1( const char * args[], int & nargs ) { // stage 1
    63         extern char ** environ;
    64 
    65         for ( int i = 0; environ[i]; i += 1 ) {
    66                 string arg( environ[i] );
     66void checkEnv( const char * args[], int & nargs ) {
     67        char *value;
     68
     69        value = getenv( "__CFA_COMPILER__" );
     70        if ( value != NULL ) {
     71                compiler_name = value;
    6772                #ifdef __DEBUG_H__
    68                 cerr << "env arg:\"" << arg << "\"" << endl;
     73                cerr << "env arg:\"" << compiler_name << "\"" << endl;
    6974                #endif // __DEBUG_H__
    70 
    71                 if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    72                         string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    73                         if ( prefix( val, "-compiler=" ) ) {
    74                                 compiler_path = val.substr( 10 );
    75                         } // if
    76                 } // if
    77         } // for
    78 } // checkEnv1
    79 
    80 
    81 static void checkEnv2( const char * args[], int & nargs ) { // stage 2
    82         extern char ** environ;
    83 
    84         for ( int i = 0; environ[i]; i += 1 ) {
    85                 string arg( environ[i] );
     75        } // if
     76
     77        value = getenv( "__GCC_MACHINE__" );
     78        if ( value != NULL ) {
     79                args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along
    8680                #ifdef __DEBUG_H__
    87                 cerr << "env arg:\"" << arg << "\"" << endl;
     81                cerr << "env arg:\"" << args[nargs] << "\"" << endl;
    8882                #endif // __DEBUG_H__
    89 
    90                 if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    91                         string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    92                         if ( prefix( val, "-compiler=" ) ) {
    93                                 compiler_path = val.substr( 10 );
    94                         } else if ( val == "-CFA" ) {
    95                                 CFA_flag = true;
    96                         } else if ( val == "-save-temps" ) {
    97                                 save_temps = true;
    98                         } else if ( prefix( val, "-o=" ) ) {            // output file for -CFA
    99                                 o_file = val.substr( 3 );
    100                         } else if ( prefix( val, "-B=" ) ) {            // location of cfa-cpp
    101                                 bprefix = val.substr( 3 );
    102                         } else {                                                                        // normal flag for cfa-cpp
    103                                 args[nargs++] = ( *new string( arg.substr( arg.find_first_of( "=" ) + 1 ) ) ).c_str();
    104                         } // if
    105                 } // if
    106         } // for
    107 } // checkEnv2
    108 
    109 
    110 static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa";
    111 static int tmpfilefd = -1;
    112 static bool startrm = false;
    113 
    114 static void rmtmpfile() {
    115         if ( tmpfilefd == -1 ) return;                                          // RACE, file created ?
    116 
    117         startrm = true;                                                                         // RACE with C-c C-c
     83                nargs += 1;
     84        } // if
     85
     86        value = getenv( "__GCC_VERSION__" );
     87        if ( value != NULL ) {
     88                args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along
     89                #ifdef __DEBUG_H__
     90                cerr << "env arg:\"" << args[nargs] << "\"" << endl;
     91                #endif // __DEBUG_H__
     92                nargs += 1;
     93        } // if
     94} // checkEnv
     95
     96
     97void rmtmpfile() {
    11898        if ( unlink( tmpname ) == -1 ) {                                        // remove tmpname
    119                 perror ( "CC1 Translator error: failed, unlink" );
    120                 exit( EXIT_FAILURE );
    121         } // if
    122         tmpfilefd = -1;                                                                         // mark removed
     99                perror ( "CFA Translator error: cpp failed" );
     100                exit( EXIT_FAILURE );
     101        } // if
     102        tmpfilefd = -1;                                                                         // mark closed
    123103} // rmtmpfile
    124104
    125105
    126 static void sigTermHandler( int ) {                                             // C-c C-c
    127         if ( startrm ) return;                                                          // return and let rmtmpfile finish, and then program finishes
    128 
     106void sigTermHandler( __attribute__((unused)) int signal ) {
    129107        if ( tmpfilefd != -1 ) {                                                        // RACE, file created ?
    130                 rmtmpfile();                                                                    // remove tmpname
    131         } // if
    132         exit( EXIT_FAILURE );                                                           // terminate
     108                rmtmpfile();                                                                    // remove
     109                exit( EXIT_FAILURE );                                                   // terminate
     110        } // if
    133111} // sigTermHandler
    134112
    135113
    136 static void Stage1( const int argc, const char * const argv[] ) {
     114void Stage1( const int argc, const char * const argv[] ) {
    137115        int code;
     116
    138117        string arg;
    139 
    140         const char * cpp_in = nullptr;
    141         const char * cpp_out = nullptr;
    142 
     118        string bprefix;
     119
     120        const char *cpp_in = NULL;
     121        const char *cpp_out = NULL;
     122
     123        bool CFA_flag = false;
    143124        bool cpp_flag = false;
    144         bool o_flag = false;
    145 
    146         const char * args[argc + 100];                                          // leave space for 100 additional cpp command line values
     125        const char *o_name = NULL;
     126
     127        const char *args[argc + 100];                                           // leave space for 100 additional cpp command line values
    147128        int nargs = 1;                                                                          // number of arguments in args list; 0 => command name
     129        const char *cargs[20];                                                          // leave space for 20 additional cfa-cpp command line values
     130        int ncargs = 1;                                                                         // 0 => command name
     131
     132        signal( SIGINT,  sigTermHandler );
     133        signal( SIGTERM, sigTermHandler );
    148134
    149135        #ifdef __DEBUG_H__
    150136        cerr << "Stage1" << endl;
    151137        #endif // __DEBUG_H__
    152         checkEnv1( args, nargs );                                                       // arguments passed via environment variables
     138        checkEnv( args, nargs );                                                        // arguments passed via environment variables
    153139        #ifdef __DEBUG_H__
    154140        for ( int i = 1; i < argc; i += 1 ) {
     
    182168                                i += 1;                                                                 // and the argument
    183169                                cpp_flag = true;
    184 
    185                                 // all other flags
     170                        } else if ( arg == "-D__CFA_PREPROCESS__" ) {
     171                                CFA_flag = true;
     172                        } else if ( arg == "-D" && string( argv[i + 1] ) == "__CFA_PREPROCESS__" ) {
     173                                i += 1;                                                                 // and the argument
     174                                CFA_flag = true;
     175                        } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) {
     176                                cargs[ncargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
     177                                ncargs += 1;
     178                        } else if ( arg == "-D" && prefix( argv[i + 1], D__CFA_FLAGPREFIX__.substr(2) ) ) {
     179                                cargs[ncargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();
     180                                ncargs += 1;
     181                                i += 1;                                                                 // and the argument
     182                        } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
     183                                bprefix = arg.substr( D__GCC_BPREFIX__.size() );
     184                        } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_BPREFIX__.substr(2) ) ) {
     185                                bprefix = string( argv[i + 1] ).substr( D__GCC_BPREFIX__.size() - 2 );
     186                                i += 1;                                                                 // and the argument
     187
     188                        // all other flags
    186189
    187190                        } else if ( arg == "-o" ) {
    188191                                i += 1;
    189                                 o_flag = true;
    190                                 cpp_out = argv[i];
     192                                o_name = argv[i];
    191193                        } else {
    192                                 args[nargs++] = argv[i];                                // pass the flag along
     194                                args[nargs] = argv[i];                                  // pass the flag along
     195                                nargs += 1;
    193196                                // CPP flags with an argument
    194197                                if ( arg == "-D" || arg == "-U" || arg == "-I" || arg == "-MF" || arg == "-MT" || arg == "-MQ" ||
     
    196199                                         arg == "-iwithprefix" || arg == "-iwithprefixbefore" || arg == "-isystem" || arg == "-isysroot" ) {
    197200                                        i += 1;
    198                                         args[nargs++] = argv[i];                        // pass the argument along
     201                                        args[nargs] = argv[i];                          // pass the argument along
     202                                        nargs += 1;
    199203                                        #ifdef __DEBUG_H__
    200204                                        cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    201205                                        #endif // __DEBUG_H__
    202206                                } else if ( arg == "-MD" || arg == "-MMD" ) {
    203                                         args[nargs++] = "-MF";                          // insert before file
     207                                        args[nargs] = "-MF";                            // insert before file
     208                                        nargs += 1;
    204209                                        i += 1;
    205                                         args[nargs++] = argv[i];                        // pass the argument along
     210                                        args[nargs] = argv[i];                          // pass the argument along
     211                                        nargs += 1;
    206212                                        #ifdef __DEBUG_H__
    207213                                        cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     
    210216                        } // if
    211217                } else {                                                                                // obtain input and possibly output files
    212                         if ( cpp_in == nullptr ) {
     218                        if ( cpp_in == NULL ) {
    213219                                cpp_in = argv[i];
    214220                                #ifdef __DEBUG_H__
    215221                                cerr << "cpp_in:\"" << cpp_in << "\"" << endl;
    216222                                #endif // __DEBUG_H__
    217                         } else if ( cpp_out == nullptr ) {
     223                        } else if ( cpp_out == NULL ) {
    218224                                cpp_out = argv[i];
    219225                                #ifdef __DEBUG_H__
     
    232238                cerr << " " << args[i];
    233239        } // for
    234         if ( cpp_in != nullptr ) cerr << " " << cpp_in;
    235         if ( cpp_out != nullptr ) cerr << " " << cpp_out;
     240        if ( cpp_in != NULL ) cerr << " " << cpp_in;
     241        if ( cpp_out != NULL ) cerr << " " << cpp_out;
    236242        cerr << endl;
    237243        #endif // __DEBUG_H__
    238244
    239         if ( cpp_in == nullptr ) {
     245        if ( cpp_in == NULL ) {
    240246                cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl;
    241247                exit( EXIT_FAILURE );
     
    246252                // output or -o. The call to cfa has a -E so it does not have to be added to the argument list.
    247253
    248                 args[0] = compiler_path.c_str();
     254                args[0] = compiler_name.c_str();
    249255                suffix( cpp_in, args, nargs );                                  // check suffix
    250                 args[nargs++] = cpp_in;
    251                 if ( o_flag ) {                                                                 // location for output
    252                         args[nargs++] = "-o";
     256                args[nargs] = cpp_in;
     257                nargs += 1;
     258                if ( o_name != NULL ) {                                                 // location for output
     259                        args[nargs] = "-o";
     260                        nargs += 1;
     261                        args[nargs] = o_name;
     262                        nargs += 1;
    253263                } // if
    254                 args[nargs++] = cpp_out;
    255                 args[nargs] = nullptr;                                                  // terminate argument list
     264                args[nargs] = NULL;                                                             // terminate argument list
    256265
    257266                #ifdef __DEBUG_H__
    258267                cerr << "nargs: " << nargs << endl;
    259                 for ( int i = 0; args[i] != nullptr; i += 1 ) {
     268                for ( int i = 0; args[i] != NULL; i += 1 ) {
    260269                        cerr << args[i] << " ";
    261270                } // for
     
    263272                #endif // __DEBUG_H__
    264273
    265                 execvp( args[0], (char * const *)args );                // should not return
    266                 perror( "CC1 Translator error: stage 1, execvp" );
    267                 exit( EXIT_FAILURE );
    268         } // if
    269 
    270         // Run the C preprocessor and save the output in the given file.
     274                execvp( args[0], (char *const *)args );                 // should not return
     275                perror( "CFA Translator error: cpp level, execvp" );
     276                exit( EXIT_FAILURE );
     277        } // if
     278
     279        // Create a temporary file to store output of the C preprocessor.
     280
     281        tmpfilefd = mkstemp( tmpname );
     282        if ( tmpfilefd == -1 ) {
     283                perror( "CFA Translator error: cpp level, mkstemp" );
     284                exit( EXIT_FAILURE );
     285        } // if
     286
     287        #ifdef __DEBUG_H__
     288        cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl;
     289        #endif // __DEBUG_H__
     290
     291        // Run the C preprocessor and save the output in tmpfile.
    271292
    272293        if ( fork() == 0 ) {                                                             // child process ?
     
    274295                // an error (e.g., cannot find include file). Whereas, output is always generated, even when there is an error,
    275296                // when cpp writes to stdout. Hence, stdout is redirected into the temporary file.
    276                 if ( freopen( cpp_out, "w", stdout ) == nullptr ) { // redirect stdout to output file
    277                         perror( "CC1 Translator error: stage 1, freopen" );
     297                if ( freopen( tmpname, "w", stdout ) == NULL ) { // redirect stdout to tmpname
     298                        perror( "CFA Translator error: cpp level, freopen" );
    278299                        exit( EXIT_FAILURE );
    279300                } // if
    280301
    281                 args[0] = compiler_path.c_str();
     302                args[0] = compiler_name.c_str();
    282303                suffix( cpp_in, args, nargs );                                  // check suffix
    283                 args[nargs++] = cpp_in;                                                 // input to cpp
    284                 args[nargs] = nullptr;                                                  // terminate argument list
     304                args[nargs] = cpp_in;                                                   // input to cpp
     305                nargs += 1;
     306                args[nargs] = NULL;                                                             // terminate argument list
    285307
    286308                #ifdef __DEBUG_H__
    287309                cerr << "cpp nargs: " << nargs << endl;
    288                 for ( int i = 0; args[i] != nullptr; i += 1 ) {
     310                for ( int i = 0; args[i] != NULL; i += 1 ) {
    289311                        cerr << args[i] << " ";
    290312                } // for
     
    292314                #endif // __DEBUG_H__
    293315
    294                 execvp( args[0], (char * const *)args );                // should not return
    295                 perror( "CC1 Translator error: stage 1 cpp, execvp" );
    296                 cerr << " invoked " << args[0] << endl;
     316                execvp( args[0], (char *const *)args );                 // should not return
     317                perror( "CFA Translator error: cpp level, execvp" );
    297318                exit( EXIT_FAILURE );
    298319        } // if
     
    304325        #endif // __DEBUG_H__
    305326
     327        if ( WIFSIGNALED(code) != 0 ) {                                         // child failed ?
     328                rmtmpfile();                                                                    // remove tmpname
     329                cerr << "CFA Translator error: cpp failed with signal " << WTERMSIG(code) << endl;
     330                exit( EXIT_FAILURE );
     331        } // if
     332
     333        if ( WEXITSTATUS(code) != 0 ) {                                         // child error ?
     334                rmtmpfile();                                                                    // remove tmpname
     335                exit( WEXITSTATUS( code ) );                                    // do not continue
     336        } // if
     337
     338        // If -CFA flag specified, run the cfa-cpp preprocessor on the temporary file, and output is written to standard
     339        // output.  Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
     340
     341        if ( fork() == 0 ) {                                                            // child runs CFA
     342                cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
     343
     344                // Source file-name used to generate routine names containing global initializations for TU.
     345                cargs[ncargs] = ( *new string( "-F" ) ).c_str();
     346                ncargs += 1;
     347                cargs[ncargs] = ( *new string( string( cpp_in ) ) ).c_str();
     348                ncargs += 1;
     349
     350                cargs[ncargs] = tmpname;
     351                ncargs += 1;
     352                if ( o_name != NULL ) {
     353                        cargs[ncargs] = o_name;
     354                        ncargs += 1;
     355                } else if ( ! CFA_flag ) {                                              // run cfa-cpp ?
     356                        cargs[ncargs] = cpp_out;
     357                        ncargs += 1;
     358                } // if
     359                cargs[ncargs] = NULL;                                                   // terminate argument list
     360
     361                #ifdef __DEBUG_H__
     362                cerr << "cfa-cpp ncargs: " << (o_name ? o_name : "No -o") << " " << CFA_flag << " " << ncargs << endl;
     363                for ( int i = 0; cargs[i] != NULL; i += 1 ) {
     364                        cerr << cargs[i] << " ";
     365                } // for
     366                cerr << endl;
     367                #endif // __DEBUG_H__
     368
     369                execvp( cargs[0], (char * const *)cargs );              // should not return
     370                perror( "CFA Translator error: cpp level, execvp" );
     371                exit( EXIT_FAILURE );
     372        } // if
     373
     374        wait( &code );                                                                          // wait for child to finish
     375
     376        #ifdef __DEBUG_H__
     377        cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl;
     378        #endif // __DEBUG_H__
     379
     380        // Must unlink here because file must exist across execvp.
     381        rmtmpfile();                                                                            // remove tmpname
     382
    306383        if ( WIFSIGNALED(code) ) {                                                      // child failed ?
    307                 cerr << "CC1 Translator error: stage 1, child failed " << WTERMSIG(code) << endl;
    308                 exit( EXIT_FAILURE );
    309         } // if
    310 
    311         exit( WEXITSTATUS(code) );                                                      // bad cpp result stops top-level gcc
     384                cerr << "CFA Translator error: cfa-cpp failed with signal " << WTERMSIG(code) << endl;
     385                exit( EXIT_FAILURE );
     386        } // if
     387
     388        exit( WEXITSTATUS(code) );
    312389} // Stage1
    313390
    314391
    315 static void Stage2( const int argc, const char * const * argv ) {
    316         int code;
     392void Stage2( const int argc, const char * const * argv ) {
    317393        string arg;
    318394
    319         const char * cpp_in = nullptr;
    320         const char * cpp_out = nullptr;
    321 
    322         const char * args[argc + 100];                                          // leave space for 100 additional cfa command line values
     395        const char *cpp_in = NULL;
     396
     397        const char *args[argc + 100];                                           // leave space for 100 additional cfa command line values
    323398        int nargs = 1;                                                                          // number of arguments in args list; 0 => command name
    324         const char * cargs[20];                                                         // leave space for 20 additional cfa-cpp command line values
    325         int ncargs = 1;                                                                         // 0 => command name
    326399
    327400        #ifdef __DEBUG_H__
    328401        cerr << "Stage2" << endl;
    329402        #endif // __DEBUG_H__
    330         checkEnv2( cargs, ncargs );                                                     // arguments passed via environment variables
     403        checkEnv( args, nargs );                                                        // arguments passed via environment variables
    331404        #ifdef __DEBUG_H__
    332405        for ( int i = 1; i < argc; i += 1 ) {
     
    357430
    358431                        } else {
    359                                 args[nargs++] = argv[i];                                // pass the flag along
     432                                args[nargs] = argv[i];                                  // pass the flag along
     433                                nargs += 1;
    360434                                if ( arg == "-o" ) {
    361435                                        i += 1;
    362                                         cpp_out = argv[i];
    363                                         args[nargs++] = argv[i];                        // pass the argument along
     436                                        args[nargs] = argv[i];                          // pass the argument along
     437                                        nargs += 1;
    364438                                        #ifdef __DEBUG_H__
    365439                                        cerr << "arg:\"" << argv[i] << "\"" << endl;
     
    368442                        } // if
    369443                } else {                                                                                // obtain input and possibly output files
    370                         if ( cpp_in == nullptr ) {
     444                        if ( cpp_in == NULL ) {
    371445                                cpp_in = argv[i];
    372446                                #ifdef __DEBUG_H__
    373447                                cerr << "cpp_in:\"" << cpp_in << "\"" << endl;
    374448                                #endif // __DEBUG_H__
    375                         } else if ( cpp_out == nullptr ) {
    376                                 cpp_out = argv[i];
    377                                 #ifdef __DEBUG_H__
    378                                 cerr << "cpp_out:\"" << cpp_out << "\""<< endl;
    379                                 #endif // __DEBUG_H__
    380449                        } else {
    381                                 cerr << "Usage: " << argv[0] << " more than two files specified" << endl;
     450                                cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl;
    382451                                exit( EXIT_FAILURE );
    383452                        } // if
     
    385454        } // for
    386455
    387         if ( cpp_in == nullptr ) {
    388                 cerr << "Usage: " << argv[0] << " missing input file" << endl;
    389                 exit( EXIT_FAILURE );
    390         } // if
    391         if ( cpp_out == nullptr ) {
    392                 cerr << "Usage: " << argv[0] << " missing output file" << endl;
    393                 exit( EXIT_FAILURE );
    394         } // if
    395 
    396         // Create a temporary file, if needed, to store output of the cfa-cpp preprocessor. Cannot be created in forked
    397         // process because variables tmpname and tmpfilefd are cloned.
    398 
    399         string cfa_cpp_out;
    400 
    401         if ( ! CFA_flag ) {                                                                     // run compiler ?
    402                 if ( save_temps ) {
    403                         cfa_cpp_out = cpp_in;
    404                         size_t dot = cfa_cpp_out.find_last_of( "." );
    405                         if ( dot == string::npos ) {
    406                                 cerr << "CC1 Translator error: stage 2, bad file name " << endl;
    407                                 exit( EXIT_FAILURE );
    408                         } // if
    409 
    410                         cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + ".ifa";
    411                         if ( creat( cfa_cpp_out.c_str(), 0666 ) == -1 ) {
    412                                 perror( "CC1 Translator error: stage 2, creat" );
    413                                 exit( EXIT_FAILURE );
    414                         } // if
    415                 } else {
    416                         tmpfilefd = mkstemps( tmpname, 4 );
    417                         if ( tmpfilefd == -1 ) {
    418                                 perror( "CC1 Translator error: stage 2, mkstemp" );
    419                                 exit( EXIT_FAILURE );
    420                         } // if
    421                         cfa_cpp_out = tmpname;
    422                 } // if
    423                 #ifdef __DEBUG_H__
    424                 cerr << "cfa_cpp_out: " << cfa_cpp_out << endl;
    425                 #endif // __DEBUG_H__
    426         } // if
    427 
    428         // If -CFA flag specified, run the cfa-cpp preprocessor on the temporary file, and output is written to standard
    429         // output.  Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
    430 
    431         if ( fork() == 0 ) {                                                            // child runs CFA
    432                 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
    433                 cargs[ncargs++] = cpp_in;
    434 
    435                 if ( CFA_flag ) {                                                               // run cfa-cpp ?
    436                         if ( o_file.size() != 0 ) {                                     // location for output
    437                                 cargs[ncargs++] = ( *new string( o_file.c_str() ) ).c_str();
    438                         } // if
    439                 } else {
    440                         cargs[ncargs++] = cfa_cpp_out.c_str();
    441                 } // if
    442                 cargs[ncargs] = nullptr;                                                // terminate argument list
    443 
    444                 #ifdef __DEBUG_H__
    445                 for ( int i = 0; cargs[i] != nullptr; i += 1 ) {
    446                         cerr << cargs[i] << " ";
    447                 } // for
    448                 cerr << endl;
    449                 #endif // __DEBUG_H__
    450 
    451                 execvp( cargs[0], (char * const *)cargs );              // should not return
    452                 perror( "CC1 Translator error: stage 2 cfa-cpp, execvp" );
    453                 cerr << " invoked " << cargs[0] << endl;
    454                 exit( EXIT_FAILURE );
    455         } // if
    456 
    457         wait( &code );                                                                          // wait for child to finish
    458 
    459         if ( WIFSIGNALED(code) ) {                                                      // child failed ?
    460                 rmtmpfile();                                                                    // remove tmpname
    461                 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
    462                 exit( EXIT_FAILURE );
    463         } // if
    464 
    465         if ( CFA_flag ) {                                                                       // no tmpfile created
    466                 exit( WEXITSTATUS( code ) );                                    // stop regardless of success or failure
    467         } // if
    468 
    469         #ifdef __DEBUG_H__
    470         cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl;
    471         #endif // __DEBUG_H__
    472 
    473         if ( WEXITSTATUS(code) ) {                                                      // child error ?
    474                 rmtmpfile();                                                                    // remove tmpname
    475                 exit( WEXITSTATUS( code ) );                                    // do not continue
    476         } // if
    477 
    478456        #ifdef __DEBUG_H__
    479457        cerr << "args:";
     
    481459                cerr << " " << args[i];
    482460        } // for
    483         cerr << " " << cpp_in << endl;
    484         #endif // __DEBUG_H__
    485 
    486         if ( fork() == 0 ) {                                                            // child runs CFA
    487                 args[0] = compiler_path.c_str();
    488                 args[nargs++] = "-S";                                                   // only compile and put assembler output in specified file
    489                 args[nargs++] = "-x";
    490                 args[nargs++] = "cpp-output";
    491 
    492                 args[nargs++] = cfa_cpp_out.c_str();
    493                 args[nargs] = nullptr;                                                  // terminate argument list
    494 
    495                 #ifdef __DEBUG_H__
    496                 cerr << "stage2 nargs: " << nargs << endl;
    497                 for ( int i = 0; args[i] != nullptr; i += 1 ) {
    498                         cerr << args[i] << " ";
    499                 } // for
    500                 cerr << endl;
    501                 #endif // __DEBUG_H__
    502 
    503                 execvp( args[0], (char * const *)args );                // should not return
    504                 perror( "CC1 Translator error: stage 2 cc1, execvp" );
    505                 cerr << " invoked " << cargs[0] << endl;
    506                 exit( EXIT_FAILURE );                                                   // tell gcc not to go any further
    507         } // if
    508 
    509         wait( &code );                                                                          // wait for child to finish
    510         rmtmpfile();                                                                            // remove tmpname
    511 
    512         if ( WIFSIGNALED(code) ) {                                                      // child failed ?
    513                 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
    514                 exit( EXIT_FAILURE );
    515         } // if
    516 
    517         #ifdef __DEBUG_H__
    518         cerr << "return code from gcc cc1:" << WEXITSTATUS(code) << endl;
    519         #endif // __DEBUG_H__
    520 
    521         exit( WEXITSTATUS( code ) );                                            // stop regardless of success or failure
     461        cerr << endl;
     462        if ( cpp_in != NULL ) cerr << " " << cpp_in;
     463        #endif // __DEBUG_H__
     464
     465        args[0] = compiler_name.c_str();
     466        args[nargs] = "-S";                                                                     // only compile and put assembler output in specified file
     467        nargs += 1;
     468        args[nargs] = cpp_in;
     469        nargs += 1;
     470        args[nargs] = NULL;                                                                     // terminate argument list
     471
     472        #ifdef __DEBUG_H__
     473        cerr << "stage2 nargs: " << nargs << endl;
     474        for ( int i = 0; args[i] != NULL; i += 1 ) {
     475                cerr << args[i] << " ";
     476        } // for
     477        cerr << endl;
     478        #endif // __DEBUG_H__
     479
     480        execvp( args[0], (char * const *)args );                        // should not return
     481        perror( "CFA Translator error: cpp level, execvp" );
     482        exit( EXIT_FAILURE );                                                           // tell gcc not to go any further
    522483} // Stage2
    523484
    524485
    525 // This program is called twice because of the -no-integrated-cpp. The calls are differentiated by the first
    526 // command-line argument. The first call replaces the traditional cpp pass to preprocess the C program. The second call
    527 // is to the compiler, which is broken into two steps: preprocess again with cfa-cpp and then call gcc to compile the
    528 // doubly preprocessed program.
    529 
    530486int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    531487        #ifdef __DEBUG_H__
    532         for ( int i = 0; env[i] != nullptr; i += 1 ) {
     488        for ( int i = 0; env[i] != NULL; i += 1 ) {
    533489                cerr << env[i] << endl;
    534490        } // for
    535491        #endif // __DEBUG_H__
    536492
    537         signal( SIGINT,  sigTermHandler );
    538         signal( SIGTERM, sigTermHandler );
    539 
    540         string arg( argv[1] );
     493        string arg = argv[1];
    541494
    542495        // Currently, stage 1 starts with flag -E and stage 2 with flag -fpreprocessed.
  • driver/cfa.cc

    r970141d r85142648  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 10 17:00:15 2019
    13 // Update Count     : 420
     12// Last Modified On : Sat Aug 10 08:44:15 2019
     13// Update Count     : 311
    1414//
    1515
     
    2828#include "config.h"                                                                             // configure info
    2929
     30
    3031using std::cerr;
    3132using std::endl;
     
    3334using std::to_string;
    3435
    35 // #define __DEBUG_H__
    36 
    37 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
    38 
    39 void Putenv( char * argv[], string arg ) {
    40         // environment variables must have unique names
    41         static int flags = 0;
    42 
    43         if ( putenv( (char *)( *new string( string( __CFA_FLAGPREFIX__ + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
    44                 cerr << argv[0] << " error, cannot set environment variable." << endl;
    45                 exit( EXIT_FAILURE );
    46         } // if
    47 } // Putenv
    48 
    49 // check if string has prefix
    50 bool prefix( const string & arg, const string & pre ) {
     36
     37//#define __DEBUG_H__
     38
     39
     40bool prefix( string arg, string pre ) {
    5141        return arg.substr( 0, pre.size() ) == pre;
    5242} // prefix
    5343
    54 inline bool ends_with(const string & str, const string & sfix) {
    55         if (sfix.size() > str.size()) return false;
    56         return std::equal(str.rbegin(), str.rbegin() + sfix.size(), sfix.rbegin(), sfix.rend());
    57 }
    58 
    59 bool suffix( const string & arg ) {                                             // check if string has suffix
     44bool suffix( string arg ) {
    6045        enum { NumSuffixes = 3 };
    6146        static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
    62 
     47        //std::cerr << arg << std::endl;
    6348        size_t dot = arg.find_last_of( "." );
     49        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    6450        if ( dot == string::npos ) return false;
    6551        const string * end = suffixes + NumSuffixes;
     
    6854
    6955
    70 static inline bool dirExists( const string & path ) {   // check if directory exists
     56void shuffle( const char * args[], int S, int E, int N ) {
     57        // S & E index 1 passed the end so adjust with -1
     58        #ifdef __DEBUG_H__
     59        cerr << "shuffle:" << S << " " << E << " " << N << endl;
     60        #endif // __DEBUG_H__
     61        for ( int j = E-1 + N; j > S-1 + N; j -=1 ) {
     62                #ifdef __DEBUG_H__
     63                cerr << "\t" << j << " " << j-N << endl;
     64                #endif // __DEBUG_H__
     65                args[j] = args[j-N];
     66        } // for
     67} // shuffle
     68
     69static inline bool dirExists( const string & path ) {
    7170    struct stat info;
    72     if ( stat( path.c_str(), &info ) != 0 ) return false;
    73         return (info.st_mode & S_IFDIR) != 0;
    74 } // dirExists
    75 
    76 static inline string dir(const string & path) {
    77         return path.substr(0, path.find_last_of('/'));
    78 }
    79 
    80 
    81 #define xstr(s) str(s)
     71    if(stat( path.c_str(), &info ) != 0)
     72        return false;
     73    else if(info.st_mode & S_IFDIR)
     74        return true;
     75    else
     76        return false;
     77} //dirExists
     78
     79
    8280#define str(s) #s
    8381
    8482int main( int argc, char * argv[] ) {
    8583        string Version( CFA_VERSION_LONG );                                     // current version number from CONFIG
    86         string Major( xstr( CFA_VERSION_MAJOR ) ), Minor( xstr( CFA_VERSION_MINOR ) ), Patch( xstr( CFA_VERSION_PATCH ) );
     84        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
    8785
    8886        string installincdir( CFA_INCDIR );                                     // fixed location of include files
     
    9290        string heading;                                                                         // banner printed at start of cfa compilation
    9391        string arg;                                                                                     // current command-line argument during command-line parsing
    94         string bprefix;                                                                         // path where gcc looks for compiler steps
     92        string Bprefix;                                                                         // path where gcc looks for compiler command steps
    9593        string langstd;                                                                         // language standard
    9694
     
    9997
    10098        bool x_flag = false;                                                            // -x flag
    101         bool nonoptarg = false;                                                         // no non-option arguments specified, i.e., no file names
    102         bool link = true;                                                                       // link stage occurring
     99        bool nonoptarg = false;                                                         // indicates non-option argument specified
     100        bool link = true;                                                                       // linking as well as compiling
    103101        bool verbose = false;                                                           // -v flag
    104102        bool quiet = false;                                                                     // -quiet flag
     
    113111        bool m32 = false;                                                                       // -m32 flag
    114112        bool m64 = false;                                                                       // -m64 flag
    115         bool intree = false;                                                            // build in tree
    116         bool compiling_libs = false;
    117         bool disttree = false;
    118         int o_file = 0;                                                                         // -o filename position
     113        bool intree = false;
    119114
    120115        const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
     
    140135
    141136                        if ( arg == "-Xlinker" || arg == "-o" ) {
    142                                 args[nargs++] = argv[i];                                // pass argument along
     137                                args[nargs] = argv[i];                                  // pass the argument along
     138                                nargs += 1;
    143139                                i += 1;
    144140                                if ( i == argc ) continue;                              // next argument available ?
    145                                 args[nargs++] = argv[i];                                // pass argument along
    146                                 if ( arg == "-o" ) o_file = i;                  // remember file
     141                                args[nargs] = argv[i];                                  // pass the argument along
     142                                nargs += 1;
    147143                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
    148144                                i += 1;
    149                                 Putenv( argv, argv[i] );
     145                                args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + argv[i] ) ).c_str();
     146                                nargs += 1;
    150147
    151148                                // CFA specific arguments
     
    154151                                CFA_flag = true;                                                // strip the -CFA flag
    155152                                link = false;
    156                                 args[nargs++] = "-fsyntax-only";                // stop after stage 2
     153                                args[nargs] = "-E";                                             // replace the argument with -E
     154                                nargs += 1;
    157155                        } else if ( arg == "-debug" ) {
    158156                                debug = true;                                                   // strip the debug flag
    159157                        } else if ( arg == "-nodebug" ) {
    160                                 debug = false;                                                  // strip the nodebug flag
     158                                debug = false;                                                  // strip the debug flag
    161159                        } else if ( arg == "-nolib" ) {
    162160                                nolib = true;                                                   // strip the nodebug flag
     
    173171                        } else if ( arg == "-in-tree" ) {
    174172                                intree = true;
    175                         } else if ( arg == "-dist-tree" ) {
    176                                 disttree = true;
    177                         } else if ( arg == "-cfalib") {
    178                                 compiling_libs = true;
    179173                        } else if ( arg == "-compiler" ) {
    180174                                // use the user specified compiler
     
    182176                                if ( i == argc ) continue;                              // next argument available ?
    183177                                compiler_path = argv[i];
    184                                 Putenv( argv, arg + "=" + argv[i] );
     178                                if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
     179                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
     180                                        exit( EXIT_FAILURE );
     181                                } // if
    185182
    186183                                // C specific arguments
     
    188185                        } else if ( arg == "-v" ) {
    189186                                verbose = true;                                                 // verbosity required
    190                                 args[nargs++] = argv[i];                                // pass argument along
     187                                args[nargs] = argv[i];                                  // pass the argument along
     188                                nargs += 1;
    191189                        } else if ( arg == "-g" ) {
    192190                                debugging = true;                                               // symbolic debugging required
    193                                 args[nargs++] = argv[i];                                // pass argument along
    194                         } else if ( arg == "-save-temps" ) {
    195                                 args[nargs++] = argv[i];                                // pass argument along
    196                                 Putenv( argv, arg );                                    // save cfa-cpp output
     191                                args[nargs] = argv[i];                                  // pass the argument along
     192                                nargs += 1;
    197193                        } else if ( prefix( arg, "-x" ) ) {                     // file suffix ?
    198194                                string lang;
    199                                 args[nargs++] = argv[i];                                // pass argument along
     195                                args[nargs] = argv[i];                                  // pass the argument along
     196                                nargs += 1;
    200197                                if ( arg.length() == 2 ) {                              // separate argument ?
    201198                                        i += 1;
    202199                                        if ( i == argc ) continue;                      // next argument available ?
    203200                                        lang = argv[i];
    204                                         args[nargs++] = argv[i];                        // pass argument along
     201                                        args[nargs] = argv[i];                          // pass the argument along
     202                                        nargs += 1;
    205203                                } else {
    206204                                        lang = arg.substr( 2 );
     
    209207                        } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
    210208                                std_flag = true;                                                // -std=XX provided
    211                                 args[nargs++] = argv[i];                                // pass argument along
     209                                args[nargs] = argv[i];                                  // pass the argument along
     210                                nargs += 1;
    212211                        } else if ( arg == "-w" ) {
    213                                 args[nargs++] = argv[i];                                // pass argument along
    214                                 Putenv( argv, arg );
     212                                args[nargs] = argv[i];                                  // pass the argument along
     213                                nargs += 1;
     214                                args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
     215                                nargs += 1;
    215216                        } else if ( prefix( arg, "-W" ) ) {                     // check before next tests
    216217                                if ( arg == "-Werror" || arg == "-Wall" ) {
    217                                         args[nargs++] = argv[i];                        // pass argument along
    218                                         Putenv( argv, argv[i] );
     218                                        args[nargs] = argv[i];                          // pass the argument along
     219                                        nargs += 1;
     220                                        args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
     221                                        nargs += 1;
    219222                                } else {
    220223                                        unsigned int adv = prefix( arg, "-Wno-" ) ? 5 : 2;
    221                                         args[nargs] = argv[i];                          // conditionally pass argument along
    222                                         const char * warning = argv[i] + adv; // extract warning
     224                                        args[nargs] = argv[i];                          // conditionally pass the argument along
     225                                        const char * warning = argv[i] + adv;    // extract warning
    223226                                        if ( SemanticWarning_Exist( warning ) ) { // replace the argument for cfa-cpp
    224                                                 Putenv( argv, arg );
     227                                                args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str();
    225228                                        } // if
    226229                                        nargs += 1;
    227230                                } // if
    228231                        } else if ( prefix( arg, "-B" ) ) {
    229                                 bprefix = arg.substr(2);                                // strip the -B flag
     232                                Bprefix = arg.substr(2);                                // strip the -B flag
     233                                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
     234                                nargs += 1;
     235                        } else if ( prefix( arg, "-b" ) ) {
     236                                if ( arg.length() == 2 ) {                              // separate argument ?
     237                                        i += 1;
     238                                        if ( i == argc ) continue;                      // next argument available ?
     239                                        arg += argv[i];                                         // concatenate argument
     240                                } // if
     241                                // later versions of gcc require the -b option to appear at the start of the command line
     242                                shuffle( args, sargs, nargs, 1 );               // make room at front of argument list
     243                                args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
     244                                if ( putenv( (char *)( *new string( string( "__GCC_MACHINE__=" ) + arg ) ).c_str() ) != 0 ) {
     245                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
     246                                        exit( EXIT_FAILURE );
     247                                } // if
     248                                sargs += 1;
     249                                nargs += 1;
     250                        } else if ( prefix( arg, "-V" ) ) {
     251                                if ( arg.length() == 2 ) {                              // separate argument ?
     252                                        i += 1;
     253                                        if ( i == argc ) continue;                      // next argument available ?
     254                                        arg += argv[i];                                         // concatenate argument
     255                                } // if
     256                                // later versions of gcc require the -V option to appear at the start of the command line
     257                                shuffle( args, sargs, nargs, 1 );               // make room at front of argument list
     258                                args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
     259                                if ( putenv( (char *)( *new string( string( "__GCC_VERSION__=" ) + arg ) ).c_str() ) != 0 ) {
     260                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
     261                                        exit( EXIT_FAILURE );
     262                                } // if
     263                                sargs += 1;
     264                                nargs += 1;
    230265                        } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) {
    231                                 args[nargs++] = argv[i];                                // pass argument along
     266                                args[nargs] = argv[i];                                  // pass the argument along
     267                                nargs += 1;
    232268                                if ( arg == "-E" || arg == "-M" || arg == "-MM" ) {
    233269                                        cpp_flag = true;                                        // cpp only
     
    236272                        } else if ( arg[1] == 'l' ) {
    237273                                // if the user specifies a library, load it after user code
    238                                 libs[nlibs++] = argv[i];
     274                                libs[nlibs] = argv[i];
     275                                nlibs += 1;
    239276                        } else if ( arg == "-m32" ) {
    240277                                m32 = true;
    241278                                m64 = false;
    242                                 args[nargs++] = argv[i];
     279                                args[nargs] = argv[i];
     280                                nargs += 1;
    243281                        } else if ( arg == "-m64" ) {
    244282                                m64 = true;
    245283                                m32 = false;
    246                                 args[nargs++] = argv[i];
     284                                args[nargs] = argv[i];
     285                                nargs += 1;
    247286                        } else {
    248287                                // concatenate any other arguments
    249                                 args[nargs++] = argv[i];
     288                                args[nargs] = argv[i];
     289                                nargs += 1;
    250290                        } // if
    251291                } else {
    252292                        bool cfa = suffix( arg );                                       // check suffix
    253293                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
    254                                 args[nargs++] = "-x";
    255                                 args[nargs++] = "c";
     294                                args[nargs] = "-x";
     295                                nargs += 1;
     296                                args[nargs] = "c";
     297                                nargs += 1;
    256298                        } // if
    257                         args[nargs++] = argv[i];                                        // concatenate files
     299                        args[nargs] = argv[i];                                          // concatenate file
     300                        nargs += 1;
    258301                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
    259                                 args[nargs++] = "-x";
    260                                 args[nargs++] = "none";
     302                                args[nargs] = "-x";
     303                                nargs += 1;
     304                                args[nargs] = "none";
     305                                nargs += 1;
    261306                        } // if
    262307                        nonoptarg = true;
     
    265310
    266311        #ifdef __x86_64__
    267         args[nargs++] = "-mcx16";                                                       // allow double-wide CAA
     312        args[nargs] = "-mcx16";                                                         // allow double-wide CAA
     313        nargs += 1;
    268314        #endif // __x86_64__
    269315
     
    276322        #endif // __DEBUG_H__
    277323
    278         // -E flag stops at cc1 stage 1, so cfa-cpp in cc1 stage 2 is never executed.
    279324        if ( cpp_flag && CFA_flag ) {
    280                 CFA_flag = false;
    281                 cerr << argv[0] << " warning, both -E and -CFA flags specified, using -E and ignoring -CFA." << endl;
     325                cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
     326                exit( EXIT_FAILURE );
    282327        } // if
    283328
    284329        // add the CFA include-library paths, which allow direct access to header files without directory qualification
    285         if ( ! intree ) {
    286                 args[nargs++] = "-I" CFA_INCDIR;
     330        if( !intree ) {
     331                args[nargs] = "-I" CFA_INCDIR;
     332                nargs += 1;
    287333                if ( ! noincstd_flag ) {                                                // do not use during build
    288                         args[nargs++] = "-I" CFA_INCDIR "stdhdr";
     334                        args[nargs] = "-I" CFA_INCDIR "stdhdr";
     335                        nargs += 1;
    289336                } // if
    290                 args[nargs++] = "-I" CFA_INCDIR "concurrency";
    291                 args[nargs++] = "-I" CFA_INCDIR "containers";
     337                args[nargs] = "-I" CFA_INCDIR "concurrency";
     338                nargs += 1;
     339                args[nargs] = "-I" CFA_INCDIR "containers";
     340                nargs += 1;
    292341        } else {
    293                 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src";
     342                args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
     343                nargs += 1;
    294344                if ( ! noincstd_flag ) {                                                // do not use during build
    295                         args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
     345                        args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
     346                        nargs += 1;
    296347                } // if
    297                 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
    298                 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
    299         } // if
     348                args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
     349                nargs += 1;
     350                args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
     351                nargs += 1;
     352        }
    300353
    301354        // add stdbool to get defines for bool/true/false
    302         args[nargs++] = "-imacros";
    303         args[nargs++] = "stdbool.h";
     355        args[nargs] = "-imacros";
     356        nargs += 1;
     357        args[nargs] = "stdbool.h";
     358        nargs += 1;
    304359
    305360        string libbase;
    306         if ( ! intree ) {
     361        if( !intree ) {
    307362                libbase = CFA_LIBDIR;
    308363        } else {
    309364                libbase = TOP_BUILDDIR "libcfa/";
    310         } // if
    311 
    312         if( compiling_libs ) {
    313                 Putenv( argv, "-t" );
    314         } // if
    315 
    316         string arch( m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU) );
     365                args[nargs] = "-D__CFA_FLAG__=-t";
     366                nargs += 1;
     367        }
     368
     369        string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
    317370        if ( ! m32 && ! m64 ) {
    318371                if ( arch == "x86" ) {
    319                         args[nargs++] = "-m32";
     372                        args[nargs] = "-m32";
     373                        nargs += 1;
    320374                } else if ( arch == "x64" ) {
    321                         args[nargs++] = "-m64";
     375                        args[nargs] = "-m64";
     376                        nargs += 1;
    322377                }  // if
    323378        } // if
    324 
    325379        const char * config = nolib ? "nolib" : (debug ? "debug": "nodebug");
    326380        string libdir = libbase + arch + "-" + config;
    327381
    328         if (!disttree) {
    329                 if ( ! nolib && ! dirExists( libdir ) ) {
    330                         cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
    331                         cerr << "Was looking for " << libdir << endl;
    332                         for(int i = 1; i < argc; i++) {
    333                                 cerr << argv[i] << " ";
    334                         }
    335                         cerr << endl;
    336                         libdir = libbase + arch + "-" + "nolib";
    337                 } // if
    338 
    339                 if ( ! dirExists( libdir ) ) {
    340                         cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
    341                         cerr << "Was looking for " << libdir << endl;
    342                         exit( EXIT_FAILURE );
    343                 } // if
    344         } // if
    345 
    346         if(disttree) {
    347                 Putenv( argv, "--prelude-dir=" + dir(argv[0]) );
    348         } else if(intree) {
    349                 Putenv( argv, "--prelude-dir=" + libdir + "/prelude" );
     382        if ( ! nolib && ! 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        } // if
     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        } // if
     393
     394        args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
     395        nargs += 1;
     396
     397        for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries
     398                args[nargs] = libs[i];
     399                nargs += 1;
     400        } // for
     401
     402        if ( link ) {
     403                args[nargs] = "-Xlinker";
     404                nargs += 1;
     405                args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
     406                nargs += 1;
     407                args[nargs] = "-Xlinker";
     408                nargs += 1;
     409                args[nargs] = "--undefined=__cfaabi_interpose_startup";
     410                nargs += 1;
     411                args[nargs] = "-Xlinker";
     412                nargs += 1;
     413                args[nargs] = "--undefined=__cfaabi_appready_startup";
     414                nargs += 1;
     415
     416                // include the cfa library in case it's needed
     417                args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     418                nargs += 1;
     419                args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     420                nargs += 1;
     421                args[nargs] = "-Wl,--push-state,--as-needed";
     422                nargs += 1;
     423                args[nargs] = "-lcfathread";
     424                nargs += 1;
     425                args[nargs] = "-Wl,--pop-state";
     426                nargs += 1;
     427                args[nargs] = "-lcfa";
     428                nargs += 1;
     429                args[nargs] = "-lpthread";
     430                nargs += 1;
     431                args[nargs] = "-ldl";
     432                nargs += 1;
     433                args[nargs] = "-lrt";
     434                nargs += 1;
     435                args[nargs] = "-lm";
     436                nargs += 1;
     437        } // if
     438
     439        // Add exception flags (unconditionally)
     440        args[nargs] = "-fexceptions";
     441        nargs += 1;
     442
     443        // add the correct set of flags based on the type of compile this is
     444
     445        args[nargs] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
     446        nargs += 1;
     447        args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
     448        nargs += 1;
     449        args[nargs] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
     450        nargs += 1;
     451        args[nargs] = "-D__CFA__";
     452        nargs += 1;
     453        args[nargs] = "-D__CFORALL__";
     454        nargs += 1;
     455        args[nargs] = "-D__cforall";
     456        nargs += 1;
     457
     458        if ( cpp_flag ) {
     459                args[nargs] = "-D__CPP__";
     460                nargs += 1;
     461        } // if
     462
     463        shuffle( args, sargs, nargs, 1 );                                       // make room at front of argument list
     464        nargs += 1;
     465        if ( CFA_flag ) {
     466                args[sargs] = "-D__CFA_FLAG__=-N";
     467                args[nargs] = "-D__CFA_PREPROCESS_";
     468                nargs += 1;
    350469        } else {
    351                 Putenv( argv, "--prelude-dir=" + libdir );
    352         }
    353 
    354         for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries
    355                 args[nargs++] = libs[i];
    356         } // for
    357 
    358         if ( link ) {
    359                 args[nargs++] = "-Xlinker";
    360                 args[nargs++] = "--undefined=__cfaabi_dbg_bits_write";
    361                 args[nargs++] = "-Xlinker";
    362                 args[nargs++] = "--undefined=__cfaabi_interpose_startup";
    363                 args[nargs++] = "-Xlinker";
    364                 args[nargs++] = "--undefined=__cfaabi_appready_startup";
    365 
    366                 // include the cfa library in case it is needed
    367                 args[nargs++] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    368                 args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    369                 args[nargs++] = "-Wl,--push-state,--as-needed";
    370                 args[nargs++] = "-lcfathread";
    371                 args[nargs++] = "-Wl,--pop-state";
    372                 args[nargs++] = "-lcfa";
    373                 args[nargs++] = "-lpthread";
    374                 args[nargs++] = "-ldl";
    375                 args[nargs++] = "-lrt";
    376                 args[nargs++] = "-lm";
    377         } // if
    378 
    379         args[nargs++] = "-fexceptions";                                         // add exception flags (unconditionally)
    380 
    381         // add flags based on the type of compile
    382 
    383         args[nargs++] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
    384         args[nargs++] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
    385         args[nargs++] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
    386         args[nargs++] = "-D__CFA__";
    387         args[nargs++] = "-D__CFORALL__";
    388         args[nargs++] = "-D__cforall";
    389 
    390         if ( cpp_flag ) {
    391                 args[nargs++] = "-D__CPP__";
    392         } // if
    393 
    394         if ( CFA_flag ) {
    395                 Putenv( argv, "-N" );
    396                 Putenv( argv, "-CFA" );
    397                 // -CFA implies cc1 stage 2, but gcc does not pass the -o file to this stage because it believe the file is for
    398                 // the linker. Hence, the -o file is explicit passed to cc1 stage 2 and used as cfa-cpp's output file.
    399                 if ( o_file ) Putenv( argv, string( "-o=" ) + argv[o_file] );
    400         } else {
    401                 Putenv( argv, "-L" );
    402         } // if
     470                args[sargs] = "-D__CFA_FLAG__=-L";
     471        } // if
     472        sargs += 1;
    403473
    404474        if ( debug ) {
    405475                heading += " (debug)";
    406                 args[nargs++] = "-D__CFA_DEBUG__";
     476                args[nargs] = "-D__CFA_DEBUG__";
     477                nargs += 1;
    407478        } else {
    408479                heading += " (no debug)";
    409480        } // if
    410481
    411         if ( bprefix.length() == 0 ) {
    412                 if(disttree) {
    413                         bprefix = dir(argv[0]);
    414                 } else if(intree) {
    415                         bprefix = srcdriverdir;
    416                 } else {
    417                         bprefix = installlibdir;
    418                 }
    419                 if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/';
    420                 Putenv( argv, string("-B=") + bprefix );
    421         } // if
    422 
    423         args[nargs++] = "-Xlinker";                                                     // used by backtrace
    424         args[nargs++] = "-export-dynamic";
     482        if ( Bprefix.length() == 0 ) {
     483                Bprefix = ! intree ? installlibdir : srcdriverdir;
     484                if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
     485                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
     486                nargs += 1;
     487        } // if
     488
     489        args[nargs] = "-Xlinker";                                                       // used by backtrace
     490        nargs += 1;
     491        args[nargs] = "-export-dynamic";
     492        nargs += 1;
    425493
    426494        // execute the compilation command
     
    436504
    437505        if ( prefix( compiler_name, "gcc" ) ) {                         // allow suffix on gcc name
    438                 args[nargs++] = "-no-integrated-cpp";
    439                 args[nargs++] = "-Wno-deprecated";
    440                 #ifdef HAVE_CAST_FUNCTION_TYPE
    441                 args[nargs++] = "-Wno-cast-function-type";
    442                 #endif // HAVE_CAST_FUNCTION_TYPE
     506                args[nargs] = "-no-integrated-cpp";
     507                nargs += 1;
     508                args[nargs] = "-Wno-deprecated";
     509                nargs += 1;
     510#ifdef HAVE_CAST_FUNCTION_TYPE
     511                args[nargs] = "-Wno-cast-function-type";
     512                nargs += 1;
     513#endif // HAVE_CAST_FUNCTION_TYPE
    443514                if ( ! std_flag ) {                                                             // default c11, if none specified
    444                         args[nargs++] = "-std=gnu11";
     515                        args[nargs] = "-std=gnu11";
     516                        nargs += 1;
    445517                } // if
    446                 args[nargs++] = "-fgnu89-inline";
    447                 args[nargs++] = "-D__int8_t_defined";                   // prevent gcc type-size attributes
    448                 args[nargs++] = ( *new string( string("-B") + bprefix ) ).c_str();
     518                args[nargs] = "-fgnu89-inline";
     519                nargs += 1;
     520                args[nargs] = "-D__int8_t_defined";                             // prevent gcc type-size attributes
     521                nargs += 1;
     522                args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
     523                nargs += 1;
    449524        } else {
    450525                cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
     
    452527        } // if
    453528
    454         args[nargs] = nullptr;                                                          // terminate
     529        args[nargs] = NULL;                                                                     // terminate with NULL
    455530
    456531        #ifdef __DEBUG_H__
    457532        cerr << "nargs: " << nargs << endl;
    458533        cerr << "args:" << endl;
    459         for ( int i = 0; args[i] != nullptr; i += 1 ) {
     534        for ( int i = 0; args[i] != NULL; i += 1 ) {
    460535                cerr << " \"" << args[i] << "\"" << endl;
    461536        } // for
    462         cerr << endl;
    463537        #endif // __DEBUG_H__
    464538
    465539        if ( ! quiet ) {
    466540                cerr << "CFA " << "Version " << Version << heading << endl;
     541
    467542                if ( help ) {
    468543                        cerr <<
     
    479554                if ( argc == 2 ) exit( EXIT_SUCCESS );                  // if only the -v flag is specified, do not invoke gcc
    480555
    481                 for ( int i = 0; args[i] != nullptr; i += 1 ) {
     556                for ( int i = 0; args[i] != NULL; i += 1 ) {
    482557                        cerr << args[i] << " ";
    483558                } // for
     
    493568
    494569        execvp( args[0], (char *const *)args );                         // should not return
    495         perror( "CFA Translator error: execvp" );
     570        perror( "CFA Translator error: cfa level, execvp" );
    496571        exit( EXIT_FAILURE );
    497572} // main
  • libcfa/Makefile.in

    r970141d r85142648  
    231231CFACC = @CFACC@
    232232CFACPP = @CFACPP@
    233 CFADIR_HASH = @CFADIR_HASH@
    234233CFA_BINDIR = @CFA_BINDIR@
    235234CFA_INCDIR = @CFA_INCDIR@
     
    275274LIPO = @LIPO@
    276275LN_S = @LN_S@
    277 LOCAL_CC1 = @LOCAL_CC1@
    278 LOCAL_CFACC = @LOCAL_CFACC@
    279276LTLIBOBJS = @LTLIBOBJS@
    280277LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
     
    296293PACKAGE_VERSION = @PACKAGE_VERSION@
    297294PATH_SEPARATOR = @PATH_SEPARATOR@
    298 PRELUDEFLAG = @PRELUDEFLAG@
    299295RANLIB = @RANLIB@
    300296SED = @SED@
  • libcfa/configure

    r970141d r85142648  
    707707CONFIG_CFLAGS
    708708ARCH_FLAGS
    709 PRELUDEFLAG
    710 CFADIR_HASH
    711 LOCAL_CC1
    712 LOCAL_CFACC
    713709CFACPP
    714710CFACC
    715 ENABLE_DISTCC_FALSE
    716 ENABLE_DISTCC_TRUE
    717711CFA_VERSION
    718712DRIVER_DIR
     
    789783enable_option_checking
    790784enable_silent_rules
    791 enable_distcc
    792785with_cfa_name
    793786enable_shared
     
    14521445  --enable-silent-rules   less verbose build output (undo: "make V=1")
    14531446  --disable-silent-rules  verbose build output (undo: "make V=0")
    1454   --enable-distcc     whether or not to enable distributed compilation
    14551447  --enable-shared[=PKGS]  build shared libraries [default=yes]
    14561448  --enable-static[=PKGS]  build static libraries [default=yes]
     
    29492941
    29502942
    2951 # Check whether --enable-distcc was given.
    2952 if test "${enable_distcc+set}" = set; then :
    2953   enableval=$enable_distcc; enable_distcc=$enableval
    2954 else
    2955   enable_distcc=no
    2956 fi
    2957 
    2958 
    2959 echo -n "checking for distributated build... "
    2960 if test x$enable_distcc = xno; then
    2961         CFACC=${DRIVER_DIR}cfa
    2962         PRELUDEFLAG='-in-tree'
    2963         echo "no"
    2964 else
    2965         tools="$(readlink -m $ac_confdir/)/../tools/build"
    2966         config=$(basename $(readlink -f .))
    2967         echo "$tools/distcc_hash $config"
    2968         CFADIR_HASH=$($tools/distcc_hash $config)
    2969         CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa"
    2970         PRELUDEFLAG='-dist-tree'
    2971         echo "yes (hash=${CFADIR_HASH})"
    2972 fi
     2943CFACC=${DRIVER_DIR}cfa
    29732944CFACPP=${DRIVER_DIR}cfa-cpp
    2974 LOCAL_CFACC=${DRIVER_DIR}cfa
    2975 LOCAL_CC1=${DRIVER_DIR}cc1
    2976 
    2977  if test x$enable_distcc = xyes; then
    2978   ENABLE_DISTCC_TRUE=
    2979   ENABLE_DISTCC_FALSE='#'
    2980 else
    2981   ENABLE_DISTCC_TRUE='#'
    2982   ENABLE_DISTCC_FALSE=
    2983 fi
    2984 
    2985 
    2986 
    2987 
    2988 
    2989 
    29902945
    29912946
     
    1702716982fi
    1702816983
    17029 if test -z "${ENABLE_DISTCC_TRUE}" && test -z "${ENABLE_DISTCC_FALSE}"; then
    17030   as_fn_error $? "conditional \"ENABLE_DISTCC\" was never defined.
    17031 Usually this means the macro was only invoked conditionally." "$LINENO" 5
    17032 fi
    1703316984if test -z "${BUILDLIB_TRUE}" && test -z "${BUILDLIB_FALSE}"; then
    1703416985  as_fn_error $? "conditional \"BUILDLIB\" was never defined.
  • libcfa/configure.ac

    r970141d r85142648  
    2727AC_ARG_VAR(CFA_VERSION, [The long version of cfa])
    2828
    29 AC_ARG_ENABLE(distcc,
    30         [  --enable-distcc     whether or not to enable distributed compilation],
    31         enable_distcc=$enableval, enable_distcc=no)
    32 
    33 echo -n "checking for distributated build... "
    34 if test x$enable_distcc = xno; then
    35         CFACC=${DRIVER_DIR}cfa
    36         PRELUDEFLAG='-in-tree'
    37         echo "no"
    38 else
    39         tools="$(readlink -m $ac_confdir/)/../tools/build"
    40         config=$(basename $(readlink -f .))
    41         echo "$tools/distcc_hash $config"
    42         CFADIR_HASH=$($tools/distcc_hash $config)
    43         CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa"
    44         PRELUDEFLAG='-dist-tree'
    45         echo "yes (hash=${CFADIR_HASH})"
    46 fi
     29CFACC=${DRIVER_DIR}cfa
    4730CFACPP=${DRIVER_DIR}cfa-cpp
    48 LOCAL_CFACC=${DRIVER_DIR}cfa
    49 LOCAL_CC1=${DRIVER_DIR}cc1
    50 
    51 AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])
    52 
    5331AC_SUBST(CFACC)
    5432AC_SUBST(CFACPP)
    55 AC_SUBST(LOCAL_CFACC)
    56 AC_SUBST(LOCAL_CC1)
    57 AC_SUBST(CFADIR_HASH)
    5833AC_SUBST(CFA_VERSION)
    59 AC_SUBST(PRELUDEFLAG)
    6034
    6135#==============================================================================
  • libcfa/prelude/Makefile.am

    r970141d r85142648  
    2323cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c
    2424
    25 CC = @LOCAL_CFACC@
     25CC = @CFACC@
    2626AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    2727AM_CFAFLAGS = @CONFIG_CFAFLAGS@
     
    5454
    5555# create forward declarations for cfa builtins
    56 builtins.cf : builtins.c @LOCAL_CFACC@
     56builtins.cf : builtins.c ${CC}
    5757        ${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po -D__cforall
    5858        ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
     
    6868MOSTLYCLEANFILES = bootloader.c builtins.cf extras.cf gcc-builtins.c gcc-builtins.cf prelude.cfa
    6969MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
    70 
    71 if ENABLE_DISTCC
    72 distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c $(srcdir)/../../tools/build/push2dist.sh
    73         ${AM_V_GEN}$(srcdir)/../../tools/build/push2dist.sh @CFADIR_HASH@
    74         @echo "Dummy file to track distribution to remote hosts" > ${@}
    75 
    76 all: all-am distribution
    77 endif ENABLE_DISTCC
  • libcfa/prelude/Makefile.in

    r970141d r85142648  
    167167AUTOMAKE = @AUTOMAKE@
    168168AWK = @AWK@
    169 CC = @LOCAL_CFACC@
     169CC = @CFACC@
    170170CCAS = @CCAS@
    171171CCASDEPMODE = @CCASDEPMODE@
     
    174174CFACC = @CFACC@
    175175CFACPP = @CFACPP@
    176 CFADIR_HASH = @CFADIR_HASH@
    177176CFA_BINDIR = @CFA_BINDIR@
    178177CFA_INCDIR = @CFA_INCDIR@
     
    218217LIPO = @LIPO@
    219218LN_S = @LN_S@
    220 LOCAL_CC1 = @LOCAL_CC1@
    221 LOCAL_CFACC = @LOCAL_CFACC@
    222219LTLIBOBJS = @LTLIBOBJS@
    223220LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
     
    239236PACKAGE_VERSION = @PACKAGE_VERSION@
    240237PATH_SEPARATOR = @PATH_SEPARATOR@
    241 PRELUDEFLAG = @PRELUDEFLAG@
    242238RANLIB = @RANLIB@
    243239SED = @SED@
     
    559555
    560556# create forward declarations for cfa builtins
    561 builtins.cf : builtins.c @LOCAL_CFACC@
     557builtins.cf : builtins.c ${CC}
    562558        ${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po -D__cforall
    563559        ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
     
    570566maintainer-clean-local :
    571567        rm -rf $(DEPDIR)
    572 
    573 @ENABLE_DISTCC_TRUE@distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c $(srcdir)/../../tools/build/push2dist.sh
    574 @ENABLE_DISTCC_TRUE@    ${AM_V_GEN}$(srcdir)/../../tools/build/push2dist.sh @CFADIR_HASH@
    575 @ENABLE_DISTCC_TRUE@    @echo "Dummy file to track distribution to remote hosts" > ${@}
    576 
    577 @ENABLE_DISTCC_TRUE@all: all-am distribution
    578568
    579569# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • libcfa/src/Makefile.am

    r970141d r85142648  
    3232# use -no-include-stdhdr to prevent rebuild cycles
    3333# The built sources must not depend on the installed headers
    34 AM_CFAFLAGS = -quiet -cfalib @PRELUDEFLAG@ -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
     34AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    3535AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
     
    6464# add dependency of cfa files
    6565libobjs = $(addsuffix .lo, $(basename $(filter %.cfa,$(libsrc))))
    66 $(libobjs) : @LOCAL_CFACC@ @CFACPP@ prelude.cfa
     66$(libobjs) : @CFACC@ @CFACPP@ prelude.cfa
    6767
    6868thread_libobjs = $(addsuffix .lo, $(basename $(filter %.cfa,$(thread_libsrc))))
    69 $(thread_libobjs) : @LOCAL_CFACC@ @CFACPP@ prelude.cfa
     69$(thread_libobjs) : @CFACC@ @CFACPP@ prelude.cfa
    7070
    7171
     
    8686
    8787
    88 if ENABLE_DISTCC
     88prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@
     89        ${AM_V_GEN}$(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@}
    8990
    90 ../prelude/distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ ../prelude/gcc-builtins.cf ../prelude/builtins.cf ../prelude/extras.cf ../prelude/prelude.cfa ../prelude/bootloader.c $(srcdir)/../../tools/build/push2dist.sh
    91         @+make -C ../prelude distribution
     91prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@
     92        ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
     93        $(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@}
    9294
    93 prelude.o prelude.lo $(libobjs) $(thread_libobjs) : ../prelude/distribution
    94 
    95 endif ENABLE_DISTCC
    96 
    97 prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    98         ${AM_V_GEN}$(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
    99 
    100 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    101         ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
    102         $(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
    10395
    10496#----------------------------------------------------------------------------------------------------------------
  • libcfa/src/Makefile.in

    r970141d r85142648  
    284284CFACC = @CFACC@
    285285CFACPP = @CFACPP@
    286 CFADIR_HASH = @CFADIR_HASH@
    287286CFA_BINDIR = @CFA_BINDIR@
    288287CFA_INCDIR = @CFA_INCDIR@
     
    328327LIPO = @LIPO@
    329328LN_S = @LN_S@
    330 LOCAL_CC1 = @LOCAL_CC1@
    331 LOCAL_CFACC = @LOCAL_CFACC@
    332329LTLIBOBJS = @LTLIBOBJS@
    333330LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
     
    349346PACKAGE_VERSION = @PACKAGE_VERSION@
    350347PATH_SEPARATOR = @PATH_SEPARATOR@
    351 PRELUDEFLAG = @PRELUDEFLAG@
    352348RANLIB = @RANLIB@
    353349SED = @SED@
     
    445441# use -no-include-stdhdr to prevent rebuild cycles
    446442# The built sources must not depend on the installed headers
    447 AM_CFAFLAGS = -quiet -cfalib @PRELUDEFLAG@ -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
     443AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    448444AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    449445AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
     
    941937        $(LTCFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
    942938        $(am__mv) $$depbase.Tpo $$depbase.Plo
    943 $(libobjs) : @LOCAL_CFACC@ @CFACPP@ prelude.cfa
    944 $(thread_libobjs) : @LOCAL_CFACC@ @CFACPP@ prelude.cfa
     939$(libobjs) : @CFACC@ @CFACPP@ prelude.cfa
     940$(thread_libobjs) : @CFACC@ @CFACPP@ prelude.cfa
    945941
    946942-include $(libdeps)
     
    948944-include $(thread_libdeps)
    949945
    950 @ENABLE_DISTCC_TRUE@../prelude/distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ ../prelude/gcc-builtins.cf ../prelude/builtins.cf ../prelude/extras.cf ../prelude/prelude.cfa ../prelude/bootloader.c $(srcdir)/../../tools/build/push2dist.sh
    951 @ENABLE_DISTCC_TRUE@    @+make -C ../prelude distribution
    952 
    953 @ENABLE_DISTCC_TRUE@prelude.o prelude.lo $(libobjs) $(thread_libobjs) : ../prelude/distribution
    954 
    955 prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    956         ${AM_V_GEN}$(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
    957 
    958 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
     946prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@
     947        ${AM_V_GEN}$(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@}
     948
     949prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@
    959950        ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
    960         $(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
     951        $(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@}
    961952
    962953#----------------------------------------------------------------------------------------------------------------
  • libcfa/src/fstream.cfa

    r970141d r85142648  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 10 22:19:56 2019
    13 // Update Count     : 354
     12// Last Modified On : Mon Jul 15 18:11:26 2019
     13// Update Count     : 349
    1414//
    1515
     
    164164} // fmt
    165165
    166 static ofstream soutFile = { (FILE *)stdout };
     166static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_) };
    167167ofstream & sout = soutFile, & stdout = soutFile;
    168 static ofstream serrFile = { (FILE *)stderr };
     168static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_) };
    169169ofstream & serr = serrFile, & stderr = serrFile;
    170170
    171 static ofstream exitFile = { (FILE *)stdout };
     171static ofstream exitFile = { (FILE *)(&_IO_2_1_stdout_) };
    172172ofstream & exit = exitFile;
    173 static ofstream abortFile = { (FILE *)stderr };
     173static ofstream abortFile = { (FILE *)(&_IO_2_1_stderr_) };
    174174ofstream & abort = abortFile;
    175175
     
    265265} // fmt
    266266
    267 static ifstream sinFile = { (FILE *)stdin };
     267
     268static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) };
    268269ifstream & sin = sinFile, & stdin = sinFile;
    269270
  • longrun_tests/Makefile.in

    r970141d r85142648  
    378378FGREP = @FGREP@
    379379GREP = @GREP@
    380 HAS_DISTCC = @HAS_DISTCC@
    381380HOST_FLAGS = @HOST_FLAGS@
    382381INSTALL = @INSTALL@
  • src/Makefile.in

    r970141d r85142648  
    441441FGREP = @FGREP@
    442442GREP = @GREP@
    443 HAS_DISTCC = @HAS_DISTCC@
    444443HOST_FLAGS = @HOST_FLAGS@
    445444INSTALL = @INSTALL@
  • src/ResolvExpr/Unify.cc

    r970141d r85142648  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:27:10 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Sep  4 10:00:00 2019
    13 // Update Count     : 44
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Mon Jun 18 11:58:00 2018
     13// Update Count     : 43
    1414//
    1515
     
    278278#endif
    279279                        if ( ( common = commonType( type1, type2, widen.first, widen.second, indexer, env, openVars ) ) ) {
    280                                 common->tq = tq1.unify( tq2 );
     280                                common->get_qualifiers() = tq1 | tq2;
    281281#ifdef DEBUG
    282282                                std::cerr << "unifyInexact: common type is ";
     
    295295                                if ( ( tq1 > tq2 || widen.first ) && ( tq2 > tq1 || widen.second ) ) {
    296296                                        common = type1->clone();
    297                                         common->tq = tq1.unify( tq2 );
     297                                        common->get_qualifiers() = tq1 | tq2;
    298298                                        result = true;
    299299                                } else {
     
    302302                        } else {
    303303                                common = type1->clone();
    304                                 common->tq = tq1.unify( tq2 );
     304                                common->get_qualifiers() = tq1 | tq2;
    305305                                result = true;
    306306                        } // if
  • src/SynTree/Expression.cc

    r970141d r85142648  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 15 13:43:00 2019
    13 // Update Count     : 64
     12// Last Modified On : Tue Aug 13 11:31:00 2019
     13// Update Count     : 63
    1414//
    1515
     
    646646                result = new VoidType( Type::Qualifiers() );
    647647        }
    648 }
    649 bool StmtExpr::get_lvalue() const {
    650         return result->get_lvalue();
    651648}
    652649void StmtExpr::print( std::ostream & os, Indenter indent ) const {
  • src/SynTree/Expression.h

    r970141d r85142648  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 15 13:46:00 2019
    13 // Update Count     : 54
     12// Last Modified On : Wed Aug 14 14:24:00 2019
     13// Update Count     : 53
    1414//
    1515
     
    777777        virtual ~StmtExpr();
    778778
    779         bool get_lvalue() const final;
    780 
    781779        CompoundStmt * get_statements() const { return statements; }
    782780        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
  • src/SynTree/Type.h

    r970141d r85142648  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Sep  4 09:58:00 2019
    13 // Update Count     : 170
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Feb 14 17:11:24 2019
     13// Update Count     : 169
    1414//
    1515
     
    131131                bool operator>( Qualifiers other ) const { return *this != other && *this >= other; }
    132132                BFCommon( Qualifiers, NumTypeQualifier )
    133 
    134                 Qualifiers unify( Qualifiers const & other ) const {
    135                         int or_flags = Mask & (val | other.val);
    136                         int and_flags = val & other.val;
    137                         return Qualifiers( or_flags | and_flags );
    138                 }
    139133        }; // Qualifiers
    140134
  • src/main.cc

    r970141d r85142648  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 23 06:50:08 2019
    13 // Update Count     : 607
     12// Last Modified On : Wed Jun  5 20:35:13 2019
     13// Update Count     : 601
    1414//
    1515
     
    9696DeclarationNode * parseTree = nullptr;                                  // program parse tree
    9797
    98 static bool waiting_for_gdb = false;                                    // flag to set cfa-cpp to wait for gdb on start
     98static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start
    9999
    100100static std::string PreludeDirector = "";
    101101
    102 static void parse_cmdline( int argc, char *argv[] );
     102static void parse_cmdline( int argc, char *argv[], const char *& filename );
    103103static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
    104104static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
     
    172172        FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
    173173        ostream * output = & cout;
     174        const char * filename = nullptr;
    174175        list< Declaration * > translationUnit;
    175176
     
    183184        // } // for
    184185
    185         parse_cmdline( argc, argv );                                            // process command-line arguments
     186        parse_cmdline( argc, argv, filename );                          // process command-line arguments
    186187        CodeGen::FixMain::setReplaceMain( !nomainp );
    187188
    188         if ( waiting_for_gdb ) {
     189        if(waiting_for_gdb) {
    189190                std::cerr << "Waiting for gdb" << std::endl;
    190191                std::cerr << "run :" << std::endl;
    191192                std::cerr << "  gdb attach " << getpid() << std::endl;
    192193                raise(SIGSTOP);
    193         } // if
     194        }
    194195
    195196        try {
     
    197198                if ( optind < argc ) {                                                  // any commands after the flags ? => input file name
    198199                        input = fopen( argv[ optind ], "r" );
    199                         assertf( input, "cannot open %s because %s\n", argv[ optind ], strerror( errno ) );
     200                        assertf( input, "cannot open %s\n", argv[ optind ] );
     201                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
     202                        if ( filename == nullptr ) filename = argv[ optind ];
     203                        // prelude filename comes in differently
     204                        if ( libcfap ) filename = "prelude.cfa";
    200205                        optind += 1;
    201206                } else {                                                                                // no input file name
    202207                        input = stdin;
     208                        std::cerr << "Input from stdin" << std::endl;
     209                        // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
     210                        // a fake name along
     211                        if ( filename == nullptr ) filename = "stdin";
    203212                } // if
    204213
     
    438447
    439448
    440 static const char optstring[] = ":hlLmNnpP:S:twW:D:";
     449static const char optstring[] = ":hlLmNnpP:S:tgwW:D:F:";
    441450
    442451enum { PreludeDir = 128 };
     
    457466        { "", no_argument, nullptr, 0 },                                        // -W
    458467        { "", no_argument, nullptr, 0 },                                        // -D
     468        { "", no_argument, nullptr, 0 },                                        // -F
    459469        { nullptr, 0, nullptr, 0 }
    460470}; // long_opts
     
    476486        "",                                                                                                     // -W
    477487        "",                                                                                                     // -D
     488        "",                                                                                                     // -F
    478489}; // description
    479490
     
    510521
    511522static void usage( char *argv[] ) {
    512     cout << "Usage: " << argv[0] << " [options] [input-file (default stdin)] [output-file (default stdout)], where options are:" << endl;
     523    cout << "Usage: " << argv[0] << " options are:" << endl;
    513524        int i = 0, j = 1;                                                                       // j skips starting colon
    514525        for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) {
     
    536547} // usage
    537548
    538 static void parse_cmdline( int argc, char * argv[] ) {
     549static void parse_cmdline( int argc, char * argv[], const char *& filename ) {
    539550        opterr = 0;                                                                                     // (global) prevent getopt from printing error messages
    540551
     
    610621                  case 'D':                                                                             // ignore -Dxxx, forwarded by cpp, hidden
    611622                        break;
     623                  case 'F':                                                                             // source file-name without suffix, hidden
     624                        filename = optarg;
     625                        break;
    612626                  case '?':                                                                             // unknown option
    613627                        if ( optopt ) {                                                         // short option ?
  • tests/Makefile.am

    r970141d r85142648  
    3535
    3636# applies to both programs
    37 # since automake doesn't have support for CFA we have to
    3837AM_CFLAGS = $(if $(test), 2> $(test), ) \
    3938        -g \
     
    4342        -DIN_DIR="${abs_srcdir}/.in/"
    4443
    45 # adjust CC to current flags
    46 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) -dist-tree -in-tree,@CFACC@ ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS})
    47 CFACC = $(CC)
    48 
    49 # get local binary for depedencies
    50 CFACCBIN = @CFACC@
    51 
    52 # adjusted CC but without the actual distcc call
    53 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) -dist-tree -in-tree,@CFACC@ ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS})
     44AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
     45CC = @CFACC@
    5446
    5547PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
     
    6557#----------------------------------------------------------------------------------------------------------------
    6658all-local :
    67         @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
     59        @+${TEST_PY} --debug=${debug}  --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
    6860
    6961all-tests :
    70         @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
     62        @+${TEST_PY} --debug=${debug}  --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
    7163
    7264clean-local :
     
    9587
    9688# Use for all tests, make sure the path are correct and all flags are added
    97 CFACOMPILETEST=$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGSCFA" | sed 's/-\|\//_/g'))
     89CFACOMPILETEST=$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g'))
     90
     91# Use for tests that either generate an executable, print directyl to stdout or the make command is expected to fail
     92CFATEST_STDOUT=$(CFACOMPILETEST) -o $(abspath ${@})
     93
     94# Use for tests where the make command is expecte to succeed but the expected.txt should be compared to stderr
     95CFATEST_STDERR=$(CFACOMPILETEST) 2> $(abspath ${@})
    9896
    9997#----------------------------------------------------------------------------------------------------------------
    10098
    10199# implicit rule so not all test require a rule
    102 # split into two steps to support compiling remotely using distcc
    103 # don't use distcc to do the linking because distcc doesn't do linking
    104 % : %.cfa $(CFACCBIN)
    105         $(CFACOMPILETEST) -c -o $(abspath ${@}).o
    106         $(CFACCLOCAL) $($(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) $(abspath ${@}).o -o $(abspath ${@})
     100% : %.cfa $(CFACC)
     101        $(CFATEST_STDOUT)
    107102
    108 # implicit rule for c++ test
    109 # convient for testing the testsuite itself but not actuall used
    110103% : %.cpp
    111104        $(PRETTY_PATH) $(CXXCOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    112105
    113106#------------------------------------------------------------------------------
    114 # TARGETS WITH CUSTOM FLAGS
     107# TARGET WITH STANDARD RULE BUT CUSTOM FLAGS
    115108#------------------------------------------------------------------------------
    116 # custom libs
    117 gmp_FLAGSLD= -lgmp
     109# Expected failures
     110declarationSpecifier_FLAGS= -CFA -XCFA -p
     111gccExtensions_FLAGS= -CFA -XCFA -p
     112extension_FLAGS= -CFA -XCFA -p
     113attributes_FLAGS= -CFA -XCFA -p
     114functions_FLAGS= -CFA -XCFA -p
     115KRfunctions_FLAGS= -CFA -XCFA -p
     116gmp_FLAGS= -lgmp
    118117
    119118#------------------------------------------------------------------------------
    120 # Generated code
    121 GENERATED_CODE = declarationSpecifier gccExtensions extension attributes functions KRfunctions
    122 $(GENERATED_CODE): % : %.cfa $(CFACCBIN)
    123         $(CFACOMPILETEST) -CFA -XCFA -p -c -fsyntax-only -o $(abspath ${@})
    124 
    125 # Use for tests where the make command is expected to succeed but the expected.txt should be compared to stderr
    126 EXPECT_STDERR = builtins/sync warnings/self-assignment
    127 $(EXPECT_STDERR): % : %.cfa $(CFACCBIN)
    128         $(CFACOMPILETEST) -c -fsyntax-only 2> $(abspath ${@})
     119# Expected failures
     120completeTypeError_FLAGS= -DERR1
    129121
    130122#------------------------------------------------------------------------------
    131123# CUSTOM TARGET
    132124#------------------------------------------------------------------------------
    133 # expected failures
    134 # use custom target since they require a custom define and custom dependencies
    135 alloc-ERROR : alloc.cfa $(CFACCBIN)
    136         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     125typedefRedef-ERR1: typedefRedef.cfa $(CFACC)
     126        $(CFATEST_STDOUT) -DERR1
    137127
    138 typedefRedef-ERR1 : typedefRedef.cfa $(CFACCBIN)
    139         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     128alloc-ERROR: alloc.cfa $(CFACC)
     129        $(CFATEST_STDOUT) -DERR1
    140130
    141 nested-types-ERR1 : nested-types.cfa $(CFACCBIN)
    142         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     131nested-types-ERR1: nested-types.cfa $(CFACC)
     132        $(CFATEST_STDOUT) -DERR1
    143133
    144 nested-types-ERR2 : nested-types.cfa $(CFACCBIN)
    145         $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})
     134nested-types-ERR2: nested-types.cfa $(CFACC)
     135        $(CFATEST_STDOUT) -DERR2
    146136
    147 raii/memberCtors-ERR1 : raii/memberCtors.cfa $(CFACCBIN)
    148         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     137raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC)
     138        $(CFATEST_STDOUT) -DERR1
    149139
    150 raii/ctor-autogen-ERR1 : raii/ctor-autogen.cfa $(CFACCBIN)
    151         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     140raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC)
     141        $(CFATEST_STDOUT) -DERR2
    152142
    153 raii/dtor-early-exit-ERR1 : raii/dtor-early-exit.cfa $(CFACCBIN)
    154         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     143raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC)
     144        $(CFATEST_STDOUT) -DERR1
    155145
    156 raii/dtor-early-exit-ERR2 : raii/dtor-early-exit.cfa $(CFACCBIN)
    157         $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})
     146raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC)
     147        $(CFATEST_STDOUT) -DERR1
    158148
    159 #------------------------------------------------------------------------------
    160 # Other targets
     149#builtins
     150builtins/sync: builtins/sync.cfa $(CFACC)
     151        $(CFATEST_STDERR) -fsyntax-only
     152
     153# Warnings
     154warnings/self-assignment: warnings/self-assignment.cfa $(CFACC)
     155        $(CFATEST_STDERR) -fsyntax-only
  • tests/Makefile.in

    r970141d r85142648  
    212212AWK = @AWK@
    213213BUILD_IN_TREE_FLAGS = @BUILD_IN_TREE_FLAGS@
    214 
    215 # adjust CC to current flags
    216 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) -dist-tree -in-tree,@CFACC@ ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS})
     214CC = @CFACC@
    217215CCAS = @CCAS@
    218216CCASDEPMODE = @CCASDEPMODE@
    219217CCASFLAGS = @CCASFLAGS@
    220218CCDEPMODE = @CCDEPMODE@
    221 CFACC = $(CC)
     219CFACC = @CFACC@
    222220CFACPP = @CFACPP@
    223221CFA_BACKEND_CC = @CFA_BACKEND_CC@
     
    250248FGREP = @FGREP@
    251249GREP = @GREP@
    252 HAS_DISTCC = @HAS_DISTCC@
    253250HOST_FLAGS = @HOST_FLAGS@
    254251INSTALL = @INSTALL@
     
    389386
    390387# applies to both programs
    391 # since automake doesn't have support for CFA we have to
    392 AM_CFLAGS = $(if $(test), 2> $(test), ) \
    393         -g \
    394         -Wall \
    395         -Wno-unused-function \
    396         -quiet @CFA_FLAGS@ \
    397         -DIN_DIR="${abs_srcdir}/.in/"
    398 
    399 
    400 # get local binary for depedencies
    401 CFACCBIN = @CFACC@
    402 
    403 # adjusted CC but without the actual distcc call
    404 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) -dist-tree -in-tree,@CFACC@ ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS})
     388AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \
     389        -quiet @CFA_FLAGS@ -DIN_DIR="${abs_srcdir}/.in/" \
     390        ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
    405391PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
    406392avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa
     
    411397
    412398# Use for all tests, make sure the path are correct and all flags are added
    413 CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGSCFA" | sed 's/-\|\//_/g'))
     399CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g'))
     400
     401# Use for tests that either generate an executable, print directyl to stdout or the make command is expected to fail
     402CFATEST_STDOUT = $(CFACOMPILETEST) -o $(abspath ${@})
     403
     404# Use for tests where the make command is expecte to succeed but the expected.txt should be compared to stderr
     405CFATEST_STDERR = $(CFACOMPILETEST) 2> $(abspath ${@})
    414406
    415407#------------------------------------------------------------------------------
    416 # TARGETS WITH CUSTOM FLAGS
     408# TARGET WITH STANDARD RULE BUT CUSTOM FLAGS
    417409#------------------------------------------------------------------------------
    418 # custom libs
    419 gmp_FLAGSLD = -lgmp
     410# Expected failures
     411declarationSpecifier_FLAGS = -CFA -XCFA -p
     412gccExtensions_FLAGS = -CFA -XCFA -p
     413extension_FLAGS = -CFA -XCFA -p
     414attributes_FLAGS = -CFA -XCFA -p
     415functions_FLAGS = -CFA -XCFA -p
     416KRfunctions_FLAGS = -CFA -XCFA -p
     417gmp_FLAGS = -lgmp
    420418
    421419#------------------------------------------------------------------------------
    422 # Generated code
    423 GENERATED_CODE = declarationSpecifier gccExtensions extension attributes functions KRfunctions
    424 
    425 # Use for tests where the make command is expected to succeed but the expected.txt should be compared to stderr
    426 EXPECT_STDERR = builtins/sync warnings/self-assignment
     420# Expected failures
     421completeTypeError_FLAGS = -DERR1
    427422all: all-am
    428423
     
    776771#----------------------------------------------------------------------------------------------------------------
    777772all-local :
    778         @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
     773        @+${TEST_PY} --debug=${debug}  --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
    779774
    780775all-tests :
    781         @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
     776        @+${TEST_PY} --debug=${debug}  --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
    782777
    783778clean-local :
     
    806801
    807802# implicit rule so not all test require a rule
    808 # split into two steps to support compiling remotely using distcc
    809 # don't use distcc to do the linking because distcc doesn't do linking
    810 % : %.cfa $(CFACCBIN)
    811         $(CFACOMPILETEST) -c -o $(abspath ${@}).o
    812         $(CFACCLOCAL) $($(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) $(abspath ${@}).o -o $(abspath ${@})
    813 
    814 # implicit rule for c++ test
    815 # convient for testing the testsuite itself but not actuall used
     803% : %.cfa $(CFACC)
     804        $(CFATEST_STDOUT)
     805
    816806% : %.cpp
    817807        $(PRETTY_PATH) $(CXXCOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    818 $(GENERATED_CODE): % : %.cfa $(CFACCBIN)
    819         $(CFACOMPILETEST) -CFA -XCFA -p -c -fsyntax-only -o $(abspath ${@})
    820 $(EXPECT_STDERR): % : %.cfa $(CFACCBIN)
    821         $(CFACOMPILETEST) -c -fsyntax-only 2> $(abspath ${@})
    822808
    823809#------------------------------------------------------------------------------
    824810# CUSTOM TARGET
    825811#------------------------------------------------------------------------------
    826 # expected failures
    827 # use custom target since they require a custom define and custom dependencies
    828 alloc-ERROR : alloc.cfa $(CFACCBIN)
    829         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
    830 
    831 typedefRedef-ERR1 : typedefRedef.cfa $(CFACCBIN)
    832         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
    833 
    834 nested-types-ERR1 : nested-types.cfa $(CFACCBIN)
    835         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
    836 
    837 nested-types-ERR2 : nested-types.cfa $(CFACCBIN)
    838         $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})
    839 
    840 raii/memberCtors-ERR1 : raii/memberCtors.cfa $(CFACCBIN)
    841         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
    842 
    843 raii/ctor-autogen-ERR1 : raii/ctor-autogen.cfa $(CFACCBIN)
    844         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
    845 
    846 raii/dtor-early-exit-ERR1 : raii/dtor-early-exit.cfa $(CFACCBIN)
    847         $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
    848 
    849 raii/dtor-early-exit-ERR2 : raii/dtor-early-exit.cfa $(CFACCBIN)
    850         $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})
    851 
    852 #------------------------------------------------------------------------------
    853 # Other targets
     812typedefRedef-ERR1: typedefRedef.cfa $(CFACC)
     813        $(CFATEST_STDOUT) -DERR1
     814
     815alloc-ERROR: alloc.cfa $(CFACC)
     816        $(CFATEST_STDOUT) -DERR1
     817
     818nested-types-ERR1: nested-types.cfa $(CFACC)
     819        $(CFATEST_STDOUT) -DERR1
     820
     821nested-types-ERR2: nested-types.cfa $(CFACC)
     822        $(CFATEST_STDOUT) -DERR2
     823
     824raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC)
     825        $(CFATEST_STDOUT) -DERR1
     826
     827raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC)
     828        $(CFATEST_STDOUT) -DERR2
     829
     830raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC)
     831        $(CFATEST_STDOUT) -DERR1
     832
     833raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC)
     834        $(CFATEST_STDOUT) -DERR1
     835
     836#builtins
     837builtins/sync: builtins/sync.cfa $(CFACC)
     838        $(CFATEST_STDERR) -fsyntax-only
     839
     840# Warnings
     841warnings/self-assignment: warnings/self-assignment.cfa $(CFACC)
     842        $(CFATEST_STDERR) -fsyntax-only
    854843
    855844# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • tests/config.py.in

    r970141d r85142648  
    88BUILDDIR = "@abs_builddir@"
    99HOSTARCH = "@host_cpu@"
    10 DISTRIBUTE = @HAS_DISTCC@
  • tests/pybin/settings.py

    r970141d r85142648  
    1414        SRCDIR = os.path.abspath(config.SRCDIR)
    1515        BUILDDIR = os.path.abspath(config.BUILDDIR)
    16         distribute = config.DISTRIBUTE
    1716        os.chdir(testpath)
    1817
     
    8988                self.string = "debug" if value else "no debug"
    9089                self.flags  = """DEBUG_FLAGS=%s""" % ("-debug -O0" if value else "-nodebug -O2")
    91                 self.path   = "debug" if value else "nodebug"
    9290
    9391class Install:
    9492        def __init__(self, value):
    95                 if value:
    96                         distribute = False
    97 
    9893                self.string = "installed" if value else "in-tree"
    9994                self.flags  = """INSTALL_FLAGS=%s""" % ("" if value else "-in-tree")
     
    114109def init( options ):
    115110        global arch
    116         global archive
    117         global debug
    118         global distcc
    119111        global dry_run
    120112        global generating
     113        global make
     114        global debug
    121115        global install
    122         global make
     116        global timeout
    123117        global output_width
    124         global timeout
     118        global archive
    125119
     120        dry_run      = options.dry_run
     121        generating   = options.regenerate_expected
     122        make         = ['make']
     123        debug        = Debug(options.debug)
     124        install      = Install(options.install)
    126125        arch         = Architecture(options.arch)
     126        timeout      = Timeouts(options.timeout, options.global_timeout)
     127        output_width = 24
    127128        archive      = os.path.abspath(os.path.join(original_path, options.archive_errors)) if options.archive_errors else None
    128         debug        = Debug(options.debug)
    129         dry_run      = options.dry_run # must be called before tools.config_hash()
    130         distcc       = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash()
    131         generating   = options.regenerate_expected
    132         install      = Install(options.install)
    133         make         = ['make']
    134         output_width = 24
    135         timeout      = Timeouts(options.timeout, options.global_timeout)
    136129
    137         # if we distribute, distcc errors will fail tests, use log file for distcc
    138         # don't use "'DISTCC_LOG' not in os.environ" because it can be set to ''
    139         if distribute and not os.environ.get('DISTCC_LOG'):
    140                 os.putenv('DISTCC_LOG', os.path.join(BUILDDIR, 'distcc_error.log'))
    141130
    142131def update_make_cmd(force, jobs):
     
    147136def validate():
    148137        errf = os.path.join(BUILDDIR, ".validate.err")
    149         make_ret, out = tools.make( ".validate", error_file = errf, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL )
     138        make_ret, out = tools.make( ".validate", error_file = errf, output=subprocess.DEVNULL, error=subprocess.DEVNULL )
    150139        if make_ret != 0:
    151140                with open (errf, "r") as myfile:
  • tests/pybin/tools.py

    r970141d r85142648  
    2323
    2424# helper functions to run terminal commands
    25 def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False):
     25def sh(*cmd, timeout = False, output = None, input = None, error = subprocess.STDOUT):
    2626        cmd = list(cmd)
    2727
    28         if input_file and input_text:
    29                 return 401, "Cannot use both text and file inputs"
    30 
    3128        # if this is a dry_run, only print the commands that would be ran
    32         if settings.dry_run and not ignore_dry_run:
     29        if settings.dry_run :
    3330                cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd))
    34                 if output_file and not isinstance(output_file, int):
     31                if output and not isinstance(output, int):
    3532                        cmd += " > "
    36                         cmd += output_file
     33                        cmd += output
    3734
    3835                if error and not isinstance(error, int):
     
    4037                        cmd += error
    4138
    42                 if input_file and not isinstance(input_file, int) and os.path.isfile(input_file):
     39                if input and not isinstance(input, int) and os.path.isfile(input):
    4340                        cmd += " < "
    44                         cmd += input_file
     41                        cmd += input
    4542
    4643                print(cmd)
     
    4946        with contextlib.ExitStack() as onexit:
    5047                # add input redirection if needed
    51                 input_file = openfd(input_file, 'r', onexit, True)
     48                input = openfd(input, 'r', onexit, True)
    5249
    5350                # add output redirection if needed
    54                 output_file = openfd(output_file, 'w', onexit, False)
     51                output = openfd(output, 'w', onexit, False)
    5552
    5653                # add error redirection if needed
     
    6158                        proc = subprocess.run(
    6259                                cmd,
    63                                 **({'input' : bytes(input_text, encoding='utf-8')} if input_text else {'stdin' : input_file}),
    64                                 stdout  = output_file,
    65                                 stderr  = error,
    66                                 timeout = settings.timeout.single if timeout else None
     60                                stdin =input,
     61                                stdout=output,
     62                                stderr=error,
     63                                timeout=settings.timeout.single if timeout else None
    6764                        )
    68 
    6965                        return proc.returncode, proc.stdout.decode("utf-8") if proc.stdout else None
    7066                except subprocess.TimeoutExpired:
     
    7975                return False
    8076
    81         code, out = sh("file %s" % fname, output_file=subprocess.PIPE)
     77        code, out = sh("file %s" % fname, output=subprocess.PIPE)
    8278        if code != 0:
    8379                return False
     
    111107        if isinstance(files, str ): files = [ files ]
    112108        for file in files:
    113                 sh( 'rm', '-f', file, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL )
     109                sh( 'rm', '-f', file, output=subprocess.DEVNULL, error=subprocess.DEVNULL )
    114110
    115111# Create 1 or more directory
     
    119115                p = os.path.normpath( file )
    120116                d = os.path.dirname ( p )
    121                 sh( 'mkdir', '-p', d, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL )
     117                sh( 'mkdir', '-p', d, output=subprocess.DEVNULL, error=subprocess.DEVNULL )
    122118
    123119
     
    142138                lhs,
    143139                rhs,
    144                 output_file=subprocess.PIPE
     140                output=subprocess.PIPE
    145141        )
    146142
    147143# call make
    148 def make(target, *, flags = '', output_file = None, error = None, error_file = None, silent = False):
     144def make(target, *, flags = '', output = None, error = None, error_file = None, silent = False):
    149145        test_param = """test="%s" """ % (error_file) if error_file else None
    150146        cmd = [
     
    155151                settings.debug.flags,
    156152                settings.install.flags,
    157                 settings.distcc if settings.distribute else None,
    158153                flags,
    159154                target
    160155        ]
    161156        cmd = [s for s in cmd if s]
    162         return sh(*cmd, output_file=output_file, error=error)
     157        return sh(*cmd, output=output, error=error)
    163158
    164159def which(program):
     
    206201# cat one file into the other
    207202def cat(source, dest):
    208         ret, _ = sh("cat", source, output_file=dest)
     203        ret, _ = sh("cat", source, output=dest)
    209204        return ret
    210205
     
    261256                        os.write(int(make_jobs_fds.group(3)), tokens)
    262257                else :
    263                         if settings.distribute:
    264                                 ret, jstr = sh("distcc", "-j", output_file=subprocess.PIPE, ignore_dry_run=True)
    265                                 if ret == 0:
    266                                         options.jobs = int(jstr.strip())
    267                                 else :
    268                                         options.jobs = multiprocessing.cpu_count()
    269                         else:
    270                                 options.jobs = multiprocessing.cpu_count()
     258                        options.jobs = multiprocessing.cpu_count()
    271259        else :
    272260                force = True
     
    286274################################################################################
    287275
    288 # get hash for given configuration
    289 def config_hash():
    290         path = os.path.normpath(os.path.join(
    291                 settings.SRCDIR,
    292         ))
    293 
    294         distcc_hash = os.path.join(settings.SRCDIR, '../tools/build/distcc_hash')
    295         config = "%s-%s" % (settings.arch.target, settings.debug.path)
    296         _, out = sh(distcc_hash, config, output_file=subprocess.PIPE, ignore_dry_run=True)
    297         return out.strip()
    298 
    299 # get pretty string for time of day
    300276def pretty_now():
    301277        ts = time.time()
     
    332308                return 1, "ERR No core dump"
    333309
    334         return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output_file=subprocess.PIPE)
     310        return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output=subprocess.PIPE)
    335311
    336312def core_archive(dst, name, exe):
  • tests/test.py

    r970141d r85142648  
    143143        # build, skipping to next test on error
    144144        with Timed() as comp_dur:
    145                 make_ret, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file )
     145                make_ret, _ = make( test.target(), output=subprocess.DEVNULL, error=out_file, error_file = err_file )
    146146
    147147        run_dur = None
     
    153153                                if settings.dry_run or is_exe(exe_file):
    154154                                        # run test
    155                                         retcode, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True)
     155                                        retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True)
    156156                                else :
    157157                                        # simply cat the result into the output
     
    219219def run_tests(tests, jobs) :
    220220        # clean the sandbox from previous commands
    221         make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
     221        make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL)
    222222
    223223        # create the executor for our jobs and handle the signal properly
     
    260260
    261261        # clean the workspace
    262         make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
     262        make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL)
    263263
    264264        return 1 if failed else 0
  • tools/Makefile.in

    r970141d r85142648  
    238238FGREP = @FGREP@
    239239GREP = @GREP@
    240 HAS_DISTCC = @HAS_DISTCC@
    241240HOST_FLAGS = @HOST_FLAGS@
    242241INSTALL = @INSTALL@
  • tools/prettyprinter/Makefile.in

    r970141d r85142648  
    267267FGREP = @FGREP@
    268268GREP = @GREP@
    269 HAS_DISTCC = @HAS_DISTCC@
    270269HOST_FLAGS = @HOST_FLAGS@
    271270INSTALL = @INSTALL@
Note: See TracChangeset for help on using the changeset viewer.