Code Monkey home page Code Monkey logo

llvm-node's Introduction

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

Develop with VS-Code

  1. Install the C++ Extension
  2. Install the Cmake Tools Extension
  3. Configure the LLVM directory in the user settings by adding the following entry
"cmake.configureSettings": {
    "LLVM_DIR": "/usr/local/Cellar/llvm/7.0.0/lib/cmake/llvm" // Output of llvm-config --cmakedir
}
  1. Run the CMake:Configure Command in Visual Studio Code
  2. Run yarn configure from the command line
  3. Run CMake:Build command in Visual Studio Code

llvm-node's People

Contributors

dependabot[bot] avatar emlai avatar luikore avatar omantere avatar ovr avatar themas3212 avatar vihanb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

llvm-node's Issues

Build issues with Node v12

Not sure what is causing this but looks like there are some build issues arising when building for node v12 as have cropped up in CI:

error: no matching function for call to ‘v8::Value::ToString()’
     llvm::DataLayout layout { ToString(info[0]->ToString()) };
                                                          ^
note: candidates are:
In file included from ...

layout.cc:5:
v8::MaybeLocal<v8::String> v8::Value::ToString(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
                                            ^
note:   candidate expects 1 argument, 0 provided

This only started happening with node v12 so I am guessing v8 api changed? Few other v12 errors I am also seeing in v12 also probably related to API changes: https://travis-ci.org/vsl-lang/VSL/jobs/525749327#L502

Creating ConstantInts of very large numbers

I was recently implementing an algorithm that used a very large number 0xdf900294d8f554a5 in my language which compiles with llvm-node however I noticed an unusual issue is that JS cannot accurately represent such large numbers so the outputted LLVM contains an inaccurate number too. First thought was a .get() that takes a string and is parsed in C++ as a uint64 and then passed to LLVM could help solve this issue.

Missing nan.h

Hi,

clean Debian install, c++, cmake, llvm installed via apt. Build keeps failing on missing nan.h

# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
# npm install --save llvm-node                  
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
                                                  
> [email protected] install /root/p/node_modules/llvm-node
> cmake-js compile                                   
                                            
info TOOL Using Unix Makefiles generator.
info CMD CONFIGURE             
info RUN cmake "/root/p/node_modules/llvm-node" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="4.0.1" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTO
RY="/root/p/node_modules/llvm-node/build/Release" -DCMAKE_JS_INC="/root/.cmake-js/node-x64/v12.16.0/include/node" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.16.0" -DNODE
_ARCH="x64"                                             
Not searching for unused variables given on the command line.                                                                                           
-- The C compiler identification is GNU 8.3.0     
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info                                           
-- Detecting C compiler ABI info - done                                                                    
-- Detecting C compile features                                       
-- Detecting C compile features - done                                   
-- Check for working CXX compiler: /usr/bin/c++                       
-- Check for working CXX compiler: /usr/bin/c++ -- works                      
-- Detecting CXX compiler ABI info       
-- Detecting CXX compiler ABI info - done                                                      
-- Detecting CXX compile features                                                          
-- Detecting CXX compile features - done                                                                       
-- Found LLVM 7.0.1                     
-- Using LLVMConfig.cmake in: /usr/lib/llvm-7/cmake
-- Configuring done                 
-- Generating done                                                                                                     
-- Build files have been written to: /root/p/node_modules/llvm-node/build    
info CMD BUILD                      
info RUN cmake --build "/root/p/node_modules/llvm-node/build" --config Release
Scanning dependencies of target llvm-node                                     
[  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
In file included from /root/p/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:7:
/root/p/node_modules/llvm-node/src/bitcode/bitcode-writer.h:8:10: fatal error: nan.h: No such file or directory
 #include <nan.h>                                                               
          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/llvm-node.dir/build.make:63: CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/llvm-node.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
info REP Build has been failed, trying to do a full rebuild.
info CMD CLEAN
info RUN cmake -E remove_directory "/root/p/node_modules/llvm-node/build"
info CMD CONFIGURE
info RUN cmake "/root/p/node_modules/llvm-node" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="4.0.1" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECT$
RY="/root/p/node_modules/llvm-node/build/Release" -DCMAKE_JS_INC="/root/.cmake-js/node-x64/v12.16.0/include/node" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.16.0" -DNOD$
_ARCH="x64"
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LLVM 7.0.1
-- Using LLVMConfig.cmake in: /usr/lib/llvm-7/cmake
-- Configuring done
-- Generating done
-- Build files have been written to: /root/p/node_modules/llvm-node/build
info CMD BUILD
info RUN cmake --build "/root/p/node_modules/llvm-node/build" --config Release
Scanning dependencies of target llvm-node
[  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
In file included from /root/p/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:7:
/root/p/node_modules/llvm-node/src/bitcode/bitcode-writer.h:8:10: fatal error: nan.h: No such file or directory
 #include <nan.h>
          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/llvm-node.dir/build.make:63: CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/llvm-node.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
ERR! OMG Process terminated: 2
npm WARN enoent ENOENT: no such file or directory, open '/root/p/package.json'
npm WARN p No description
npm WARN p No repository field.
npm WARN p No README data
npm WARN p No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `cmake-js compile`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-02-18T03_06_49_264Z-debug.log

I did cp node_modules/nan/nan*.h /root/.cmake-js/node-x64/v12.16.0/include/node/ and

/root/p/node_modules/llvm-node/src/ir/data-layout.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE DataLayoutWrapper::New(Nan::NAN_METHOD_ARGS_TYPE)’:
/root/p/node_modules/llvm-node/src/ir/data-layout.cc:47:58: error: no matching function for call to ‘v8::Value::ToString()’
     llvm::DataLayout layout { ToString(info[0]->ToString()) };          
                                                          ^
In file included from /root/.cmake-js/node-x64/v12.16.0/include/node/node.h:63,                                                                                                                from /root/.cmake-js/node-x64/v12.16.0/include/node/nan.h:54,                                                                                                                 from /root/p/node_modules/llvm-node/src/ir/../util/string.h:8,
                 from /root/p/node_modules/llvm-node/src/ir/data-layout.cc:5:
/root/.cmake-js/node-x64/v12.16.0/include/node/v8.h:2668:44: note: candidate: ‘v8::MaybeLocal<v8::String> v8::Value::ToString(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
                                            ^~~~~~~~
/root/.cmake-js/node-x64/v12.16.0/include/node/v8.h:2668:44: note:   candidate expects 1 argument, 0 provided
In file included from /root/.cmake-js/node-x64/v12.16.0/include/node/v8-internal.h:14,
                 from /root/.cmake-js/node-x64/v12.16.0/include/node/v8.h:27,
                 from /root/.cmake-js/node-x64/v12.16.0/include/node/node.h:63,
                 from /root/.cmake-js/node-x64/v12.16.0/include/node/nan.h:54,
                 from /root/p/node_modules/llvm-node/src/ir/../util/string.h:8,
                 from /root/p/node_modules/llvm-node/src/ir/data-layout.cc:5:
/root/.cmake-js/node-x64/v12.16.0/include/node/v8.h:2684:31: note: candidate: ‘v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const’
                 Local<String> ToString(Isolate* isolate) const);
                               ^~~~~~~~
/root/.cmake-js/node-x64/v12.16.0/include/node/v8config.h:335:44: note: in definition of macro ‘V8_DEPRECATED’
 #define V8_DEPRECATED(message, declarator) declarator
                                            ^~~~~~~~~~
/root/.cmake-js/node-x64/v12.16.0/include/node/v8.h:2684:31: note:   candidate expects 1 argument, 0 provided
                 Local<String> ToString(Isolate* isolate) const);
                               ^~~~~~~~                                  
/root/.cmake-js/node-x64/v12.16.0/include/node/v8config.h:335:44: note: in definition of macro ‘V8_DEPRECATED’
 #define V8_DEPRECATED(message, declarator) declarator                        
                                            ^~~~~~~~~~
/root/p/node_modules/llvm-node/src/ir/data-layout.cc:47:61: error: no matching function for call to ‘llvm::DataLayout::DataLayout(<brace-enclosed initializer list>)’
     llvm::DataLayout layout { ToString(info[0]->ToString()) };                                    

Any ideas on what am I doing wrong?

Error installing

npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported

> [email protected] install /home/my-name/git/tmp/node_modules/llvm-node
> cmake-js compile

info TOOL Using Unix Makefiles generator.
info CMD CONFIGURE
info RUN cmake "/home/my-name/git/tmp/node_modules/llvm-node" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="4.0.1" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/home/my-name/git/tmp/node_modules/llvm-node/build/Release" -DCMAKE_JS_INC="/home/my-name/.cmake-js/node-x64/v14.8.0/include/node" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="14.8.0" -DNODE_ARCH="x64"
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LLVM 10.0.1
-- Using LLVMConfig.cmake in: /usr/lib64/cmake/llvm
-- Configuring done
-- Generating done
-- Build files have been written to: /home/my-name/git/tmp/node_modules/llvm-node/build
info CMD BUILD
info RUN cmake --build "/home/my-name/git/tmp/node_modules/llvm-node/build" --config Release
Scanning dependencies of target llvm-node
[  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
In file included from /home/my-name/git/tmp/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:7:
/home/my-name/git/tmp/node_modules/llvm-node/src/bitcode/bitcode-writer.h:8:10: fatal error: nan.h: No such file or directory
    8 | #include <nan.h>
      |          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/llvm-node.dir/build.make:82: CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:96: CMakeFiles/llvm-node.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
info REP Build has been failed, trying to do a full rebuild.
info CMD CLEAN
info RUN cmake -E remove_directory "/home/my-name/git/tmp/node_modules/llvm-node/build"
info CMD CONFIGURE
info RUN cmake "/home/my-name/git/tmp/node_modules/llvm-node" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="4.0.1" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/home/my-name/git/tmp/node_modules/llvm-node/build/Release" -DCMAKE_JS_INC="/home/my-name/.cmake-js/node-x64/v14.8.0/include/node" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="14.8.0" -DNODE_ARCH="x64"
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LLVM 10.0.1
-- Using LLVMConfig.cmake in: /usr/lib64/cmake/llvm
-- Configuring done
-- Generating done
-- Build files have been written to: /home/my-name/git/tmp/node_modules/llvm-node/build
info CMD BUILD
info RUN cmake --build "/home/my-name/git/tmp/node_modules/llvm-node/build" --config Release
Scanning dependencies of target llvm-node
[  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
In file included from /home/my-name/git/tmp/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:7:
/home/my-name/git/tmp/node_modules/llvm-node/src/bitcode/bitcode-writer.h:8:10: fatal error: nan.h: No such file or directory
    8 | #include <nan.h>
      |          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/llvm-node.dir/build.make:82: CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:96: CMakeFiles/llvm-node.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
ERR! OMG Process terminated: 2
npm WARN enoent ENOENT: no such file or directory, open '/home/my-name/git/tmp/package.json'
npm WARN tmp No description
npm WARN tmp No repository field.
npm WARN tmp No README data
npm WARN tmp No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `cmake-js compile`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/my-name/.npm/_logs/2020-08-17T19_36_09_385Z-debug.log

Contribution Guidelines

It seems I will be needing to add more stuff to this for my personal use. Instead of forking the library and including it privately, I'd like to do it properly and send pull requests that can be merged to the main repository.

I can just go and hack some stuff but if there were some guidelines that would prevent me shooting in my foot, it'd be much easier. For instance, this can be an example of one such case.

Type.getHalfTy() is missing.

There seems to be no way to create Half (16 bit float) types. There is a way in the LLVM api.

Type.getHalfTy(context) is the API I propose.

error: no member named 'getTypeByName' in 'llvm::Module'

This happens when I try to install lllvm-node via yarn on Termux. Possibly because I'm using LLVM 12 which is incompatible with llvm-node (contributions probably can make it compatible with llvm-node)

Full log:

❯ yarn add llvm-node
yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /data/data/com.termux/files/home/tlang_js/node_modules/llvm-node: Command failed.
Exit code: 1
Command: cmake-js compile
Arguments:
Directory: /data/data/com.termux/files/home/tlang_js/node_modules/llvm-node
Output:
[
  '/data/data/com.termux/files/usr/bin/node',
  '/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/node_modules/.bin/cmake-js',
  'compile'
]
info TOOL Using Ninja generator, because ninja is available.
info CMD CONFIGURE
info RUN [
info RUN   'cmake',
info RUN   '/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node',
info RUN   '--no-warn-unused-cli',
info RUN   '-G',
info RUN   'Ninja',
info RUN   '-DCMAKE_JS_VERSION=6.2.1',
info RUN   '-DCMAKE_BUILD_TYPE=Release',
info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build/Release',
info RUN   '-DCMAKE_JS_INC=/data/data/com.termux/files/home/.cmake-js/node-arm64/v14.15.4/include/node;/data/data/com.termux/files/home/tlang_js/node_modules/nan',
info RUN   '-DCMAKE_JS_SRC=',
info RUN   '-DNODE_RUNTIME=node',
info RUN   '-DNODE_RUNTIMEVERSION=14.15.4',
info RUN   '-DNODE_ARCH=arm64',
info RUN   '-DLLVM_DIR=/data/data/com.termux/files/usr/lib/cmake/llvm'
info RUN ]
Not searching for unused variables given on the command line.
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /data/data/com.termux/files/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /data/data/com.termux/files/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /data/data/com.termux/files/usr/lib/libz.so (found version "1.2.11")
-- Found LibXml2: /data/data/com.termux/files/usr/lib/libxml2.so (found version "2.9.12")
-- Found LLVM 12.0.0
-- Using LLVMConfig.cmake in: /data/data/com.termux/files/usr/lib/cmake/llvm
-- Configuring done
-- Generating done
-- Build files have been written to: /data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build
info CMD BUILD
info RUN [
info RUN   'cmake',
info RUN   '--build',
info RUN   '/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build',
info RUN   '--config',
info RUN   'Release'
info RUN ]
[1/45] Building CXX object CMakeFiles/llvm-node.dir/src/config/llvm-config.cc.o
[2/45] Building CXX object CMakeFiles/llvm-node.dir/src/config/config.cc.o
[3/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/attribute.cc.o
[4/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/array-type.cc.o
[5/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/atomic-rmw-inst.cc.o
[6/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/calling-conv.cc.o
[7/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/basic-block.cc.o
[8/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/alloca-inst.cc.o
[9/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/argument.cc.o
[10/45] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode.cc.o
[11/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-array.cc.o
[12/45] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
[13/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-data-array.cc.o
[14/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/call-inst.cc.o
[15/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-pointer-null.cc.o
[16/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-struct.cc.o
[17/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-fp.cc.o
[18/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-int.cc.o
[19/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant.cc.o
[20/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/data-layout.cc.o
[21/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/function-type.cc.o
[22/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/integer-type.cc.o
[23/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/llvm-context.cc.o
[24/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/global-variable.cc.o
[25/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/linkage-types.cc.o
[26/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/function.cc.o
[27/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/module.cc.o
FAILED: CMakeFiles/llvm-node.dir/src/ir/module.cc.o
/data/data/com.termux/files/usr/bin/c++ -DNOMINMAX -Dllvm_node_EXPORTS -I/data/data/com.termux/files/home/.cmake-js/node-arm64/v14.15.4/include/node -I/data/data/com.termux/files/home/tlang_js/node_modules/nan -I/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/./node_modules/nan -O3 -DNDEBUG -fPIC   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++14 -MD -MT CMakeFiles/llvm-node.dir/src/ir/module.cc.o -MF CMakeFiles/llvm-node.dir/src/ir/module.cc.o.d -o CMakeFiles/llvm-node.dir/src/ir/module.cc.o -c /data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/src/ir/module.cc
/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/src/ir/module.cc:139:38: error: no member named 'getTypeByName' in 'llvm::Module'
    llvm::StructType* type = module->getTypeByName(name);
                             ~~~~~~  ^
1 error generated.
[28/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/pointer-type.cc.o
[29/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/struct-type.cc.o
[30/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/unnamed-addr.cc.o
[31/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/type.cc.o
[32/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/undef-value.cc.o
[33/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/ir.cc.o
[34/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/phi-node.cc.o
[35/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/value.cc.o
[36/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/ir-builder.cc.o
ninja: build stopped: subcommand failed.
info REP Build has been failed, trying to do a full rebuild.
info CMD CLEAN
info RUN [
info RUN   'cmake',
info RUN   '-E',
info RUN   'remove_directory',
info RUN   '/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build'
info RUN ]                                                                              info CMD CONFIGURE
info RUN [                                                                              info RUN   'cmake',
info RUN   '/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node',          info RUN   '--no-warn-unused-cli',
info RUN   '-G',                                                                        info RUN   'Ninja',
info RUN   '-DCMAKE_JS_VERSION=6.2.1',                                                  info RUN   '-DCMAKE_BUILD_TYPE=Release',
info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build/Release',
info RUN   '-DCMAKE_JS_INC=/data/data/com.termux/files/home/.cmake-js/node-arm64/v14.15.4/include/node;/data/data/com.termux/files/home/tlang_js/node_modules/nan',
info RUN   '-DCMAKE_JS_SRC=',                                                           info RUN   '-DNODE_RUNTIME=node',
info RUN   '-DNODE_RUNTIMEVERSION=14.15.4',
info RUN   '-DNODE_ARCH=arm64',                                                         info RUN   '-DLLVM_DIR=/data/data/com.termux/files/usr/lib/cmake/llvm'                  info RUN ]
Not searching for unused variables given on the command line.
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /data/data/com.termux/files/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /data/data/com.termux/files/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /data/data/com.termux/files/usr/lib/libz.so (found version "1.2.11")     -- Found LibXml2: /data/data/com.termux/files/usr/lib/libxml2.so (found version "2.9.12")                                                                                       -- Found LLVM 12.0.0
-- Using LLVMConfig.cmake in: /data/data/com.termux/files/usr/lib/cmake/llvm            -- Configuring done
-- Generating done                                                                      -- Build files have been written to: /data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build                                                                     info CMD BUILD
info RUN [                                                                              info RUN   'cmake',                                                                     info RUN   '--build',
info RUN   '/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/build',
info RUN   '--config',
info RUN   'Release'
info RUN ]
[1/45] Building CXX object CMakeFiles/llvm-node.dir/src/config/config.cc.o
[2/45] Building CXX object CMakeFiles/llvm-node.dir/src/config/llvm-config.cc.o
[3/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/attribute.cc.o
[4/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/array-type.cc.o
[5/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/calling-conv.cc.o
[6/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/argument.cc.o
[7/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/basic-block.cc.o
[8/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/atomic-rmw-inst.cc.o
[9/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/alloca-inst.cc.o
[10/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-array.cc.o         [11/45] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode.cc.o
[12/45] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o    [13/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-data-array.cc.o
[14/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/call-inst.cc.o              [15/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-int.cc.o
[16/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-fp.cc.o            [17/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-pointer-null.cc.o
[18/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant-struct.cc.o        [19/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/data-layout.cc.o
[20/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/function-type.cc.o          [21/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/constant.cc.o               [22/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/integer-type.cc.o
[23/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/linkage-types.cc.o
[24/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/llvm-context.cc.o
[25/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/global-variable.cc.o
[26/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/function.cc.o
[27/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/pointer-type.cc.o
[28/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/module.cc.o
FAILED: CMakeFiles/llvm-node.dir/src/ir/module.cc.o
/data/data/com.termux/files/usr/bin/c++ -DNOMINMAX -Dllvm_node_EXPORTS -I/data/data/com.termux/files/home/.cmake-js/node-arm64/v14.15.4/include/node -I/data/data/com.termux/files/home/tlang_js/node_modules/nan -I/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/./node_modules/nan -O3 -DNDEBUG -fPIC   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++14 -MD -MT CMakeFiles/llvm-node.dir/src/ir/module.cc.o -MF CMakeFiles/llvm-node.dir/src/ir/module.cc.o.d -o CMakeFiles/llvm-node.dir/src/ir/module.cc.o -c /data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/src/ir/module.cc
/data/data/com.termux/files/home/tlang_js/node_modules/llvm-node/src/ir/module.cc:139:38: error: no member named 'getTypeByName' in 'llvm::Module'
    llvm::StructType* type = module->getTypeByName(name);                                                            ~~~~~~  ^
1 error generated.                                                                      [29/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/struct-type.cc.o
[30/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/undef-value.cc.o            [31/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/phi-node.cc.o
[32/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/unnamed-addr.cc.o           [33/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/type.cc.o                   [34/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/ir.cc.o
[35/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/value.cc.o
[36/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/ir-builder.cc.o
[37/45] Building CXX object CMakeFiles/llvm-node.dir/src/ir/verifier.cc.o
ninja: build stopped: subcommand failed.
ERR! OMG Process terminated: 1
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Can't found LLVM API: GetElementPtrInst

I want declare a number array and give it a value.

I can do this with clang, and the corresponding IR is

int a[3];
a[0] = 1;
%1 = alloca i32, align 4
%2 = alloca [3 x i32], align 4
store i32 0, i32* %1, align 4
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 1, i32* %3, align 4

But don't know how to implement it in llvm-node , because I cant' found getelementptr api in llvm-node

Cannot find Builder.createUnreachable

Hello,

Builder.createUnreachable seems missing. Sometimes this function may be quite useful, for example, building a trap basic block, where we do not want a terminator branching.

Thanks

Test Issue

The ir-builder.spec.ts can't be translated.
The error is "Assertion failed: (CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"), function getCast, file /Users/pzx/llvm/llvm-7.0.0.src/lib/IR/Constants.cpp, line1512.
Abort trap: 6",
My configuration is "Info RUN cmake "/Users/pzx/Desktop/panL/llvm-node" --no-warn-unused-cli -G"Ninja" -DCMAKE_JS_VERSION="5.3.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/Users/pzx/Desktop/panL/llvm-node/build/Release" -DCMAKE_JS_INC="/Users/pzx/.cmake-js/node-x64/v9.10.1/include/node;/Users/pzx/Desktop/panL/llvm-node/node_modules/nan" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="9.10.1" -DNODE_ARCH="x64" -DCMAKE_CXX_FLAGS="-D_DARWIN_USE_64_BIT_INODE=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DBUILDING_NODE_EXTENSION" -DCMAKE_SHARED_LINKER_FLAGS="-undefined dynamic_lookup" -DLLVM_DIR="/usr/local/lib/cmake/llvm"
Not searching for unused variables given on the command line.
-- Found LLVM 7.0.0
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
-- Configuring done
-- Generating done
"

Doubts about the `ConstantExpr` object

Hi, MichaReiser!

I want create a global string, and I can do this right now by such codes

const v = llvm.ConstantDataArray.getString(context, "Hello");
const r = new llvm.GlobalVariable(module, v.type, false, llvm.LinkageTypes.ExternalLinkage, v, name);

But I got some question, The generated IR is

@s = global [6 x i8] c"Hello\00"

See, the @s is an array.

When I declare a global string in clang, The generated IR is

@.str = private unnamed_addr constant [6 x i8] c"world\00", align 1
@s = global i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), align 8

the @s is an i8*

I think clang has done one more thing by

ConstantExpr::getBitCast(v, i8->getPointerTo())

I want my global string's type is i8* so I can pass in to system's function stdio::printf as an argument. But I don't known how can I do it because I can't find the ConstantExpr in llvm-node.

Installation failed

Installation fails on Ubuntu 18.04 when CMake begins linking process. Any ideas? This is extremely frustrating.

image

no member named 'getTypeByName' in 'llvm::Module'

When building with LLVM 12, I get this error:

node_modules/llvm-node/src/ir/module.cc:139:38: error: no member named 'getTypeByName' in 'llvm::Module'
    llvm::StructType* type = module->getTypeByName(name);

Use explicit declarations over using NAN Macros

The Nan documentation suggests to declare methods explicitly over using the Nan Macros.

void MethodName(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  ...
}

instead of

NAN_METHOD(MethodName {
  ...
}

The explicit declaration is suggested not only for JS method implementations but also for getters, setters...

The more explicit way has the advantage that many IDEs provide better IntelliSense and is generally either understood by humble humans as well.

It is, therefore, probably advisable to migrate the existing code base to use explicit method declarations.

StoreInst type problem (ConstantFP)

I'm trying to create a store instruction that will store a float on a float allocation (logical).

However, I'm running into the problem that when I access ConstantFP.get(), I have no way of specifying the type I want for the value. So ConstantFP.get() accepts LLVMContext and a number in that order.

But in the LLVM documentation this is possible:

image

Has this method not been implemented? The other way I tried was changing the type property of the returned value manually, but it shouldn't be like this... (have not verified working).

This is what is generated from my current code:

define void @main() {
  %pi = alloca float
  store double 3.140000e+00, float* %pi
  ret void
}

from:

...
const myFloat = parseFloat( ... )
ConstantFP.get(<context>, myFloat); // I want a float, creates a double instead.
...

The ConstantInt class' get() method looks more flexible, as it allows to specify the size, etc.

Expose JIT functions.

An important use case for llvm-node is to implement small toy languages, thus JIT becomes a necessary function. Not all use requires writing a bitcode to file. Is exposing JIT functions in the pipeline?

Node 11.4 crash on TargetMachineWrapper::of

Hey!

node -v
v11.4.0

I was trying to find where is a bug, but I didn't find..

LLDB:

lldb node                                                                                      SIGSEGV(11) ↵  3.68 Dur
(lldb) target create "node"
Current executable set to 'node' (x86_64).
(lldb) run ./node_modules/jest/bin/jest.js --ci --coverage --runInBand
Process 88466 launched: '/Users/ovr/.nvm/versions/node/v11.4.0/bin/node' (x86_64)
 PASS  test/ir/ir-builder.spec.ts
 PASS  test/ir/module.spec.ts
 PASS  test/ir/type.spec.ts
 PASS  test/ir/basic-block.spec.ts
 PASS  test/ir/value.spec.ts
 PASS  test/ir/argument.spec.ts
 PASS  test/ir/global-variable.spec.ts
 PASS  test/ir/struct-type.spec.ts
 PASS  test/ir/constant-fp.spec.ts
 PASS  test/ir/call-inst.spec.ts
 PASS  test/ir/verifier.spec.ts
 PASS  test/ir/alloca-inst.spec.ts
 PASS  test/ir/constant.spec.ts
 PASS  test/ir/constant-int.spec.ts
 PASS  test/ir/constant-data-array.spec.ts
 PASS  test/ir/phi-node.spec.ts

 RUNS  ...
Process 88466 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100198b05 node`v8::internal::(anonymous namespace)::InstantiateObject(v8::internal::Isolate*, v8::internal::Handle<v8::internal::ObjectTemplateInfo>, v8::internal::Handle<v8::internal::JSReceiver>, bool, bool) + 37
node`v8::internal::(anonymous namespace)::InstantiateObject:
->  0x100198b05 <+37>: movq   (%rsi), %rax
    0x100198b08 <+40>: movl   0x13(%rax), %ebx
    0x100198b0b <+43>: xorl   %esi, %esi
    0x100198b0d <+45>: testq  %r12, %r12
Target 0: (node) stopped.
(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000100198b05 node`v8::internal::(anonymous namespace)::InstantiateObject(v8::internal::Isolate*, v8::internal::Handle<v8::internal::ObjectTemplateInfo>, v8::internal::Handle<v8::internal::JSReceiver>, bool, bool) + 37
    frame #1: 0x0000000100198a9e node`v8::internal::ApiNatives::InstantiateObject(v8::internal::Isolate*, v8::internal::Handle<v8::internal::ObjectTemplateInfo>, v8::internal::Handle<v8::internal::JSReceiver>) + 62
    frame #2: 0x00000001001bae38 node`v8::ObjectTemplate::NewInstance(v8::Local<v8::Context>) + 280
    frame #3: 0x0000000109c3bbac llvm-node.node`TargetMachineWrapper::of(llvm::TargetMachine const*) + 108
    frame #4: 0x0000000109c3b277 llvm-node.node`TargetWrapper::createTargetMachine(Nan::FunctionCallbackInfo<v8::Value> const&) + 1015
    frame #5: 0x0000000109c10c25 llvm-node.node`Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo<v8::Value> const&) + 165
    frame #6: 0x0000000100221f37 node`v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) + 567
    frame #7: 0x0000000100221506 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 566
    frame #8: 0x0000000100220c00 node`v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 288
    frame #9: 0x00003aef44bcfb7d
    frame #10: 0x00003aef44b8e458
    frame #11: 0x00003aef44b8e458
    frame #12: 0x00003aef44b8e458
    frame #13: 0x00003aef44b876a6
    frame #14: 0x00003aef44c6bd9b
    frame #15: 0x00003aef44b89e72
    frame #16: 0x00003aef44c0a400
    frame #17: 0x00003aef44b8e458
    frame #18: 0x00003aef44b8e458
    frame #19: 0x00003aef44b876a6
    frame #20: 0x00003aef44bbf7ae
    frame #21: 0x00003aef44b9c6d2
    frame #22: 0x00003aef44b85c9e
    frame #23: 0x000000010054da45 node`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Handle<v8::internal::Object>, v8::internal::Execution::MessageHandling, v8::internal::Execution::Target) + 629
    frame #24: 0x000000010054dcc7 node`v8::internal::Execution::TryCall(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Execution::MessageHandling, v8::internal::MaybeHandle<v8::internal::Object>*, v8::internal::Execution::Target) + 231
    frame #25: 0x000000010054ddea node`v8::internal::Execution::RunMicrotasks(v8::internal::Isolate*, v8::internal::Execution::MessageHandling, v8::internal::MaybeHandle<v8::internal::Object>*) + 42
    frame #26: 0x0000000100673de4 node`v8::internal::Isolate::RunMicrotasks() + 436
    frame #27: 0x00000001000104fc node`node::InternalCallbackScope::Close() + 324
    frame #28: 0x00000001000420bc node`node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 306
    frame #29: 0x0000000100042291 node`node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 161
    frame #30: 0x0000000100027348 node`node::Environment::CheckImmediate(uv_check_s*) + 228
    frame #31: 0x00000001009fe6a2 node`uv__run_check + 167
    frame #32: 0x00000001009f97e6 node`uv_run + 344
    frame #33: 0x000000010004816e node`node::Start(v8::Isolate*, node::IsolateData*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 824
    frame #34: 0x00000001000472b8 node`node::Start(uv_loop_s*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 330
    frame #35: 0x0000000100046f1e node`node::Start(int, char**) + 243
    frame #36: 0x0000000100001034 node`start + 52```

Thanks

createAlloca return Segmentation fault: 11

let bb1 = llvm.BasicBlock.create(context,"start");
let irb1 = new llvm.IRBuilder(bb1);
let d = irb1.createAlloca(llvm.Type.getDoubleTy(context),undefined,"d");

third line throws Segmentation fault: 11 error

Need help for `InlineAsm`

// hope you are not bored with me :)

In simple terms, I am implementing a system call, which will requires InlineAsm.

I studied the code that implements the system call in c language and its IR:

static inline long
__internal_syscall(long n, long _a0, long _a1, long _a2, long _a3, long _a4, long _a5)
{
    register long a0 asm("a0") = _a0;
    register long a1 asm("a1") = _a1;
    register long a2 asm("a2") = _a2;
    register long a3 asm("a3") = _a3;
    register long a4 asm("a4") = _a4;
    register long a5 asm("a5") = _a5;
    register long syscall_id asm("a7") = n;
    asm volatile ("scall": "+r"(a0) : "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), "r"(syscall_id));
    return a0;
}

which results the IR code:

; Function Attrs: noinline nounwind optnone
define internal i64 @__internal_syscall(i64 %n, i64 %_a0, i64 %_a1, i64 %_a2, i64 %_a3, i64 %_a4, i64 %_a5) #0 {
entry:
  ......
  %14 = call i64 asm sideeffect "scall", "={x10},{x11},{x12},{x13},{x14},{x15},{x17},0"(i64 %8, i64 %9, i64 %10, i64 %11, i64 %12, i64 %13, i64 %7) #1, !srcloc !2
  .....
}

I can implement this with the c library of llvm:

llvm::InlineAsm *IA =
llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect,
                         /* IsAlignStack */ false, AsmDialect);
llvm::CallInst *Result = Builder.CreateCall(IA, Args);

But I can't find the InlineAsm in llvm node, I don't know how to implement this function. Thanks.

Failed to install llvm-node on macOS Sierra

OS version: macOS 10.12.4
LLVM version: Homebrew installed LLVM 4.0.0_1

Below is the error message when npm install llvm-node:

> [email protected] install /Users/linjie/Desktop/t/node_modules/llvm-node
> node-gyp rebuild

  CXX(target) Release/obj.target/llvm/src/llvm-node.o
  CXX(target) Release/obj.target/llvm/src/bitcode/bitcode.o
  CXX(target) Release/obj.target/llvm/src/bitcode/bitcode-writer.o
  CXX(target) Release/obj.target/llvm/src/ir/ir.o
  CXX(target) Release/obj.target/llvm/src/ir/attribute.o
  CXX(target) Release/obj.target/llvm/src/ir/alloca-inst.o
  CXX(target) Release/obj.target/llvm/src/ir/array-type.o
  CXX(target) Release/obj.target/llvm/src/ir/argument.o
../src/ir/argument.cc:69:26: error: no matching constructor for initialization of 'llvm::Argument'
    auto* argument = new llvm::Argument { type, name, function, argNo };
                         ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/4.0.0_1/include/llvm/IR/Argument.h:46:12: note: candidate constructor not viable: requires at most 3 arguments, but 4 were provided
  explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr);
           ^
/usr/local/Cellar/llvm/4.0.0_1/include/llvm/IR/Argument.h:34:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 4 were
      provided
class Argument : public Value, public ilist_node<Argument> {
      ^
../src/ir/argument.cc:120:15: error: no member named 'addAttrs' in 'llvm::Argument'
    argument->addAttrs(builder);
    ~~~~~~~~  ^
2 errors generated.
make: *** [Release/obj.target/llvm/src/ir/argument.o] Error 1

Won't build on Ubuntu 21.10 with LLVM 13

The library won't build on Ubuntu 21.10 with LLVM 13 installed. I've installed llvm and llvm-dev packages. cmake is available in the path. I've tried following https://github.com/vsl-lang/VSL/wiki/Installation#source-build-i-get-nanh-no-such-file-or-directory, but with no luck.

npm ERR! code 1
npm ERR! path /home/damian/Code/wisteria/node_modules/llvm-node
npm ERR! command failed
npm ERR! command sh -c cmake-js compile
npm ERR! [
npm ERR!   '/home/damian/.nvm/versions/node/v16.13.1/bin/node',
npm ERR!   '/home/damian/Code/wisteria/node_modules/.bin/cmake-js',
npm ERR!   'compile'
npm ERR! ]
npm ERR! Not searching for unused variables given on the command line.
npm ERR! -- The C compiler identification is GNU 11.2.0
npm ERR! -- The CXX compiler identification is GNU 11.2.0
npm ERR! -- Detecting C compiler ABI info
npm ERR! -- Detecting C compiler ABI info - done
npm ERR! -- Check for working C compiler: /usr/bin/cc - skipped
npm ERR! -- Detecting C compile features
npm ERR! -- Detecting C compile features - done
npm ERR! -- Detecting CXX compiler ABI info
npm ERR! -- Detecting CXX compiler ABI info - done
npm ERR! -- Check for working CXX compiler: /usr/bin/c++ - skipped
npm ERR! -- Detecting CXX compile features
npm ERR! -- Detecting CXX compile features - done
npm ERR! -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
npm ERR! -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.12") 
npm ERR! -- Found LLVM 13.0.0
npm ERR! -- Using LLVMConfig.cmake in: /usr/lib/llvm-13/cmake
npm ERR! -- Configuring done
npm ERR! -- Generating done
npm ERR! -- Build files have been written to: /home/damian/Code/wisteria/node_modules/llvm-node/build
npm ERR! Scanning dependencies of target llvm-node
npm ERR! [  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
npm ERR! Not searching for unused variables given on the command line.
npm ERR! -- The C compiler identification is GNU 11.2.0
npm ERR! -- The CXX compiler identification is GNU 11.2.0
npm ERR! -- Detecting C compiler ABI info
npm ERR! -- Detecting C compiler ABI info - done
npm ERR! -- Check for working C compiler: /usr/bin/cc - skipped
npm ERR! -- Detecting C compile features
npm ERR! -- Detecting C compile features - done
npm ERR! -- Detecting CXX compiler ABI info
npm ERR! -- Detecting CXX compiler ABI info - done
npm ERR! -- Check for working CXX compiler: /usr/bin/c++ - skipped
npm ERR! -- Detecting CXX compile features
npm ERR! -- Detecting CXX compile features - done
npm ERR! -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
npm ERR! -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.12") 
npm ERR! -- Found LLVM 13.0.0
npm ERR! -- Using LLVMConfig.cmake in: /usr/lib/llvm-13/cmake
npm ERR! -- Configuring done
npm ERR! -- Generating done
npm ERR! -- Build files have been written to: /home/damian/Code/wisteria/node_modules/llvm-node/build
npm ERR! Scanning dependencies of target llvm-node
npm ERR! [  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
npm ERR! info TOOL Using Unix Makefiles generator.
npm ERR! info CMD CONFIGURE
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '/home/damian/Code/wisteria/node_modules/llvm-node',
npm ERR! info RUN   '--no-warn-unused-cli',
npm ERR! info RUN   '-G',
npm ERR! info RUN   'Unix Makefiles',
npm ERR! info RUN   '-DCMAKE_JS_VERSION=6.3.0',
npm ERR! info RUN   '-DCMAKE_BUILD_TYPE=Release',
npm ERR! info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/damian/Code/wisteria/node_modules/llvm-node/build/Release',
npm ERR! info RUN   '-DCMAKE_JS_INC=/home/damian/.cmake-js/node-x64/v16.13.1/include/node;/home/damian/Code/wisteria/node_modules/nan',
npm ERR! info RUN   '-DCMAKE_JS_SRC=',
npm ERR! info RUN   '-DNODE_RUNTIME=node',
npm ERR! info RUN   '-DNODE_RUNTIMEVERSION=16.13.1',
npm ERR! info RUN   '-DNODE_ARCH=x64'
npm ERR! info RUN ]
npm ERR! info CMD BUILD
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '--build',
npm ERR! info RUN   '/home/damian/Code/wisteria/node_modules/llvm-node/build',
npm ERR! info RUN   '--config',
npm ERR! info RUN   'Release'
npm ERR! info RUN ]
npm ERR! /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE WriteBitcodeToFile(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:24:77: error: ‘F_None’ is not a member of ‘llvm::sys::fs’; did you mean ‘OF_None’?
npm ERR!    24 |     llvm::raw_fd_ostream byteCodeFile { fileName, errorCode, llvm::sys::fs::F_None };
npm ERR!       |                                                                             ^~~~~~
npm ERR!       |                                                                             OF_None
npm ERR! /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:24:84: error: no matching function for call to ‘llvm::raw_fd_ostream::raw_fd_ostream(<brace-enclosed initializer list>)’
npm ERR!    24 |     llvm::raw_fd_ostream byteCodeFile { fileName, errorCode, llvm::sys::fs::F_None };
npm ERR!       |                                                                                    ^
npm ERR! In file included from /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:5:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:504:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(int, bool, bool, llvm::raw_ostream::OStreamKind)’
npm ERR!   504 |   raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:504:22: note:   no known conversion for argument 1 from ‘std::__cxx11::basic_string<char>’ to ‘int’
npm ERR!   504 |   raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
npm ERR!       |                  ~~~~^~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:497:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::CreationDisposition, llvm::sys::fs::FileAccess, llvm::sys::fs::OpenFlags)’
npm ERR!   497 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:497:3: note:   candidate expects 5 arguments, 3 provided
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:495:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::OpenFlags)’
npm ERR!   495 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:495:3: note:   conversion of argument 3 would be ill-formed:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:493:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::FileAccess)’
npm ERR!   493 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:493:3: note:   conversion of argument 3 would be ill-formed:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:491:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::CreationDisposition)’
npm ERR!   491 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:491:3: note:   conversion of argument 3 would be ill-formed:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:490:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&)’
npm ERR!   490 |   raw_fd_ostream(StringRef Filename, std::error_code &EC);
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:490:3: note:   candidate expects 2 arguments, 3 provided
npm ERR! gmake[2]: *** [CMakeFiles/llvm-node.dir/build.make:82: CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
npm ERR! gmake[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/llvm-node.dir/all] Error 2
npm ERR! gmake: *** [Makefile:103: all] Error 2
npm ERR! info REP Build has been failed, trying to do a full rebuild.
npm ERR! info CMD CLEAN
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '-E',
npm ERR! info RUN   'remove_directory',
npm ERR! info RUN   '/home/damian/Code/wisteria/node_modules/llvm-node/build'
npm ERR! info RUN ]
npm ERR! info CMD CONFIGURE
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '/home/damian/Code/wisteria/node_modules/llvm-node',
npm ERR! info RUN   '--no-warn-unused-cli',
npm ERR! info RUN   '-G',
npm ERR! info RUN   'Unix Makefiles',
npm ERR! info RUN   '-DCMAKE_JS_VERSION=6.3.0',
npm ERR! info RUN   '-DCMAKE_BUILD_TYPE=Release',
npm ERR! info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/damian/Code/wisteria/node_modules/llvm-node/build/Release',
npm ERR! info RUN   '-DCMAKE_JS_INC=/home/damian/.cmake-js/node-x64/v16.13.1/include/node;/home/damian/Code/wisteria/node_modules/nan',
npm ERR! info RUN   '-DCMAKE_JS_SRC=',
npm ERR! info RUN   '-DNODE_RUNTIME=node',
npm ERR! info RUN   '-DNODE_RUNTIMEVERSION=16.13.1',
npm ERR! info RUN   '-DNODE_ARCH=x64'
npm ERR! info RUN ]
npm ERR! info CMD BUILD
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '--build',
npm ERR! info RUN   '/home/damian/Code/wisteria/node_modules/llvm-node/build',
npm ERR! info RUN   '--config',
npm ERR! info RUN   'Release'
npm ERR! info RUN ]
npm ERR! /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE WriteBitcodeToFile(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:24:77: error: ‘F_None’ is not a member of ‘llvm::sys::fs’; did you mean ‘OF_None’?
npm ERR!    24 |     llvm::raw_fd_ostream byteCodeFile { fileName, errorCode, llvm::sys::fs::F_None };
npm ERR!       |                                                                             ^~~~~~
npm ERR!       |                                                                             OF_None
npm ERR! /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:24:84: error: no matching function for call to ‘llvm::raw_fd_ostream::raw_fd_ostream(<brace-enclosed initializer list>)’
npm ERR!    24 |     llvm::raw_fd_ostream byteCodeFile { fileName, errorCode, llvm::sys::fs::F_None };
npm ERR!       |                                                                                    ^
npm ERR! In file included from /home/damian/Code/wisteria/node_modules/llvm-node/src/bitcode/bitcode-writer.cc:5:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:504:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(int, bool, bool, llvm::raw_ostream::OStreamKind)’
npm ERR!   504 |   raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:504:22: note:   no known conversion for argument 1 from ‘std::__cxx11::basic_string<char>’ to ‘int’
npm ERR!   504 |   raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
npm ERR!       |                  ~~~~^~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:497:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::CreationDisposition, llvm::sys::fs::FileAccess, llvm::sys::fs::OpenFlags)’
npm ERR!   497 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:497:3: note:   candidate expects 5 arguments, 3 provided
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:495:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::OpenFlags)’
npm ERR!   495 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:495:3: note:   conversion of argument 3 would be ill-formed:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:493:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::FileAccess)’
npm ERR!   493 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:493:3: note:   conversion of argument 3 would be ill-formed:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:491:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&, llvm::sys::fs::CreationDisposition)’
npm ERR!   491 |   raw_fd_ostream(StringRef Filename, std::error_code &EC,
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:491:3: note:   conversion of argument 3 would be ill-formed:
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:490:3: note: candidate: ‘llvm::raw_fd_ostream::raw_fd_ostream(llvm::StringRef, std::error_code&)’
npm ERR!   490 |   raw_fd_ostream(StringRef Filename, std::error_code &EC);
npm ERR!       |   ^~~~~~~~~~~~~~
npm ERR! /usr/lib/llvm-13/include/llvm/Support/raw_ostream.h:490:3: note:   candidate expects 2 arguments, 3 provided
npm ERR! gmake[2]: *** [CMakeFiles/llvm-node.dir/build.make:82: CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
npm ERR! gmake[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/llvm-node.dir/all] Error 2
npm ERR! gmake: *** [Makefile:103: all] Error 2
npm ERR! ERR! OMG Process terminated: 2

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/damian/.npm/_logs/2021-12-27T09_47_27_201Z-debug.log

Install error: no viable conversion from 'unsigned int' to 'llvm::MaybeAlign'

Hey there, I'm trying to install version 2.1.0 of this library against LLVM 10.0.1. I'm getting the following error while npm installing:

info CMD CONFIGURE
info RUN cmake "/Users/cam/code/personal/witch/node_modules/llvm-node" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="4.0.1" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/Users/cam/code/personal/witch/node_modules/llvm-node/build/Release" -DCMAKE_JS_INC="/Users/cam/.cmake-js/node-x64/v14.5.0/include/node;/Users/cam/code/personal/witch/node_modules/nan" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="14.5.0" -DNODE_ARCH="x64" -DCMAKE_CXX_FLAGS="-D_DARWIN_USE_64_BIT_INODE=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DBUILDING_NODE_EXTENSION" -DCMAKE_SHARED_LINKER_FLAGS="-undefined dynamic_lookup" -DLLVM_DIR="/usr/local/Cellar/llvm/10.0.1/lib/cmake/llvm"
Not searching for unused variables given on the command line.
-- The C compiler identification is AppleClang 11.0.3.11030032
-- The CXX compiler identification is AppleClang 11.0.3.11030032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libz.tbd (found version "1.2.11") 
-- Found LLVM 10.0.1
-- Using LLVMConfig.cmake in: /usr/local/opt/llvm/lib/cmake/llvm
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/cam/code/personal/witch/node_modules/llvm-node/build
info CMD BUILD
info RUN cmake --build "/Users/cam/code/personal/witch/node_modules/llvm-node/build" --config Release
Scanning dependencies of target llvm-node
[  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
[  4%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode.cc.o
[  7%] Building CXX object CMakeFiles/llvm-node.dir/src/config/config.cc.o
[  9%] Building CXX object CMakeFiles/llvm-node.dir/src/config/llvm-config.cc.o
[ 11%] Building CXX object CMakeFiles/llvm-node.dir/src/ir/alloca-inst.cc.o
/Users/cam/code/personal/witch/node_modules/llvm-node/src/ir/alloca-inst.cc:71:44: error: no viable conversion
      from 'unsigned int' to 'llvm::MaybeAlign'
    wrapper->getAllocaInst()->setAlignment(Nan::To<uint32_t>(value).FromJust());
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/opt/llvm/include/llvm/ADT/Optional.h:222:13: note: candidate inherited constructor not viable: no
      known conversion from 'unsigned int' to 'llvm::NoneType' for 1st argument
  constexpr Optional(NoneType) {}
            ^
/usr/local/opt/llvm/include/llvm/Support/Alignment.h:132:13: note: constructor from base class
      'Optional<llvm::Align>' inherited here
  using UP::UP;
            ^
/usr/local/opt/llvm/include/llvm/ADT/Optional.h:224:3: note: candidate inherited constructor not viable: no
      known conversion from 'unsigned int' to 'const llvm::Align &' for 1st argument
  Optional(const T &y) : Storage(optional_detail::in_place_t{}, y) {}
  ^
/usr/local/opt/llvm/include/llvm/Support/Alignment.h:132:13: note: constructor from base class
      'Optional<llvm::Align>' inherited here
  using UP::UP;
            ^
/usr/local/opt/llvm/include/llvm/ADT/Optional.h:227:3: note: candidate inherited constructor not viable: no
      known conversion from 'unsigned int' to 'llvm::Align &&' for 1st argument
  Optional(T &&y) : Storage(optional_detail::in_place_t{}, std::move(y)) {}
  ^
/usr/local/opt/llvm/include/llvm/Support/Alignment.h:132:13: note: constructor from base class
      'Optional<llvm::Align>' inherited here
  using UP::UP;
            ^
/usr/local/opt/llvm/include/llvm/Support/Alignment.h:126:3: note: candidate constructor not viable: no known
      conversion from 'unsigned int' to 'const llvm::MaybeAlign &' for 1st argument
  MaybeAlign(const MaybeAlign &Other) = default;
  ^
/usr/local/opt/llvm/include/llvm/Support/Alignment.h:128:3: note: candidate constructor not viable: no known
      conversion from 'unsigned int' to 'llvm::MaybeAlign &&' for 1st argument
  MaybeAlign(MaybeAlign &&Other) = default;
  ^
/usr/local/opt/llvm/include/llvm/IR/Instructions.h:117:32: note: passing argument to parameter 'Align' here
  void setAlignment(MaybeAlign Align);
                               ^
1 error generated.
make[2]: *** [CMakeFiles/llvm-node.dir/src/ir/alloca-inst.cc.o] Error 1
make[1]: *** [CMakeFiles/llvm-node.dir/all] Error 2

Any ideas? I'm not familiar enough with the ecosystem to debug the llvm-node/llvm boundary.

In the meantime, I'm going to try compiling against an older version of LLVM and report back

yarn add llvm-node build error in macOS

The system info: mac 12.0.1 , macOS Monterey.

When i run yarn add llvm-node, it occurs as follows:

info RUN cmake "/Users/[**user-path**]/llvm-node" --no-warn-unused-cli -G"Unix Makefiles" 
-DCMAKE_JS_VERSION="6.1.0" -DCMAKE_BUILD_TYPE="Release" 
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/Users/[**user-path**]/llvm-node/build/Release" 
-DCMAKE_JS_INC="/Users/[**user-path**]/.cmake-js/node-x64/v14.17.4/include/node;
/Users/[**user-path**]/llvm-node/node_modules/nan" -DCMAKE_JS_SRC="" 
-DNODE_RUNTIME="node" 
-DNODE_RUNTIMEVERSION="14.17.4" -DNODE_ARCH="x64" -DCMAKE_CXX_FLAGS="
-D_DARWIN_USE_64_BIT_INODE=1 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DBUILDING_NODE_EXTENSION" 
-DCMAKE_SHARED_LINKER_FLAGS="-undefined dynamic_lookup"
Not searching for unused variables given on the command line.
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk/usr/lib/libz.tbd (found version "1.2.11")
-- Found LibXml2: /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk/usr/lib/libxml2.tbd (found version "2.9.4")
-- Found LLVM 13.0.0
-- Using LLVMConfig.cmake in: /usr/local/opt/llvm/lib/cmake/llvm
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/[**user-path**]/llvm-node/build
info CMD BUILD
info RUN cmake --build "/Users/[**user-path**]/llvm-node/build" --config Release
[  2%] Building CXX object CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o
/Users/[**user-path**]/llvm-node/src/bitcode/bitcode-writer.cc:24:77: error: no member named 'F_None' in namespace 'llvm::sys::fs'; did you mean 'OF_None'?
    llvm::raw_fd_ostream byteCodeFile { fileName, errorCode, llvm::sys::fs::F_None };
                                                             ~~~~~~~~~~~~~~~^~~~~~
                                                                            OF_None
/usr/local/opt/llvm/include/llvm/Support/FileSystem.h:757:3: note: 'OF_None' declared here
  OF_None = 0,
  ^
1 error generated.
make[2]: *** [CMakeFiles/llvm-node.dir/src/bitcode/bitcode-writer.cc.o] Error 1
make[1]: *** [CMakeFiles/llvm-node.dir/all] Error 2
make: *** [all] Error 2
ERR! OMG Process terminated: 2
error Command failed with exit code 1.

Is it some problems about macos system?

thanks for the response.

Requirements?

I am using windows 10. What do I need to do to use llvm-node? I tried installing LLVM-13.0.1-win64.exe. Then when I installed llvm-node, I got this error:

CMake Error at CMakeLists.txt:6 (find_package):
│   Could not find a package configuration file provided by "LLVM" with any of
│   the following names:
│     LLVMConfig.cmake
│     llvm-config.cmake
│   Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
│   "LLVM_DIR" to a directory containing one of the above files.  If "LLVM"
│   provides a separate development package or SDK, be sure it has been
│   installed.

Do I need to download llvm source code?

DIBuilder class

LLVM has a LLVM::DIBuilder which provides tools for creating debug information.

I'll attempt to make a PR for this in the upcoming weeks.

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.