Skip to content
/ Rllvm Public

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

Notifications You must be signed in to change notification settings

duncantl/Rllvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RLLVM

Updated for LLVM 18

  • Not fully tested!

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

The current repository builds against LLVM 18, 17, 16, 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

And exploration/proof-of-concept packages using this include:

Installation

See INSTALL.md.

The usual package installation

R CMD INSTALL .

should work.

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.

After correcting this, R CMD INSTALL should install the corrected .so without needing to recompile or relink.

URLs

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published