[51b73452] | 1 | cfa-cc: The Cforall->C Compiler System
|
---|
| 2 | ======================================
|
---|
| 3 |
|
---|
| 4 | This is a PRE-RELEASE version of cfa-cc. It exists solely for the
|
---|
| 5 | purpose of private experimentation and scholarly research. The authors
|
---|
| 6 | disclaim all responsibility for the consequences of any malfunction of
|
---|
| 7 | the software, including the malfunction of any programs compiled using
|
---|
| 8 | the software.
|
---|
| 9 |
|
---|
| 10 | What is Cforall?
|
---|
| 11 | ----------------
|
---|
| 12 | Cforall is a language design extending ISO C. The purpose of the
|
---|
| 13 | project is to engineer modern language features into C in an
|
---|
| 14 | evolutionary rather than revolutionary way. Java is an example of the
|
---|
| 15 | revolutionary approach of modernizing C/C++, resulting in a new
|
---|
| 16 | language rather than an extension of its descendents. C++, Fortran 95
|
---|
| 17 | and Cobol 9X are examples of the evolutionary approach where modern
|
---|
| 18 | language features are added and problems fixed within the framework of
|
---|
| 19 | an existing language.
|
---|
| 20 |
|
---|
| 21 | The goal of this project is to produce a largely backwards compatible
|
---|
| 22 | version of C containing many modern language features and fixing some
|
---|
| 23 | of the well known C problems. Without continued development of the
|
---|
| 24 | language, C will be unable to cope with the needs of modern programming
|
---|
| 25 | problems and programmers; as a result, it will fade into disuse.
|
---|
| 26 | Considering the large body of existing C code and programmers, there is
|
---|
| 27 | a significant impetus to ensure C is transformed into a modern
|
---|
| 28 | programming language.
|
---|
| 29 |
|
---|
| 30 | What is cfa-cc?
|
---|
| 31 | ---------------
|
---|
| 32 | cfa-cc is a collection of programs centred around a translator that
|
---|
| 33 | takes Cforall code as input and outputs corresponding C code. This
|
---|
| 34 | is complemented by a compiler driver in the style of "gcc", which
|
---|
| 35 | handles preprocessing, compiling, assembling, and linking and invokes
|
---|
| 36 | the translator at appropriate moments.
|
---|
| 37 |
|
---|
| 38 | What is required in order to use cfa-cc?
|
---|
| 39 | ----------------------------------------
|
---|
| 40 | Building cfa-cc requires GNU Make and gcc/g++ 3. cfa-cc is written in
|
---|
| 41 | C++.
|
---|
| 42 |
|
---|
| 43 | The compiler driver uses an installed version of gcc to handle all
|
---|
| 44 | aspects of the compilation process except for the Cforall->C translation.
|
---|
| 45 | Currently, only gcc 3.2 is supported.
|
---|
| 46 |
|
---|
| 47 | How is cfa-cc used?
|
---|
| 48 | -------------------
|
---|
| 49 | The compiler driver "cfa" accepts all of the arguments of gcc, and is
|
---|
| 50 | used in the same way. For example:
|
---|
| 51 |
|
---|
| 52 | cfa -c test.c
|
---|
| 53 | cfa test.o
|
---|
| 54 |
|
---|
| 55 | Cforall source files must end with '.c' in order to be compiled by the
|
---|
| 56 | compiler driver. In addition, the flag "-CFA" causes cfa to invoke the
|
---|
| 57 | preprocessor and translator and send the translator output to standard
|
---|
| 58 | output.
|
---|
| 59 |
|
---|
| 60 | In cases where the compiler driver is not useful (i.e., where gcc 3.2
|
---|
| 61 | is not available), it is still possible to invoke the translator
|
---|
| 62 | directly. The translator is installed by default as
|
---|
| 63 | /usr/local/lib/cfa-cpp. A typical invocation is:
|
---|
| 64 |
|
---|
| 65 | /usr/local/lib/cfa-cpp -cp infile outfile
|
---|
| 66 |
|
---|
| 67 | If outfile is omitted, output goes to standard output; if infile is
|
---|
| 68 | also omitted, input comes from standard input. Options to the
|
---|
| 69 | translator other than "-cp" will not produce valid C code and are only
|
---|
| 70 | useful for debugging the translator.
|
---|
| 71 |
|
---|
| 72 | How can C code be used with cfa-cc?
|
---|
| 73 | -----------------------------------
|
---|
| 74 | cfa-cc should be able to compile most ANSI C programs. It is also
|
---|
| 75 | possible to link against C libraries in most cases. Since Cforall
|
---|
| 76 | supports overloading, however, names used in Cforall code are
|
---|
| 77 | mangled in the output C code. This will cause linker failures when
|
---|
| 78 | the names refer to functions and objects in code compiled with
|
---|
| 79 | a standard C compiler. For this reason, it is necessary to enclose
|
---|
| 80 | the declarations of these functions and objects in extern "C" {}
|
---|
| 81 | blocks. For example:
|
---|
| 82 |
|
---|
| 83 | extern "C" {
|
---|
| 84 | #include <stdio.h>
|
---|
| 85 | #include <stdlib.h>
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | The extern "C" turns off name mangling for functions and objects declared
|
---|
| 89 | within the block. As a result, it is not possible to overload their
|
---|
| 90 | names.
|
---|
| 91 |
|
---|
| 92 | It is our intention to have a transparent solution to this problem
|
---|
| 93 | in place for our first official release.
|
---|
| 94 |
|
---|
| 95 | What's wrong with cfa-cc?
|
---|
| 96 | -------------------------
|
---|
| 97 | The authors consider this software to be in an unstable state. It is
|
---|
| 98 | quite likely that there are many reasonable programs that will fail
|
---|
| 99 | to compile. We encourage users to report their experiences to
|
---|
| 100 | cforall@plg.uwaterloo.ca, but we make no promises regarding support.
|
---|
| 101 |
|
---|
| 102 | We have fixed most of the problems that we are aware of. There are
|
---|
| 103 | some exceptions:
|
---|
| 104 |
|
---|
| 105 | - initializers are poorly implemented; in particular,
|
---|
| 106 | file-scope initializers may result in the generation of invalid
|
---|
| 107 | C code
|
---|
| 108 |
|
---|
| 109 | - the ISO C99 designated initialization syntax '[n] = m' or
|
---|
| 110 | '.n = m' is not supported; use a colon in place of the equal sign
|
---|
| 111 |
|
---|
| 112 | - some legitimate programs will produce warnings from the C
|
---|
| 113 | compiler; these are harmless (in particular, the creation of
|
---|
| 114 | libcfa.a in the build process should cause four warnings from
|
---|
| 115 | gcc)
|
---|
| 116 |
|
---|
| 117 | - abstract types introduced using the keyword 'type' are not
|
---|
| 118 | implemented (although 'type' can be used to introduce type
|
---|
| 119 | parameters)
|
---|
| 120 |
|
---|
| 121 | - the implicit coercion of structure types to the type of their
|
---|
| 122 | first member is not implemented
|
---|
| 123 |
|
---|
| 124 | Who is responsible for cfa-cc?
|
---|
| 125 | ------------------------------
|
---|
| 126 | cfa-cc was written by Peter Buhr, Richard Bilson, and Rodolfo Esteves.
|
---|
| 127 | Questions and comments can be sent to cforall@plg.uwaterloo.ca.
|
---|
| 128 |
|
---|
| 129 | The Cforall project maintains a web page:
|
---|
| 130 |
|
---|
| 131 | http://plg.uwaterloo.ca/~cforall
|
---|