Giter Site home page Giter Site logo

idris2-llvm's Introduction

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

LLVM codegen and native runtime for Idris 2

This is a (work in progress) backend to generate native executables from Idris code, using the LLVM compiler infrastructure. Code is generated via LLVM IR.

The source folder rts/ contains a primitive runtime system with a relocating semi-space garbage collector.

Prerequisites

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

$ opt --version
LLVM (http://llvm.org/):
  LLVM version 11.1.0

  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.18) and Ninja, building with make is not supported.

Make sure you have checked out the Git submodule as well:

git submodule update --init --recursive

Compilation

Prepare the submodule:

make -C external/llvm-statepoint-utils dist/llvm-statepoint-tablegen.h unified

Compile:

cmake -G Ninja .
ninja

Run tests:

ninja test

Usage

The "support files" (precompiled platform code and runtime system, as well as a custom LLVM pass) 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/support

(most useful during development) or by running make install.

# compile the included "Hello world" example
./build/exec/rapidc --cg llvm -o hello samples/Hello.idr
# run the compiled binary
./build/exec/hello

Limitations

Differences from mainline Idris 2:

  • Int is 63-bits only and overflow is handled differently

Currently not implemented:

  • FFI (the FFI functions from prelude and base are hardcoded & handwritten specifically for the RTS)
  • Concurrency
  • Network primitives are stubbed and not functional
  • Some support functions are completely missing

idris2-llvm's People

Contributors

cypheon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.