MichaReiser/llvm-node


Node LLVM 4.0+ Bindings

License: MIT

Language: C++

Keywords: llvm, llvm-node, node, v8


llvm-node

Build Status npm version

Node Bindings for LLVM. The API is mostly identical to the one of LLVM (when possible and not to cumbersom). All supported methods with their signatures are listed in the TypeScript definition file.

Getting Started

Install the packages using npm or yarn.

npm install --save llvm-node

Require llvm-node and you're good to go

import * as llvm from "llvm-node";
// or
const llvm = require("llvm-node");

const context = new llvm.LLVMContext();
const module = new llvm.Module("test", context);

const intType = llvm.Type.getInt32Ty(context);
const initializer = llvm.ConstantInt.get(context, 0);
const globalVariable = new llvm.GlobalVariable(module, intType, true, llvm.LinkageTypes.InternalLinkage, initializer);

const ll = module.print(); // prints IR
llvm.writeBitcodeToFile(module, biteCodeFileName); // Writes file to disk

Custom LLVM Installation

You can use the npm configuration options to set the path to the LLVM cmake directory. This is needed if you don't want to use the system default LLVM installation --- e.g. when you want to compile againt the latest dev version.

To change the LLVM version use:

npm config set cmake_LLVM_DIR $(path-to-llvm/bin/llvm-config --cmakedir)

If you want to change the value just for a single project use an .npmrc file in your project.

Debug Build

If you want to use Value.dump or Module.dump you need to use the debug build of the library (and, as well, of LLVM). In this case, run node-gyp build --debug or if using npm install run npm_config_DEBUG=true npm install llvm-node.

There variables can also be set using npm set:

npm config set [--global] DEBUG True

Project Statistics

Sourcerank 5
Repository Size 490 KB
Stars 47
Forks 7
Watchers 4
Open issues 4
Dependencies 140
Contributors 3
Tags 33
Created
Last updated
Last pushed

Top Contributors See all

Micha Reiser Emil Laine Emil Laine

Packages Referencing this Repo

llvm-node
Node Bindings for LLVM >=4.0
Latest release 2.1.0 - Updated - 47 stars

Recent Tags See all

v2.1.0 October 24, 2018
v2.0.8 August 14, 2018
v2.0.7 August 13, 2018
v2.0.6 August 09, 2018
v2.0.5 May 22, 2018
v2.0.4 July 31, 2017
v2.0.3 June 26, 2017
v2.0.2 June 23, 2017
v2.0.1 May 26, 2017
v2.0.0 May 25, 2017
v1.0.7 May 19, 2017
v1.0.6 May 06, 2017
v1.0.5 May 03, 2017
v1.0.4 April 20, 2017
v1.0.3 April 20, 2017

Something wrong with this page? Make a suggestion

Last synced: 2018-08-14 17:45:41 UTC

Login to resync this repository