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

Failure to install on modern versions of Node.js (node-gyp compilation error from deprecated GetContents() function) #2

Closed
trinitronx opened this issue Jun 11, 2024 · 0 comments

Comments

@trinitronx
Copy link
Contributor

Related to the issue with pinning nan 2.4.0, this project fails to build on newer versions of Node.js.

The main compile error from node-gyp is related to GetContents() being deprecated in Node.js 14.

Expand for full compile log:

../qrusage.cc: In function ‘double* getFloat64ArrayPointer(unsigned int, v8::Local<v8::Value>)’:
../qrusage.cc:25:55: error: ‘class v8::ArrayBuffer’ has no member named ‘GetContents’
   25 |             double* fields = static_cast<double*>(ab->GetContents().Data());
      |                                                       ^~~~~~~~~~~

The fix can be seen in nan 2.4.1, which adds a C pre-processor directive checking for (V8_MAJOR_VERSION >= 8). If nodejs built-in V8 headers define this to be 8 or greater, then they use the new GetBackingStore() function. Otherwise, they fall back on using GetContents().

// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
// using 7.8 till 13.2.0.
#if (V8_MAJOR_VERSION >= 8)
      data = static_cast<char*>(buffer->GetBackingStore()->Data()) + byte_offset;
#else
      data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
#endif

The V8_MAJOR_VERSION definition can be found in v8-version.h from Node.js installation. Usually this is in /usr/include/node/v8-version.h.

andrasq added a commit that referenced this issue Jul 10, 2024
Fix #2: Use new v8 GetBackingStore() API when supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant