ApsarasX/llvm-bindings

Can't install llvm-bindings on ubuntu 20.04

YiraSan opened this issue · 5 comments

npm ERR! command failed
npm ERR! command sh -c cross-env CMAKE_BUILD_PARALLEL_LEVEL=$(node -p 'require(`os`).cpus().length') cmake-js compile
npm ERR! [
npm ERR!   '/usr/bin/node',
npm ERR!   '/root/code/flowge/node_modules/.bin/cmake-js',
npm ERR!   'compile'
npm ERR! ]
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   '/root/code/flowge/node_modules/llvm-bindings',
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=/root/code/flowge/node_modules/llvm-bindings/build/Release',
npm ERR! info RUN   '-DCMAKE_JS_INC=/root/.cmake-js/node-x64/v17.3.1/include/node',
npm ERR! info RUN   '-DCMAKE_JS_SRC=',
npm ERR! info RUN   '-DNODE_RUNTIME=node',
npm ERR! info RUN   '-DNODE_RUNTIMEVERSION=17.3.1',
npm ERR! info RUN   '-DNODE_ARCH=x64'
npm ERR! info RUN ]
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   '/root/code/flowge/node_modules/llvm-bindings/build'
npm ERR! info RUN ]
npm ERR! info CMD CONFIGURE
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '/root/code/flowge/node_modules/llvm-bindings',
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=/root/code/flowge/node_modules/llvm-bindings/build/Release',
npm ERR! info RUN   '-DCMAKE_JS_INC=/root/.cmake-js/node-x64/v17.3.1/include/node',
npm ERR! info RUN   '-DCMAKE_JS_SRC=',
npm ERR! info RUN   '-DNODE_RUNTIME=node',
npm ERR! info RUN   '-DNODE_RUNTIMEVERSION=17.3.1',
npm ERR! info RUN   '-DNODE_ARCH=x64'
npm ERR! info RUN ]
npm ERR! ERR! OMG Process terminated: 1 

I can't install llvm-bindings and this is what I get.. :/

Also i tried using yarn, npm, different version of nodejs (14, 16 and 17)

Sorry, I can't see what the problem is from your error message for now.

You can try the following commands and see what happens.

git clone https://github.com/ApsarasX/llvm-bindings.git --depth=1

cd llvm-bindings

npm install --ignore-scripts

npm run build:debug

From this :

> llvm-bindings@0.3.3 build:debug
> cross-env CMAKE_BUILD_PARALLEL_LEVEL=$(node -p 'require(`os`).cpus().length') cmake-js build -D

[
  '/usr/bin/node',
  '/home/camille/ndmodules/llvm-bindings/node_modules/.bin/cmake-js',
  'build',
  '-D'
]
info TOOL Using Unix Makefiles generator.
info CMD CONFIGURE
info RUN [
info RUN   'cmake',
info RUN   '/home/camille/ndmodules/llvm-bindings',
info RUN   '--no-warn-unused-cli',
info RUN   '-G',
info RUN   'Unix Makefiles',
info RUN   '-DCMAKE_JS_VERSION=6.3.0',
info RUN   '-DCMAKE_BUILD_TYPE=Debug',
info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/camille/ndmodules/llvm-bindings/build/Debug',
info RUN   '-DCMAKE_JS_INC=/home/camille/.cmake-js/node-x64/v17.3.1/include/node',
info RUN   '-DCMAKE_JS_SRC=',
info RUN   '-DNODE_RUNTIME=node',
info RUN   '-DNODE_RUNTIMEVERSION=17.3.1',
info RUN   '-DNODE_ARCH=x64'
info RUN ]
Not searching for unused variables given on the command line.
-- The CXX compiler identification is GNU 9.3.0
-- 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 NPM
-- Found CMake.js
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.10") 
CMake Error at /usr/lib/llvm-13/lib/cmake/llvm/LLVMExports.cmake:1529 (message):
  The imported target "MLIRSupportIndentedOstream" references the file

     "/usr/lib/llvm-13/lib/libMLIRSupportIndentedOstream.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/llvm-13/lib/cmake/llvm/LLVMExports.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/llvm-13/cmake/LLVMConfig.cmake:300 (include)
  cmake/LLVM.cmake:5 (find_package)
  CMakeLists.txt:11 (include)

I found this solution:

sudo npm i -g cmake-js

After that I get:

 llvm-bindings@0.3.3 build:debug
> cross-env CMAKE_BUILD_PARALLEL_LEVEL=$(node -p 'require(`os`).cpus().length') cmake-js build -D

[
  '/usr/bin/node',
  '/home/camille/ndmodules/llvm-bindings/node_modules/.bin/cmake-js',
  'build',
  '-D'
]
info TOOL Using Unix Makefiles generator.
info CMD BUILD
info RUN [
info RUN   'cmake',
info RUN   '--build',
info RUN   '/home/camille/ndmodules/llvm-bindings/build',
info RUN   '--config',
info RUN   'Debug'
info RUN ]
make: Makefile: No such file or directory
make: *** No rule to make target 'Makefile'.  Stop.
ERR! OMG Process terminated: 2

So I guessed that there's a problem with this file: /usr/lib/llvm-13/lib/cmake/llvm/LLVMExports.cmake
So I reinstalled llvm with:

sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"

But I get the same error, so I tried to reinstall packages:

rm -Rf node_modules
npm install

Here, I get a new CMake error:

CMake Error in CMakeLists.txt:
  Imported target "LLVMCore" includes non-existent path

    "/usr/local/zlib/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

So i reinstalled zlib (with a broken check flag) and add missing path

sudo apt-get reinstall -f zlib1g
sudo mkdir /usr/local/zlib/ && sudo mkdir /usr/local/zlib/include/ && sudo mkdir /usr/local/zlib/src/

And this time I get back:

camille@yirasan:~/ndmodules/llvm-bindings$ npm run build:debug

> llvm-bindings@0.3.3 build:debug
> cross-env CMAKE_BUILD_PARALLEL_LEVEL=$(node -p 'require(`os`).cpus().length') cmake-js build -D

[
  '/usr/bin/node',
  '/home/camille/ndmodules/llvm-bindings/node_modules/.bin/cmake-js',
  'build',
  '-D'
]
info TOOL Using Unix Makefiles generator.
info CMD CONFIGURE
info RUN [
info RUN   'cmake',
info RUN   '/home/camille/ndmodules/llvm-bindings',
info RUN   '--no-warn-unused-cli',
info RUN   '-G',
info RUN   'Unix Makefiles',
info RUN   '-DCMAKE_JS_VERSION=6.3.0',
info RUN   '-DCMAKE_BUILD_TYPE=Debug',
info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/camille/ndmodules/llvm-bindings/build/Debug',
info RUN   '-DCMAKE_JS_INC=/home/camille/.cmake-js/node-x64/v17.3.1/include/node',
info RUN   '-DCMAKE_JS_SRC=',
info RUN   '-DNODE_RUNTIME=node',
info RUN   '-DNODE_RUNTIMEVERSION=17.3.1',
info RUN   '-DNODE_ARCH=x64'
info RUN ]
Not searching for unused variables given on the command line.
-- Found NPM
-- Found CMake.js
-- Found LLVM 13.0.1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/camille/ndmodules/llvm-bindings
info CMD BUILD
info RUN [
info RUN   'cmake',
info RUN   '--build',
info RUN   '/home/camille/ndmodules/llvm-bindings/build',
info RUN   '--config',
info RUN   'Debug'
info RUN ]
Error: could not load cache
ERR! OMG Process terminated: 1

So I deleted CMakeCache:

rm CMakeCache.txt

And get (again) this (with npm run build:debug):

-- The CXX compiler identification is GNU 9.3.0
-- 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 NPM
-- Found CMake.js
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.10") 
-- Found LLVM 13.0.1
-- Configuring done
CMake Error at CMakeLists.txt:17 (add_library):
  Target "llvm-bindings" links to target "ZLIB::ZLIB" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

So i'm no sure that ther's a missing ZLIB!!
I check entry in cmake-gui, and there's no ZLIB entry (also in environnement).
So I installed zlib-dev (to try): sudo apt-get install zlib1g-dev

And finally that work!

(spoiler: I get another error x))

collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/llvm-bindings.dir/build.make:961: Debug/llvm-bindings.node] Error 1
make[1]: *** [CMakeFiles/Makefile2:164: CMakeFiles/llvm-bindings.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
ERR! OMG Process terminated: 2

I found on internet, that sometimes Cmake want 32bits library ?? So I installed 32 bits:

sudo apt-get install lib32z1-dev

And... I get the same error :D 🧑‍⚕️ 🗡️

But I discover that there's a command to install all zlib package (including all packages I tried to installed and more, so I just wanna kill myself)

I tried... sudo apt-get install zlib*

But I get the same error x)
I tried to find with LD Debug info:
LD_DEBUG=all make ...
and i get:

     69526:	binding file /lib/x86_64-linux-gnu/libc.so.6 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `realloc' [GLIBC_2.2.5]
make: *** No rule to make target '...'.  Stop.
     69526:	
     69526:	calling fini: make [0]
     69526:	
     69526:	
     69526:	calling fini: /lib/x86_64-linux-gnu/libdl.so.2 [0]

Help ? 😭

Sorry for taking so long to reply to you, I think it's because zlib is not installed correctly.

The compile target for llvm-bindings is llvm-bindings.node.

Below is the display when I execute ldd llvm-bindings.node
截屏2022-01-22 上午12 09 33

It can be seen that /lib/x86_64-linux-gnu/libz.so.1 will be linked into the compilation target of llvm-bindings.

So you need to execute sudo apt install zlib1g-dev to install zlib.

On my machine, the installation status of zlib is as follows:
截屏2022-01-22 上午12 18 40

I change everything in my computer (for other reasons), im now on windows and I use wsl2 i had a similar problem and i fix the problem with this:

  • i entierly install cmake with every possible extensions
  • npm cache clear --force
  • chown -R $USER ~/.npm

That's now work