quangr / Rllvm

R interface to LLVM C++ API to be able to create compiled code from within R

Home Page:http://www.omegahat.org/Rllvm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RLLVM

Updated for LLVM 15

RLLVM is an R interface to LLVM. This interface allows one to

  • dynamically create native machine code
  • invoke native/compiled code
  • analyze native code from C/C++/FORTRAN code

We generate native code via R commands and intermediate representation (IR), which LLVM can then extensively and efficiently optimize and generate native code.

For examples, see explorations, experiments and tests directories.

The current repository builds against LLVM 15, 14, 13, 12, 11, 10, 9, ..., 3.5, 3.6, 3.7, and 3.8.

Importantly, versions of LLVM default to the MCJIT execution engine. This unfortunately has very limited ability to invoke routines compiled via Rllvm, i.e., using the .llvm() and run() functions. Acccordingly, we have implemented a reasonably comprehensive mechanism to invoke these routines. We use the Rffi package to do this.

So this package now requires the Rffi package. This comes with its own version of libffi, but will find a more up-to-date version if it is installed (see pkg-config).

These packages are not on CRAN.

Related packages are Rffi, Rllvm (this one), RLLVMCompile, RLLVMCompile, RCUDA, RCIndex, NativeCodeAnalysis.

Installation

See INSTALL.md

On OSX, when working with binary versions of LLVM or versions built from source, some of the dynamic libraries (dylib) may not correctly point to the libc++.1.dylib leading to a failure to load the Rllvm.so library. To fix this, we use the command

install_name_tool -change @rpath/libc++.1.dylib /usr/lib/libc++.1.dylib src/Rllvm.so

to fix the src/Rllvm.so.

We can detect this either a) from the error message when R tries to load the package and its .so, or b) using otool -L src/Rllvm.so.

URLs

About

R interface to LLVM C++ API to be able to create compiled code from within R

http://www.omegahat.org/Rllvm


Languages

Language:R 88.1%Language:C++ 7.2%Language:TeX 2.0%Language:C 1.1%Language:Shell 0.5%Language:LLVM 0.5%Language:M4 0.3%Language:HTML 0.2%Language:Makefile 0.1%Language:Cuda 0.0%Language:Assembly 0.0%