~cypheon/rapid

LLVM Backend and Native Runtime for Idris2
dc52e744 — Johann Rudloff 12 days ago
Explicitly free heap when tests are finished
c3ff35b5 — Johann Rudloff 12 days ago
Allow global building with address sanitizer
8fe3c4f3 — Johann Rudloff 12 days ago
Limit max depth of CPS IR dump

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~cypheon/rapid
read/write
git@git.sr.ht:~cypheon/rapid

You can also use your local clone with git send-email.

builds.sr.ht status builds.sr.ht status

#LLVM codegen and native runtime for Idris 2

This is a backend to generate native executables from Idris code, machine code is generated via LLVM IR. Rapid is still in active development , but can already compile itself successfully (and reproducibly).

The source folder rts/ contains the runtime system with a relocating generational garbage collector.

#Prerequisites

LLVM 16 needs to be installed and the binaries available in your $PATH. To check if that is the case, try the following command:

$ opt --version
Debian LLVM version 16.0.6
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: znver2

GMP needs to be installed (libgmp-dev on Debian).

You need CMake (>= 3.25), building with make or ninja is supported.

For details regarding build time dependencies, please check the CI scripts in .builds/debian.yml.

#Compilation

Compile:

cmake .
make

Run tests:

make test

#Usage

The "support files" (precompiled platform code and runtime system) need to be available in a directory in the $IDRIS2_DATA path. You can achieve that by running (from within the source dir):

export IDRIS2_DATA=$PWD/build/support:$PWD/support

Then you can compile the included "Hello world" example:

./build/rapidc/exec/rapidc -o hello samples/Hello.idr

And run the compiled binary:

./build/exec/hello

#Limitations

Differences from the default Chez Scheme backend:

  • Int width is 63-bits instead of 64-bits
  • Generic FFI is new and not well tested (the FFI/prim functions from prelude and base are handwritten specifically for the RTS and work fine, however)

Currently not implemented:

  • Concurrency
  • UDP network primitives are not yet implemented
  • Some other support functions are still missing