cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

README.md (4666B)


      1 (mirrored on [GitHub][GitHub mirror])
      2 
      3 [![builds.sr.ht status](https://builds.sr.ht/~mcf/cproc.svg)](https://builds.sr.ht/~mcf/cproc)
      4 
      5 `cproc` is a [C11] compiler using [QBE] as a backend. It is released
      6 under the [ISC] license.
      7 
      8 Several GNU C [extensions] are also implemented.
      9 
     10 There is still much to do, but it currently implements most of the
     11 language and is capable of [building software] including itself, mcpp,
     12 gcc 4.7, binutils, and more.
     13 
     14 It was inspired by several other small C compilers including [8cc],
     15 [c], [lacc], and [scc].
     16 
     17 ## Requirements
     18 
     19 The compiler itself is written in standard C11 and can be built with
     20 any conforming C11 compiler.
     21 
     22 The POSIX driver depends on POSIX.1-2008 interfaces, and the `Makefile`
     23 requires a POSIX-compatible make(1).
     24 
     25 At runtime, you will need QBE, an assembler, and a linker for the
     26 target system. Currently, my personal [QBE branch] is recommended, since
     27 it may address some issues that have not yet made it upstream. Since
     28 the preprocessor is not yet implemented, an external one is currently
     29 required as well.
     30 
     31 ## Supported targets
     32 
     33 All architectures supported by QBE should work (currently x86\_64 and
     34 aarch64).
     35 
     36 The following targets are tested by the continuous build and known to
     37 bootstrap and pass all tests:
     38 
     39 - `x86_64-linux-musl`
     40 - `x86_64-linux-gnu`
     41 - `x86_64-freebsd`
     42 - `aarch64-linux-musl`
     43 - `aarch64-linux-gnu`
     44 
     45 ## Building
     46 
     47 Run `./configure` to create a `config.h` and `config.mk` appropriate for
     48 your system. If your system is not supported by the configure script,
     49 you can create these files manually. `config.h` should define several
     50 string arrays (`static char *[]`):
     51 
     52 - **`startfiles`**: Objects to pass to the linker at the beginning of
     53   the link command.
     54 - **`endfiles`**: Objects to pass to the linker at the end of the link
     55   command (including libc).
     56 - **`preprocesscmd`**: The preprocessor command, and any necessary flags
     57   for the target system.
     58 - **`codegencmd`**: The QBE command, and possibly explicit target flags.
     59 - **`assemblecmd`**: The assembler command.
     60 - **`linkcmd`**: The linker command.
     61 
     62 You may also want to customize your environment or `config.mk` with the
     63 appropriate `CC`, `CFLAGS` and `LDFLAGS`.
     64 
     65 If you don't have QBE installed, you can build it from the included
     66 submodule (NOTE: BSD users will need to use gmake here), then add it to
     67 your PATH so that the driver will be able to run it.
     68 
     69 	make qbe
     70 	PATH=$PWD/qbe/obj:$PATH
     71 
     72 Once this is done, you can build with
     73 
     74 	make
     75 
     76 ### Bootstrap
     77 
     78 The `Makefile` includes several other targets that can be used for
     79 bootstrapping. These targets require the ability to run the tools
     80 specified in `config.h`.
     81 
     82 - **`stage2`**: Build the compiler with the initial (`stage1`) output.
     83 - **`stage3`**: Build the compiler with the `stage2` output.
     84 - **`bootstrap`**: Build the `stage2` and `stage3` compilers, and verify
     85   that they are byte-wise identical.
     86 
     87 ## What's missing
     88 
     89 - Digraph and trigraph sequences ([6.4.6p3] and [5.2.1.1], will not
     90   be implemented).
     91 - Wide string literals ([#35]).
     92 - Variable-length arrays ([#1]).
     93 - `volatile`-qualified types ([#7]).
     94 - `_Thread_local` storage-class specifier ([#5]).
     95 - `long double` type ([#3]).
     96 - Inline assembly ([#5]).
     97 - Preprocessor ([#6]).
     98 - Generation of position independent code (i.e. shared libraries,
     99   modules, PIEs).
    100 
    101 ## Mailing list
    102 
    103 There is a mailing list at [~mcf/cproc@lists.sr.ht]. Feel free to
    104 use it for general discussion, questions, patches, or bug reports
    105 (if you don't have an sr.ht account).
    106 
    107 ## Issue tracker
    108 
    109 Please report any issues to https://todo.sr.ht/~mcf/cproc.
    110 
    111 ## Contributing
    112 
    113 Patches are greatly appreciated. Send them to the mailing list
    114 (preferred), or as pull-requests on the [GitHub mirror].
    115 
    116 [QBE]: https://c9x.me/compile/
    117 [C11]: http://port70.net/~nsz/c/c11/n1570.html
    118 [ISC]: https://git.sr.ht/~mcf/cproc/blob/master/LICENSE
    119 [extensions]: https://man.sr.ht/~mcf/cproc/doc/extensions.md
    120 [building software]: https://man.sr.ht/~mcf/cproc/doc/software.md
    121 [8cc]: https://github.com/rui314/8cc
    122 [c]: https://github.com/andrewchambers/c
    123 [lacc]: https://github.com/larmel/lacc
    124 [scc]: http://www.simple-cc.org/
    125 [QBE branch]: https://git.sr.ht/~mcf/qbe
    126 [5.2.1.1]: http://port70.net/~nsz/c/c11/n1570.html#5.2.1.1
    127 [6.4.6p3]: http://port70.net/~nsz/c/c11/n1570.html#6.4.6p3
    128 [#1]: https://todo.sr.ht/~mcf/cproc/1
    129 [#3]: https://todo.sr.ht/~mcf/cproc/3
    130 [#5]: https://todo.sr.ht/~mcf/cproc/5
    131 [#6]: https://todo.sr.ht/~mcf/cproc/6
    132 [#7]: https://todo.sr.ht/~mcf/cproc/7
    133 [#35]: https://todo.sr.ht/~mcf/cproc/35
    134 [#44]: https://todo.sr.ht/~mcf/cproc/44
    135 [~mcf/cproc@lists.sr.ht]: https://lists.sr.ht/~mcf/cproc
    136 [GitHub mirror]: https://github.com/michaelforney/cproc