nodejs / nodejs/node-gyp

Compiled node module can not be executed on Apple M1

Open
#2,391 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Arm macOS nodejs/nan
Dominant language
Python
Stars
10.7k
Forks
1.9k
Avg merge
1d 4h
Merged PRs (30d)
5

Description

  • Node Version: v14.16.1
  • Platform: Darwin RobbiedeAir 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101 arm64
  • Compiler: Apple clang version 12.0.5 (clang-1205.0.22.9)
    Target: arm64-apple-darwin20.4.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  • Module: node-usb-detection
Verbose output (from npm or node-gyp):
robbiewu@RobbiedeAir node-usb-detection-4.11.0 % node-gyp rebuild --python /usr/bin/python3 --target=12.0.4 --dist-url=https://electronjs.org/headers --verbose
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/opt/homebrew/Cellar/node@14/14.16.1_1/bin/node',
gyp verb cli   '/opt/homebrew/bin/node-gyp',
gyp verb cli   'rebuild',
gyp verb cli   '--python',
gyp verb cli   '/usr/bin/python3',
gyp verb cli   '--target=12.0.4',
gyp verb cli   '--dist-url=https://electronjs.org/headers',
gyp verb cli   '--verbose'
gyp verb cli ]
gyp info using node-gyp@8.0.0
gyp info using node@14.16.1 | darwin | arm64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb download using dist-url https://electronjs.org/headers
gyp verb find Python checking Python explicitly set from command line or npm configuration
gyp verb find Python - "--python=" or "npm config get python" is "/usr/bin/python3"
gyp verb find Python - executing "/usr/bin/python3" to get executable path
gyp verb find Python - executable path is "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp verb find Python - executing "/Library/Developer/CommandLineTools/usr/bin/python3" to get version
gyp verb find Python - version is "3.8.2"
gyp info find Python using Python version 3.8.2 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp verb get node dir compiling against --target node version: 12.0.4
gyp verb command install [ '12.0.4' ]
gyp verb download using dist-url https://electronjs.org/headers
gyp verb install input version string "12.0.4"
gyp verb install installing version: 12.0.4
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 12.0.4
gyp verb build dir attempting to create "build" dir: /Users/robbiewu/Downloads/node-usb-detection-4.11.0/build
gyp verb build dir "build" dir needed to be created? /Users/robbiewu/Downloads/node-usb-detection-4.11.0/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/robbiewu/Downloads/node-usb-detection-4.11.0/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/robbiewu/Downloads/node-usb-detection-4.11.0/config.gypi
gyp verb common.gypi checking for gypi file: /Users/robbiewu/Downloads/node-usb-detection-4.11.0/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/opt/homebrew/lib/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/robbiewu/Downloads/node-usb-detection-4.11.0/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/homebrew/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/robbiewu/Library/Caches/node-gyp/12.0.4/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/robbiewu/Library/Caches/node-gyp/12.0.4',
gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/robbiewu/Library/Caches/node-gyp/12.0.4/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/robbiewu/Downloads/node-usb-detection-4.11.0',
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 verb command build []
gyp verb build type Release
gyp verb architecture arm64
gyp verb node dev dir /Users/robbiewu/Library/Caches/node-gyp/12.0.4
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
  c++ -o Release/obj.target/detection/src/detection.o ../src/detection.cpp '-DNODE_GYP_MODULE_NAME=detection' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DV8_COMPRESS_POINTERS' '-DV8_31BIT_SMIS_ON_64BIT_ARCH' '-DV8_REVERSE_JSARGS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' '-DNDEBUG' -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/include/node -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/src -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/openssl/config -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/openssl/openssl/include -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/uv/include -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/zlib -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/v8/include -I../node_modules/nan  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/detection/src/detection.o.d.raw -I/opt/homebrew/opt/node@14/include  -c
In file included from ../src/detection.cpp:1:
In file included from ../src/detection.h:15:
../src/deviceList.h:7:15: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
typedef struct {
              ^
               ListResultItem_t
../src/deviceList.h:8:2: note: type is not C-compatible due to this member declaration
        public:
        ^~~~~~~
../src/deviceList.h:16:3: note: type is given name 'ListResultItem_t' for linkage purposes by this typedef declaration
} ListResultItem_t;
  ^
1 warning generated.
  c++ -o Release/obj.target/detection/src/deviceList.o ../src/deviceList.cpp '-DNODE_GYP_MODULE_NAME=detection' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DV8_COMPRESS_POINTERS' '-DV8_31BIT_SMIS_ON_64BIT_ARCH' '-DV8_REVERSE_JSARGS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' '-DNDEBUG' -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/include/node -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/src -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/openssl/config -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/openssl/openssl/include -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/uv/include -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/zlib -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/v8/include -I../node_modules/nan  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/detection/src/deviceList.o.d.raw -I/opt/homebrew/opt/node@14/include  -c
In file included from ../src/deviceList.cpp:5:
../src/deviceList.h:7:15: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
typedef struct {
              ^
               ListResultItem_t
../src/deviceList.h:8:2: note: type is not C-compatible due to this member declaration
        public:
        ^~~~~~~
../src/deviceList.h:16:3: note: type is given name 'ListResultItem_t' for linkage purposes by this typedef declaration
} ListResultItem_t;
  ^
1 warning generated.
  c++ -o Release/obj.target/detection/src/detection_mac.o ../src/detection_mac.cpp '-DNODE_GYP_MODULE_NAME=detection' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DV8_COMPRESS_POINTERS' '-DV8_31BIT_SMIS_ON_64BIT_ARCH' '-DV8_REVERSE_JSARGS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' '-DNDEBUG' -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/include/node -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/src -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/openssl/config -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/openssl/openssl/include -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/uv/include -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/zlib -I/Users/robbiewu/Library/Caches/node-gyp/12.0.4/deps/v8/include -I../node_modules/nan  -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/detection/src/detection_mac.o.d.raw -I/opt/homebrew/opt/node@14/include  -c
In file included from ../src/detection_mac.cpp:1:
In file included from ../src/detection.h:15:
../src/deviceList.h:7:15: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
typedef struct {
              ^
               ListResultItem_t
../src/deviceList.h:8:2: note: type is not C-compatible due to this member declaration
        public:
        ^~~~~~~
../src/deviceList.h:16:3: note: type is given name 'ListResultItem_t' for linkage purposes by this typedef declaration
} ListResultItem_t;
  ^
1 warning generated.
  c++ -bundle -undefined dynamic_lookup -Wl,-search_paths_first -mmacosx-version-min=10.13 -arch arm64 -L./Release -stdlib=libc++ -L/opt/homebrew/opt/node@14/lib -o Release/detection.node Release/obj.target/detection/src/detection.o Release/obj.target/detection/src/deviceList.o Release/obj.target/detection/src/detection_mac.o -framework IOKit
gyp info ok

But the compiled detection.node can not be executed.

Failed to open serial port /dev/cu.usbserial-0001 due to error: + Error: dlopen(/Users/robbiewu/.vscode/extensions/vsciot-vscode.vscode-arduino-0.4.2/out/node_modules/usb-detection/build/Release/detection.node, 1): no suitable image found.  Did find:
	/Users/robbiewu/.vscode/extensions/vsciot-vscode.vscode-arduino-0.4.2/out/node_modules/usb-detection/build/Release/detection.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
	/Users/robbiewu/.vscode/extensions/vsciot-vscode.vscode-arduino-0.4.2/out/node_modules/usb-detection/build/Release/detection.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported node-gyp rebuild command on the Apple M1 setup and capture the complete dlopen error, which is truncated in the issue. Read binding.gyp and the mentioned sources src/detection.cpp, src/deviceList.cpp, and src/detection_mac.cpp; done means the compiled detection.node can be loaded and executed on the reported platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, electron, node.js, python
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.