mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-18 00:31:57 +03:00
36 lines
1.3 KiB
ReStructuredText
36 lines
1.3 KiB
ReStructuredText
*************************
|
|
C with Reference Counting
|
|
*************************
|
|
|
|
There is an experimental code generator which compiles to an executable via C,
|
|
using a reference counting garbage collector. This is intended as a lightweight
|
|
(i.e. minimal dependencies) code generator that can be ported to multiple
|
|
platforms, especially those with memory constraints.
|
|
|
|
Performance is not as good as the Scheme based code generators, partly because
|
|
the reference counting has not yet had any optimisation, and partly because of
|
|
the limitations of C. However, the main goal is portability: the generated
|
|
code should run on any platform that supports a C compiler.
|
|
|
|
This code generator can be accessed via the REPL command:
|
|
|
|
::
|
|
|
|
Main> :set cg refc
|
|
|
|
Alternatively, you can set it via the ``IDRIS2_CG`` environment variable:
|
|
|
|
::
|
|
|
|
$ export IDRIS2_CG=refc
|
|
|
|
The C compiler it invokes is determined by either the ``IDRIS2_CC`` or ``CC``
|
|
environment variables. If neither is set, it uses ``cc``.
|
|
|
|
This code generator does not yet support `:exec`, just `:c`.
|
|
|
|
Also note that, if you link with any dynamic libraries for interfacing with
|
|
C, you will need to arrange for them to be accessible via ``LD_LIBRARY_PATH``
|
|
when running the executable. The default Idris 2 support libraries are
|
|
statically linked.
|