ShravanSunder / hnswlib-wasm

hnswlib-wasm attempts to create a browser friendly version of hnswlib
https://www.npmjs.com/package/hnswlib-wasm
Apache License 2.0
42 stars 8 forks source link

Cannot build from source #11

Open Jonarod opened 1 month ago

Jonarod commented 1 month ago
git clone git@github.com:ShravanSunder/hnswlib-wasm.git
cd hnswlib-wasm
yarn install
make rebuild
yarn build

results in these errors:

mkdir -p lib
em++ -O3 -fwasm-exceptions -s ALLOW_MEMORY_GROWTH=1 -s ALLOW_TABLE_GROWTH=1 -s WASM=1 -s MODULARIZE=1 -s EXPORT_NAME='hnswlib' -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 -s SINGLE_FILE --bind -s ENVIRONMENT=web -gsource-map -lidbfs.js -I././src/hnswlib  ././src/wrapper.cpp -o ./lib/hnswlib.mjs 
In file included from ././src/wrapper.cpp:6:
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:440:13: error: too many arguments to function call, expected single argument 'vec', have 2 arguments
  438 |         return internal::BindingType<ReturnType>::toWireType(
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  439 |             fn(internal::BindingType<Args>::fromWireType(args)...),
  440 |             ReturnPolicy{}
      |             ^~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:585:63: note: in instantiation of member function 'emscripten::internal::Invoker<emscripten::internal::rvp::default_tag, std::vector<float>, const std::vector<float> &>::invoke' requested here
  585 |     auto invoke = Invoker<ReturnPolicy, ReturnType, Args...>::invoke;
      |                                                               ^
././src/wrapper.cpp:1036:5: note: in instantiation of function template specialization 'emscripten::function<std::vector<float>, const std::vector<float> &>' requested here
 1036 |     function("normalizePoint", &normalizePointsPure);
      |     ^
././src/wrapper.cpp:180:23: note: 'toWireType' declared here
  180 |       static WireType toWireType(const std::vector<T, Allocator>& vec) {
      |                       ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
././src/wrapper.cpp:181:16: error: no matching function for call to 'toWireType'
  181 |         return ValBinding::toWireType(val::array(vec));
      |                ^~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:438:51: note: in instantiation of member function 'emscripten::internal::BindingType<std::vector<float>>::toWireType' requested here
  438 |         return internal::BindingType<ReturnType>::toWireType(
      |                                                   ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:585:63: note: in instantiation of member function 'emscripten::internal::Invoker<emscripten::internal::rvp::default_tag, std::vector<float>, const std::vector<float> &>::invoke' requested here
  585 |     auto invoke = Invoker<ReturnPolicy, ReturnType, Args...>::invoke;
      |                                                               ^
././src/wrapper.cpp:1036:5: note: in instantiation of function template specialization 'emscripten::function<std::vector<float>, const std::vector<float> &>' requested here
 1036 |     function("normalizePoint", &normalizePointsPure);
      |     ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/val.h:809:19: note: candidate function not viable: requires 2 arguments, but 1 was provided
  809 |   static WireType toWireType(val&& v, rvp::default_tag) {
      |                   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/val.h:815:19: note: candidate function not viable: requires 2 arguments, but 1 was provided
  815 |   static WireType toWireType(const val& v, rvp::default_tag) {
      |                   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ././src/wrapper.cpp:6:
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:667:13: error: too many arguments to function call, expected single argument 'vec', have 2 arguments
  662 |         return internal::BindingType<ReturnType>::toWireType(
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663 |             (internal::BindingType<ThisType>::fromWireType(wireThis)->*method)(
  664 |                 internal::BindingType<Args>::fromWireType(args)...
  665 |             )
  666 |             ,
  667 |             ReturnPolicy{}
      |             ^~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:1452:111: note: in instantiation of member function 'emscripten::internal::MethodInvoker<emscripten::internal::rvp::default_tag, std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(const std::vector<std::vector<float>> &, bool), std::vector<unsigned int>, emscripten::HierarchicalNSW *, const std::vector<std::vector<float>> &, bool>::invoke' requested here
 1452 |         auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, ClassType*, Args...>::invoke;
      |                                                                                                               ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:1740:27: note: in instantiation of function template specialization 'emscripten::internal::RegisterClassMethod<std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(const std::vector<std::vector<float>> &, bool)>::invoke<emscripten::HierarchicalNSW>' requested here
 1740 |         invoker::template invoke<ClassType, Policies...>(methodName, callable);
      |                           ^
././src/wrapper.cpp:1076:8: note: in instantiation of function template specialization 'emscripten::class_<emscripten::HierarchicalNSW>::function<emscripten::internal::DeduceArgumentsTag, std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(const std::vector<std::vector<float>> &, bool)>' requested here
 1076 |       .function("addItems", &HierarchicalNSW::addItems)
      |        ^
././src/wrapper.cpp:180:23: note: 'toWireType' declared here
  180 |       static WireType toWireType(const std::vector<T, Allocator>& vec) {
      |                       ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
././src/wrapper.cpp:181:16: error: no matching function for call to 'toWireType'
  181 |         return ValBinding::toWireType(val::array(vec));
      |                ^~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:662:51: note: in instantiation of member function 'emscripten::internal::BindingType<std::vector<unsigned int>>::toWireType' requested here
  662 |         return internal::BindingType<ReturnType>::toWireType(
      |                                                   ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:1452:111: note: in instantiation of member function 'emscripten::internal::MethodInvoker<emscripten::internal::rvp::default_tag, std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(const std::vector<std::vector<float>> &, bool), std::vector<unsigned int>, emscripten::HierarchicalNSW *, const std::vector<std::vector<float>> &, bool>::invoke' requested here
 1452 |         auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, ClassType*, Args...>::invoke;
      |                                                                                                               ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:1740:27: note: in instantiation of function template specialization 'emscripten::internal::RegisterClassMethod<std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(const std::vector<std::vector<float>> &, bool)>::invoke<emscripten::HierarchicalNSW>' requested here
 1740 |         invoker::template invoke<ClassType, Policies...>(methodName, callable);
      |                           ^
././src/wrapper.cpp:1076:8: note: in instantiation of function template specialization 'emscripten::class_<emscripten::HierarchicalNSW>::function<emscripten::internal::DeduceArgumentsTag, std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(const std::vector<std::vector<float>> &, bool)>' requested here
 1076 |       .function("addItems", &HierarchicalNSW::addItems)
      |        ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/val.h:809:19: note: candidate function not viable: requires 2 arguments, but 1 was provided
  809 |   static WireType toWireType(val&& v, rvp::default_tag) {
      |                   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/val.h:815:19: note: candidate function not viable: requires 2 arguments, but 1 was provided
  815 |   static WireType toWireType(const val& v, rvp::default_tag) {
      |                   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ././src/wrapper.cpp:6:
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:667:13: error: too many arguments to function call, expected single argument 'vec', have 2 arguments
  662 |         return internal::BindingType<ReturnType>::toWireType(
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663 |             (internal::BindingType<ThisType>::fromWireType(wireThis)->*method)(
  664 |                 internal::BindingType<Args>::fromWireType(args)...
  665 |             )
  666 |             ,
  667 |             ReturnPolicy{}
      |             ^~~~~~~~~~~~~~
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:1452:111: note: in instantiation of member function 'emscripten::internal::MethodInvoker<emscripten::internal::rvp::default_tag, std::vector<unsigned int> (emscripten::HierarchicalNSW::*)(), std::vector<unsigned int>, emscripten::HierarchicalNSW *>::invoke' requested here
 1452 |         auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, ClassType*, Args...>::invoke;
      |                                                                                                               ^
/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot/include/emscripten/bind.h:1740:27: note: in instantiation of function template specialization 'emscripten::internal::RegisterClassMethod<std::vector<unsigned int> (emscripten::HierarchicalNSW::*)()>::invoke<emscripten::HierarchicalNSW>' requested here
 1740 |         invoker::template invoke<ClassType, Policies...>(methodName, callable);
      |                           ^
././src/wrapper.cpp:1077:8: note: in instantiation of function template specialization 'emscripten::class_<emscripten::HierarchicalNSW>::function<emscripten::internal::DeduceArgumentsTag, std::vector<unsigned int> (emscripten::HierarchicalNSW::*)()>' requested here
 1077 |       .function("getUsedLabels", &HierarchicalNSW::getUsedLabels)
      |        ^
././src/wrapper.cpp:180:23: note: 'toWireType' declared here
  180 |       static WireType toWireType(const std::vector<T, Allocator>& vec) {
      |                       ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.
em++: error: '/opt/homebrew/Cellar/emscripten/3.1.61/libexec/llvm/bin/clang++ -target wasm32-unknown-emscripten -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr --sysroot=/opt/homebrew/Cellar/emscripten/3.1.61/libexec/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O3 -fwasm-exceptions -g -I././src/hnswlib ././src/wrapper.cpp -c -o /var/folders/2r/wm98mb7x1ms1bng9qjxt71q40000gn/T/emscripten_temp_56liivkk/wrapper_0.o' failed (returned 1)
make: *** [lib/hnswlib] Error 1
Jonarod commented 1 month ago
emcc -v
# emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.61-git
# clang version 19.0.0git
# Target: wasm32-unknown-emscripten
# Thread model: posix
# InstalledDir: /opt/homebrew/Cellar/emscripten/3.1.61/libexec/llvm/bin