MichaReiser / llvm-node

LLVM 9.0+ Node Bindings
MIT License
183 stars 29 forks source link

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

Closed ecto closed 4 years ago

ecto commented 4 years ago

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

vihanb commented 4 years ago

There are some known bugs when building for LLVM v10 right now. You can try to use PR #102 and see if that works for you. I'm not sure what's the status on getting PR #102 merged. I believe the main holdup is the fact that llvm::MaybeAlign doesn't exist on older versions which means it works only on LLVM 10+

ecto commented 4 years ago

Thank you @vihanb! #102 did allow me to install the package. My bad for not checking open PRs