~cypheon/rapid

Native Codegen and Runtime for Idris2

f1e5fb9 Make globals section dynamic, also for dummy global

~cypheon pushed to ~cypheon/rapid git

2 days ago

07f9fea test/asan: "Unpoison" globals area in tests when running on a Mach-O system

~cypheon pushed to ~cypheon/rapid git

2 days ago

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