dachev / node-cld

Language detection for Javascript (Node). Based on the CLD2 (Compact Language Detector) library from Google.
Apache License 2.0
317 stars 55 forks source link

Compiler error on M1 Macs #66

Closed wrenger closed 3 years ago

wrenger commented 3 years ago

The std::unexpected_handler was removed in C++17:

https://github.com/dachev/node-cld/blob/626a94e7f8357ef7e0492e75b49eb35e17b9eb80/src/cld.cc#L9

This leads to compiler errors on the m1 macs (and probably also on other platforms that build with C++17 or newer). This can be easily fixed by removing that line.

Here the full error message:

$ npm install

> cld@2.7.0 install
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@17.0.1 | darwin | arm64
gyp info find Python using Python version 3.9.7 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/lars/Documents/projects/node-cld/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/lars/Library/Caches/node-gyp/17.0.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/lars/Library/Caches/node-gyp/17.0.1',
gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/lars/Library/Caches/node-gyp/17.0.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/lars/Documents/projects/node-cld',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cldutil.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cldutil_shared.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/compact_lang_det.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/compact_lang_det_hint_code.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/compact_lang_det_impl.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/debug.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/fixunicodevalue.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_entities.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_language.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_ulscript.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/getonescriptspan.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/lang_script.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/offsetmap.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/scoreonescriptspan.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/tote.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/utf8statetable.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_cjk_uni_prop_80.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_cjk_compatible.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_cjk_delta_bi_32.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_distinct_bi_0.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_quad0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_deltaocta0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_deltaoctachrome.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_distinctocta0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_distinctoctachrome.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_quadchrome_16.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_quadchrome_2.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_score_quad_octa_0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_score_quad_octa_2.o
  LIBTOOL-STATIC Release/cld-c.a
  CXX(target) Release/obj.target/cld/src/constants.o
  CXX(target) Release/obj.target/cld/src/cld.o
../src/cld.cc:10:12: error: no member named 'unexpected_handler' in namespace 'std'
using std::unexpected_handler;
      ~~~~~^
1 error generated.
make: *** [Release/obj.target/cld/src/cld.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/opt/homebrew/Cellar/node/17.0.1/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/lars/Documents/projects/node-cld
gyp ERR! node -v v17.0.1
gyp ERR! node-gyp -v v8.2.0
gyp ERR! not ok 
npm ERR! code 1
npm ERR! path /Users/lars/Documents/projects/node-cld
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild

(Macbook Air M1, Macos 11.6 20G165, Xcode 13.1)

dachev commented 3 years ago

@wrenger thanks for the heads up. I just pushed 2.7.1.