|
| 1 | +************************* |
| 2 | +C with Reference Counting |
| 3 | +************************* |
| 4 | + |
| 5 | +There is an experimental code generator which compiles to an executable via C, |
| 6 | +using a reference counting garbage collector. This is intended as a lightweight |
| 7 | +(i.e. minimal dependencies) code generator that can be ported to multiple |
| 8 | +platforms, especially those with memory constraints. |
| 9 | + |
| 10 | +Performance is not as good as the Scheme based code generators, partly because |
| 11 | +the reference counting has not yet had any optimisation, and partly because of |
| 12 | +the limitations of C. However, the main goal is portability: the generated |
| 13 | +code should run on any platform that supports a C compiler. |
| 14 | + |
| 15 | +This code generator can be accessed via the REPL command: |
| 16 | + |
| 17 | +:: |
| 18 | + |
| 19 | + Main> :set cg refc |
| 20 | + |
| 21 | +Alternatively, you can set it via the ``IDRIS2_CG`` environment variable: |
| 22 | + |
| 23 | +:: |
| 24 | + |
| 25 | + $ export IDRIS2_CG=refc |
| 26 | + |
| 27 | +The C compiler it invokes is determined by either the ``IDRIS2_CC`` or ``CC`` |
| 28 | +environment variables. If neither is set, it uses ``cc``. |
| 29 | + |
| 30 | +This code generator does not yet support `:exec`, just `:c`. |
| 31 | + |
| 32 | +Also note that, if you link with any dynamic libraries for interfacing with |
| 33 | +C, you will need to arrange for them to be accessible via ``LD_LIBRARY_PATH`` |
| 34 | +when running the executable. The default Idris 2 support libraries are |
| 35 | +statically linked. |
0 commit comments