ErLLVM is a project aiming at providing multiple backends for the HiPE compiler with the use of the LLVM Compiler Infastructure.

At the moment, ErLLVM supports only AMD64; x86 support is currently unstable due to architectural changes. Hopefully, this will be fixed soon. There is also some ongoing work for ARM.

ErLLVM will be soon available experimentally as part of version 17.0 of Erlang/OTP (merged into master branch as of 1st of April 2014).

System Requirements

  • LLVM >= 3.4

Hello world with ErLLVM

  1. Write an Erlang module:

    hello(Name) ->
      io:format("Hello ~w!~n", [Name]).
  2. Fire the Erlang shell:

    yiannis@mosby [~/git/otp]>>= erl
    Erlang/OTP 17 [erts-6.0] [source-ef8c4a6] [64-bit] [smp:16:16] [async-threads:10] [hipe]
    Eshell V6.0  (abort with ^G)
  3. Compile the module to native code using the LLVM backend:

    2> c(test, [native, {hipe, [to_llvm]}]).

    Alternatively, you can first generate BEAM bytecode and then compile it to native code and load it using:

    2> c(test), hipe:c(test, [to_llvm]).
  4. It works! :-)

    3> test:hello(world).
    Hello world!

All wikis are supposed to have a SandBox, so this one does too.

This wiki is powered by ikiwiki.