dbousque / posix-semaphore

Blocking POSIX semaphores for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing to build

ezzatron opened this issue · comments

commented

I was going to try this module out, but it fails to build on my macOS Catalina machine with the following error when trying a yarn add:

error /path/to/project/node_modules/posix-semaphore: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /path/to/project/node_modules/posix-semaphore
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@15.3.0 | darwin | x64
gyp info find Python using Python version 2.7.16 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/usr/local/Cellar/node/15.3.0/libexec/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   '/path/to/project/node_modules/posix-semaphore/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/Cellar/node/15.3.0/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/erin/Library/Caches/node-gyp/15.3.0/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/erin/Library/Caches/node-gyp/15.3.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/Cellar/node/15.3.0/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/erin/Library/Caches/node-gyp/15.3.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/path/to/project/node_modules/posix-semaphore',
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/addon/srcs/semaphore.o
../srcs/semaphore.cc:25:9: warning: 'sem_getvalue' is deprecated [-Wdeprecated-declarations]
    if (sem_getvalue(this->semaphore, &sval)) sval = -1;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/semaphore.h:54:56: note: 'sem_getvalue' has been explicitly marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:187:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
../srcs/semaphore.cc:54:38: error: too few arguments to function call, single argument 'context' was not specified
  constructor.Reset(tpl->GetFunction());
                    ~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:6497:3: note: 'GetFunction' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
  ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8config.h:431:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../srcs/semaphore.cc:55:73: error: too few arguments to function call, single argument 'context' was not specified
  exports->Set(Nan::New("Semaphore").ToLocalChecked(), tpl->GetFunction());
                                                       ~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:6497:3: note: 'GetFunction' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
  ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8config.h:431:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../srcs/semaphore.cc:83:34: error: too few arguments to function call, single argument 'isolate' was not specified
  strict = info[1]->BooleanValue();
           ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:2904:3: note: 'BooleanValue' declared here
  bool BooleanValue(Isolate* isolate) const;
  ^
../srcs/semaphore.cc:84:33: error: too few arguments to function call, single argument 'isolate' was not specified
  debug = info[2]->BooleanValue();
          ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:2904:3: note: 'BooleanValue' declared here
  bool BooleanValue(Isolate* isolate) const;
  ^
../srcs/semaphore.cc:85:34: error: too few arguments to function call, single argument 'isolate' was not specified
  silent = info[3]->BooleanValue();
           ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:2904:3: note: 'BooleanValue' declared here
  bool BooleanValue(Isolate* isolate) const;
  ^
../srcs/semaphore.cc:86:42: error: too few arguments to function call, single argument 'isolate' was not specified
  retry_on_eintr = info[4]->BooleanValue();
                   ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:2904:3: note: 'BooleanValue' declared here
  bool BooleanValue(Isolate* isolate) const;
  ^
../srcs/semaphore.cc:87:58: error: too few arguments to function call, single argument 'context' was not specified
  value = !info[5]->IsUndefined()? info[5]->IntegerValue(): 1;
                                   ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:2909:3: note: 'IntegerValue' declared here
  V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
  ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8config.h:431:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../srcs/semaphore.cc:88:47: error: too few arguments to function call, single argument 'context' was not specified
  v8::String::Utf8Value str(info[0]->ToString());
                            ~~~~~~~~~~~~~~~~~ ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8.h:2856:3: note: 'ToString' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
  ^
/Users/erin/Library/Caches/node-gyp/15.3.0/include/node/v8config.h:431:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../srcs/semaphore.cc:114:9: warning: 'sem_getvalue' is deprecated [-Wdeprecated-declarations]
    if (sem_getvalue(obj->semaphore, &sval)) sval = -1;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/semaphore.h:54:56: note: 'sem_getvalue' has been explicitly marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:187:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
../srcs/semaphore.cc:144:9: warning: 'sem_getvalue' is deprecated [-Wdeprecated-declarations]
    if (sem_getvalue(obj->semaphore, &sval)) sval = -1;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/semaphore.h:54:56: note: 'sem_getvalue' has been explicitly marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:187:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
../srcs/semaphore.cc:165:9: warning: 'sem_getvalue' is deprecated [-Wdeprecated-declarations]
    if (sem_getvalue(obj->semaphore, &sval)) sval = -1;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/semaphore.h:54:56: note: 'sem_getvalue' has been explicitly marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:187:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
../srcs/semaphore.cc:180:9: warning: 'sem_getvalue' is deprecated [-Wdeprecated-declarations]
    if (sem_getvalue(obj->semaphore, &sval)) sval = -1;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/semaphore.h:54:56: note: 'sem_getvalue' has been explicitly marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:187:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
5 warnings and 8 errors generated.
make: *** [Release/obj.target/addon/srcs/semaphore.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/Cellar/node/15.3.0/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/Cellar/node/15.3.0/bin/node" "/usr/local/Cellar/node/15.3.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /path/to/project/node_modules/posix-semaphore
gyp ERR! node -v v15.3.0
gyp ERR! node-gyp -v v7.1.2

Thought you might appreciate a heads up. Let me know if you need any further info about my system.

EDIT: Updated error output after fixing macOS command line tools warnings.

Hi there, thanks for the report! Looks like it's some issue with the combination of node-gyp/nan/nodejs versions. I tried a few of the combinations I thought were working in the past, but failed to get a working build on macOS Catalina as well.

We probably need to rewrite the nodejs - C++ intercommunication glue code (currently uses nan), but I don't have time to invest in that right now, I'll let you know if that changes! You could maybe take a look at N-API if you care to, it's probably a few hours worth of investment if you don't have experience with it, probably a few tens of minutes if you do.

Hey I faced the same set of issues and managed to fix this locally for myself, going to issue a PR soon. Two things here went wrong:

  • sem_getvalue is deprecated on OSX as it doesn't support unnamed semaphores. Fortunately it was only used inside debug statements, so I removed them.
  • this lib was using some deprecated nan APIs, I updated them. This thread was helpful as I felt like nan was poorly documented.

Awesome, thanks @szymonWojdat ! Let's continue the discussion in the PR.

Thanks to you both @ezzatron and @szymonWojdat , the fixes are available in the new version 1.0.0!