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
environment variables. If neither is set, it uses
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
when running the executable. The default Idris 2 support libraries are