Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Won't build on node 12 #111

Closed
matburnham opened this issue Jul 26, 2020 · 4 comments · Fixed by #112
Closed

Won't build on node 12 #111

matburnham opened this issue Jul 26, 2020 · 4 comments · Fixed by #112

Comments

@matburnham
Copy link
Contributor

Shifted to Ubuntu 20.04, so thought I'd get myself up to date with Node 12 (current LTS). Then remembered I had this problem before - node-osmium won't build on Node 12 because v8 has deprecated lots of non-maybe APIs.

mat@devbox:~/dev$ git clone https://github.com/osmcode/node-osmium.git
Cloning into 'node-osmium'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 2548 (delta 4), reused 7 (delta 2), pack-reused 2534
Receiving objects: 100% (2548/2548), 604.51 KiB | 1.42 MiB/s, done.
Resolving deltas: 100% (1806/1806), done.
mat@devbox:~/dev$ cd node-osmium
mat@devbox:~/dev/node-osmium$ make
npm install node-pre-gyp
npm notice created a lockfile as package-lock.json. You should commit this file.
+ node-pre-gyp@0.10.3
added 66 packages from 25 contributors and audited 66 packages in 4.607s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

npm install `node -e "console.log(Object.keys(require('./package.json').dependencies).join(' '))"` \
`node -e "console.log(Object.keys(require('./package.json').devDependencies).join(' '))"` --clang=1
npm WARN deprecated turf-difference@2.0.0: Turf packages are now namespaced: please use @turf/difference instead
npm WARN deprecated geojson-normalize@0.0.0: This module is now under the @mapbox namespace: install @mapbox/geojson-normalize instead
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated to-iso-string@0.0.2: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
+ aws-sdk@2.720.0
+ nan@2.14.1
+ geojson-coords@0.0.0
+ turf-difference@2.0.0
+ node-pre-gyp@0.10.3
+ mocha@2.5.3
+ wellknown@0.4.2
+ osm-testdata@1.0.0
added 59 packages from 372 contributors, updated 8 packages and audited 125 packages in 9.863s

1 package is looking for funding
  run `npm fund` for details

found 9 vulnerabilities (7 low, 1 high, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
./node_modules/.bin/node-pre-gyp configure --loglevel=error --clang=1
./node_modules/.bin/node-pre-gyp build --loglevel=error --clang=1
make[1]: Entering directory '/home/mat/dev/node-osmium/build'
  CXX(target) Release/obj.target/osmium/src/apply.o
In file included from ../src/apply.cpp:6:
../node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../node_modules/nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
In file included from ../src/apply.cpp:22:
../src/utils.hpp: In function ‘v8::Local<v8::Object> node_osmium::new_external(Args&& ...)’:
../src/utils.hpp:38:13: error: ‘Handle’ is not a member of ‘v8’
   38 |         v8::Handle<v8::Value> ext = Nan::New<v8::External>(new T(std::forward<Args>(args)...));
      |             ^~~~~~
../src/utils.hpp:38:29: error: expected primary-expression before ‘>’ token
   38 |         v8::Handle<v8::Value> ext = Nan::New<v8::External>(new T(std::forward<Args>(args)...));
      |                             ^
../src/utils.hpp:38:31: error: ‘ext’ was not declared in this scope; did you mean ‘exit’?
   38 |         v8::Handle<v8::Value> ext = Nan::New<v8::External>(new T(std::forward<Args>(args)...));
      |                               ^~~
      |                               exit
../src/utils.hpp:41:68: error: no matching function for call to ‘v8::Object::ToObject()’
   41 |         return scope.Escape(maybe_local.ToLocalChecked()->ToObject());
      |                                                                    ^
In file included from /home/mat/.cache/node-gyp/12.18.3/include/node/node.h:67,
                 from ../node_modules/nan/nan.h:56,
                 from ../src/apply.cpp:6:
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2672:44: note: candidate: ‘v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const’
 2672 |   V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
      |                                            ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2672:44: note:   candidate expects 1 argument, 0 provided
In file included from /home/mat/.cache/node-gyp/12.18.3/include/node/v8-internal.h:14,
                 from /home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:27,
                 from /home/mat/.cache/node-gyp/12.18.3/include/node/node.h:67,
                 from ../node_modules/nan/nan.h:56,
                 from ../src/apply.cpp:6:
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2686:31: note: candidate: ‘v8::Local<v8::Object> v8::Value::ToObject(v8::Isolate*) const’
 2686 |                 Local<Object> ToObject(Isolate* isolate) const);
      |                               ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2686:31: note:   candidate expects 1 argument, 0 provided
 2686 |                 Local<Object> ToObject(Isolate* isolate) const);
      |                               ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
../src/apply.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE node_osmium::apply(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/apply.cpp:164:46: error: no matching function for call to ‘v8::Value::ToObject()’
  164 |                 auto obj = info[i]->ToObject();
      |                                              ^
In file included from /home/mat/.cache/node-gyp/12.18.3/include/node/node.h:67,
                 from ../node_modules/nan/nan.h:56,
                 from ../src/apply.cpp:6:
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2672:44: note: candidate: ‘v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const’
 2672 |   V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
      |                                            ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2672:44: note:   candidate expects 1 argument, 0 provided
In file included from /home/mat/.cache/node-gyp/12.18.3/include/node/v8-internal.h:14,
                 from /home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:27,
                 from /home/mat/.cache/node-gyp/12.18.3/include/node/node.h:67,
                 from ../node_modules/nan/nan.h:56,
                 from ../src/apply.cpp:6:
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2686:31: note: candidate: ‘v8::Local<v8::Object> v8::Value::ToObject(v8::Isolate*) const’
 2686 |                 Local<Object> ToObject(Isolate* isolate) const);
      |                               ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2686:31: note:   candidate expects 1 argument, 0 provided
 2686 |                 Local<Object> ToObject(Isolate* isolate) const);
      |                               ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
../src/apply.cpp:175:49: error: no matching function for call to ‘v8::Value::ToObject()’
  175 |                 auto source = info[0]->ToObject();
      |                                                 ^
In file included from /home/mat/.cache/node-gyp/12.18.3/include/node/node.h:67,
                 from ../node_modules/nan/nan.h:56,
                 from ../src/apply.cpp:6:
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2672:44: note: candidate: ‘v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const’
 2672 |   V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
      |                                            ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2672:44: note:   candidate expects 1 argument, 0 provided
In file included from /home/mat/.cache/node-gyp/12.18.3/include/node/v8-internal.h:14,
                 from /home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:27,
                 from /home/mat/.cache/node-gyp/12.18.3/include/node/node.h:67,
                 from ../node_modules/nan/nan.h:56,
                 from ../src/apply.cpp:6:
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2686:31: note: candidate: ‘v8::Local<v8::Object> v8::Value::ToObject(v8::Isolate*) const’
 2686 |                 Local<Object> ToObject(Isolate* isolate) const);
      |                               ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8.h:2686:31: note:   candidate expects 1 argument, 0 provided
 2686 |                 Local<Object> ToObject(Isolate* isolate) const);
      |                               ^~~~~~~~
/home/mat/.cache/node-gyp/12.18.3/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
make[1]: *** [osmium.target.mk:137: Release/obj.target/osmium/src/apply.o] Error 1
make[1]: Leaving directory '/home/mat/dev/node-osmium/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.0-42-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--loglevel=error" "--clang=1" "--module=/home/mat/dev/node-osmium/lib/binding/osmium.node" "--module_name=osmium" "--module_path=/home/mat/dev/node-osmium/lib/binding" "--napi_version=6" "--node_abi_napi=napi"
gyp ERR! cwd /home/mat/dev/node-osmium
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --loglevel=error --clang=1 --module=/home/mat/dev/node-osmium/lib/binding/osmium.node --module_name=osmium --module_path=/home/mat/dev/node-osmium/lib/binding --napi_version=6 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/mat/dev/node-osmium/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Linux 5.4.0-42-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/mat/dev/node-osmium/node_modules/.bin/node-pre-gyp" "build" "--loglevel=error" "--clang=1"
node-pre-gyp ERR! cwd /home/mat/dev/node-osmium
node-pre-gyp ERR! node -v v12.18.3
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --loglevel=error --clang=1 --module=/home/mat/dev/node-osmium/lib/binding/osmium.node --module_name=osmium --module_path=/home/mat/dev/node-osmium/lib/binding --napi_version=6 --node_abi_napi=napi' (1)
make: *** [Makefile:31: build-all] Error 1
mat@devbox:~/dev/node-osmium$

Appreciate there are no binaries for Node 12 (#108), but it would be nice if it compiled.

@matburnham
Copy link
Contributor Author

I had a good stab at trying to fix this in d8eb02c (no guarantees any of it works - I was trying to fix the deprecation errors before trying to actually get it to work) but got stuck with utils.hpp:

    template<class T, class... Args>
    v8::Local<v8::Object> new_external(Args&&... args) {
        Nan::EscapableHandleScope scope;
        v8::Handle<v8::Value> ext = Nan::New<v8::External>(new T(std::forward<Args>(args)...));
        Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(T::constructor)->GetFunction(), 1, &ext);
        if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Buffer instance");
        return scope.Escape(maybe_local.ToLocalChecked()->ToObject());

    }
../src/utils.hpp:39:67: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
   39 |         Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(T::constructor)->GetFunction(), 1, &ext);
      |                                                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Where might I get the context for GetFunction from?

matburnham added a commit to matburnham/node-osmium that referenced this issue Jul 28, 2020
@matburnham matburnham mentioned this issue Jul 28, 2020
@matburnham
Copy link
Contributor Author

matburnham commented Jul 28, 2020

Frustratingly I can't get rid of these repeated warnings, but nodejs/nan#878 suggests they're safe to ignore:

  CXX(target) Release/obj.target/osmium/src/apply.o
In file included from ../src/apply.cpp:6:
../node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../node_modules/nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^

@matburnham
Copy link
Contributor Author

Now builds on all but node 4, but that was already broken:

> mocha -R spec --timeout 100000
/home/travis/build/osmcode/node-osmium/node_modules/mocha/bin/mocha:13
const {deprecate} = require('../lib/utils');
      ^
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:140:18)
    at node.js:1043:3

matburnham added a commit to matburnham/node-osmium that referenced this issue Jul 28, 2020
@joto joto closed this as completed in #112 Jan 9, 2021
joto added a commit that referenced this issue Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant