Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental C backend with reference counting #739

Merged
merged 10 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Compiler changes:

* Added primitives to the parsing library used in the compiler to get more precise
boundaries to the AST nodes `FC`.
* New experimental ``refc`` code generator, which generates C with reference
counting.

REPL/IDE mode changes:

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ test:

support:
@${MAKE} -C support/c
@${MAKE} -C support/refc

support-clean:
@${MAKE} -C support/c clean
@${MAKE} -C support/refc clean

clean-libs:
${MAKE} -C libs/prelude clean
Expand Down Expand Up @@ -129,6 +131,7 @@ install-support:
install support/gambit/* ${PREFIX}/idris2-${IDRIS2_VERSION}/support/gambit
install support/js/* ${PREFIX}/idris2-${IDRIS2_VERSION}/support/js
@${MAKE} -C support/c install
@${MAKE} -C support/refc install

install-libs:
${MAKE} -C libs/prelude install IDRIS2=../../${TARGET} IDRIS2_PATH=${IDRIS2_BOOT_PATH}
Expand Down
2 changes: 1 addition & 1 deletion Release/mkdist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ git checkout tags/v$1
rm -rf .git
rm -rf .github
rm .git*
rm .travis*
rm -f .travis*
rm -rf Release
find . -type f -name '.gitignore' -exec rm -f {} \;

Expand Down
1 change: 1 addition & 0 deletions docs/source/backends/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ or via the `IDRIS2_CG` environment variable.
racket
gambit
javascript
refc
custom
35 changes: 35 additions & 0 deletions docs/source/backends/refc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
*************************
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.
2 changes: 2 additions & 0 deletions idris2api.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ modules =
Compiler.ES.RemoveUnused,
Compiler.ES.TailRec,

Compiler.RefC.RefC,

Compiler.Scheme.Chez,
Compiler.Scheme.Racket,
Compiler.Scheme.Gambit,
Expand Down
Loading