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

node-gyp fails on armv7 32bit #21

Closed
renkei opened this issue Jun 22, 2021 · 15 comments
Closed

node-gyp fails on armv7 32bit #21

renkei opened this issue Jun 22, 2021 · 15 comments
Labels

Comments

@renkei
Copy link

renkei commented Jun 22, 2021

I'm on Arch Linux ARM for amv7h, 32bit.

node-gyp fails with:

[alarm@lio-sta-001 MySpiTool]$ npm install
npm ERR! code 1
npm ERR! path /home/alarm/MySpiTool/node_modules/spi-device
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/alarm/MySpiTool/node_modules/spi-device/build'
npm ERR!   CXX(target) Release/obj.target/spi/src/spi.o
npm ERR!   CXX(target) Release/obj.target/spi/src/spidevice.o
npm ERR!   CXX(target) Release/obj.target/spi/src/open.o
npm ERR!   CXX(target) Release/obj.target/spi/src/close.o
npm ERR!   CXX(target) Release/obj.target/spi/src/transfer.o
npm ERR!   CXX(target) Release/obj.target/spi/src/getoptions.o
npm ERR! make: Leaving directory '/home/alarm/MySpiTool/node_modules/spi-device/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.1.0
npm ERR! gyp info using node@14.16.0 | linux | arm
npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/alarm/MySpiTool/node_modules/spi-device/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/alarm/.cache/node-gyp/14.16.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/alarm/.cache/node-gyp/14.16.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/alarm/.cache/node-gyp/14.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/alarm/MySpiTool/node_modules/spi-device',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../../nan/nan.h:290,
npm ERR!                  from ../src/getoptions.cc:4:
npm ERR! ../../nan/nan_new.h: In instantiation of ‘typename Nan::imp::Factory<T>::return_t Nan::New(A0) [with T = v8::Uint32; A0 = long unsigned int; typename Nan::imp::Factory<T>::return_t = v8::Local<v8::Uint32>]’:
npm ERR! ../src/getoptions.cc:35:65:   required from here
npm ERR! ../../nan/nan_new.h:208:30: error: call of overloaded ‘New(long unsigned int&)’ is ambiguous
npm ERR!   208 |   return imp::Factory<T>::New(arg0);
npm ERR!       |          ~~~~~~~~~~~~~~~~~~~~^~~~~~
npm ERR! In file included from ../../nan/nan_new.h:189,
npm ERR!                  from ../../nan/nan.h:290,
npm ERR!                  from ../src/getoptions.cc:4:
npm ERR! ../../nan/nan_implementation_12_inl.h:177:1: note: candidate: ‘static Nan::imp::FactoryBase<v8::Uint32>::return_t Nan::imp::Factory<v8::Uint32>::New(int32_t)’
npm ERR!   177 | Factory<v8::Uint32>::New(int32_t value) {
npm ERR!       | ^~~~~~~~~~~~~~~~~~~
npm ERR! ../../nan/nan_implementation_12_inl.h:183:1: note: candidate: ‘static Nan::imp::FactoryBase<v8::Uint32>::return_t Nan::imp::Factory<v8::Uint32>::New(uint32_t)’
npm ERR!   183 | Factory<v8::Uint32>::New(uint32_t value) {
npm ERR!       | ^~~~~~~~~~~~~~~~~~~
npm ERR! make: *** [spi.target.mk:115: Release/obj.target/spi/src/getoptions.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Linux 5.10.44-1-ARCH
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/alarm/MySpiTool/node_modules/spi-device
npm ERR! gyp ERR! node -v v14.16.0
npm ERR! gyp ERR! node-gyp -v v8.1.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alarm/.npm/_logs/2021-06-22T13_17_31_561Z-debug.log

Runs fine on Ach Linux ARM for armv8/aarch64, 64bit.
Any ideas howto solve the error call of overloaded ‘New(long unsigned int&)’ is ambiguous?

@fivdi
Copy link
Owner

fivdi commented Jun 22, 2021

Unfortunately, I can't reproduce the error on the latest version of Raspberry Pi OS with Node.js v14.16.0 and gcc v8.3.0.

pi@raspberrypi:~/spi-device $ node --version
v14.16.0
pi@raspberrypi:~/spi-device $ gcc --version
gcc (Raspbian 8.3.0-6+rpi1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pi@raspberrypi:~/spi-device $ uname -a
Linux raspberrypi 5.10.17-v7l+ #1414 SMP Fri Apr 30 13:20:47 BST 2021 armv7l GNU/Linux
pi@raspberrypi:~/spi-device $ npm install spi-device

> spi-device@3.1.1 install /home/pi/spi-device/node_modules/spi-device
> node-gyp rebuild

make: Entering directory '/home/pi/spi-device/node_modules/spi-device/build'
  CXX(target) Release/obj.target/spi/src/spi.o
  CXX(target) Release/obj.target/spi/src/spidevice.o
  CXX(target) Release/obj.target/spi/src/open.o
  CXX(target) Release/obj.target/spi/src/close.o
  CXX(target) Release/obj.target/spi/src/transfer.o
  CXX(target) Release/obj.target/spi/src/getoptions.o
  CXX(target) Release/obj.target/spi/src/setoptions.o
  SOLINK_MODULE(target) Release/obj.target/spi.node
  COPY Release/spi.node
make: Leaving directory '/home/pi/spi-device/node_modules/spi-device/build'
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/spi-device/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/spi-device/package.json'
npm WARN spi-device No description
npm WARN spi-device No repository field.
npm WARN spi-device No README data
npm WARN spi-device No license field.

+ spi-device@3.1.1
added 4 packages from 9 contributors and audited 4 packages in 18.479s
found 0 vulnerabilities

pi@raspberrypi:~/spi-device $ 

Please answer the following questions:

What version of spi-device is being used? It should be possible to see this in "node_modules/spi-device/package.json".
What version of gcc is being used?

@fivdi
Copy link
Owner

fivdi commented Jun 22, 2021

Also, if you run the command "npm install spi-device" in an empty directory, does it work?

@renkei
Copy link
Author

renkei commented Jun 22, 2021

I'm using spi-device 3.1.1. It also happens in an empty directory. It always worked in the past for both, armv7 32bit and armv8 64bit. After an update of Arch Linux ARM npm install fails for getoptions.o on armv7 32bit now. It's a rolling release distribution with updates all the time, so I'm not 100% sure when it exactly happened. It is also difficult to remember because after each system update everything worked as expected, so the already built spi-device module worked without issues. Only when I had to compile the spi-device module again I run into this issue. So, yes, it could be related to an gcc update.

gcc version is actually 10.2.0.

@renkei
Copy link
Author

renkei commented Jun 22, 2021

The longer I think about this the more I believe that the update from gcc 9.3.0 to 10.2.0 was the one that introduced this issue for spi-device. But again, I'm not 100% sure.

@fivdi
Copy link
Owner

fivdi commented Jun 22, 2021

Does it work if this line:

    Nan::New<v8::Uint32>(spiOptions.mode & (SPI_CPOL | SPI_CPHA))

is changed to this:

    Nan::New<v8::Uint32>(static_cast<uint32_t>(spiOptions.mode & (SPI_CPOL | SPI_CPHA)))

@Flummi
Copy link

Flummi commented Jun 23, 2021

Does it work if this line:
[...]
is changed to this:

    Nan::New<v8::Uint32>(static_cast<uint32_t>(spiOptions.mode & (SPI_CPOL | SPI_CPHA)))

yes, this works fine.
(gcc 10.2.1 aarch64 @ odroid c2)

@fivdi
Copy link
Owner

fivdi commented Jun 23, 2021

yes, this works fine.
(gcc 10.2.1 aarch64 @ odroid c2)

The issue reported by @renkei was for Arch Linux ARM for amv7h, 32bit

@Flummi Are you also having the same issue on aarch64 @ odroid c2 with gcc 10.2.1?

@Flummi
Copy link

Flummi commented Jun 23, 2021

oh, I forgot to mention that it didn't work for me either.
gcc 7, 8, 9, 10, i tried everything. :D

@fivdi
Copy link
Owner

fivdi commented Jun 23, 2021

Ok, thanks for the information. I don't quite understand why it didn't work with gcc 8 which works for me.

@fivdi
Copy link
Owner

fivdi commented Jun 23, 2021

Ok, thanks for the information. I don't quite understand why it didn't work with gcc 8 which works for me.

@Flummi On the other hand, your using aarch64 @ odroid c2. I used 32-bit Raspberry Pi OS. This may explain the difference.

@Flummi
Copy link

Flummi commented Jun 23, 2021

Ok, thanks for the information. I don't quite understand why it didn't work with gcc 8 which works for me.

@Flummi On the other hand, your using aarch64 @ odroid c2. I used 32-bit Raspberry Pi OS.

true. maybe an error only with aarch64. (I got the same error as @renkei)

edit: nevermind.. I've no clue.

@renkei
Copy link
Author

renkei commented Jun 23, 2021

To be clear, on aarch64 there is no error. I've got it only on armv7, 32bit.

Now, I've cloned this repo and run npm install on master branch on armv7, 32bit. It fails with exactly the same error, as expected. I've added the static cast as mentioned by fivdi and called npm install again. Now it works!

Please, can you create a bugfix release 3.1.2? I don't expect any side-effects by this patch and it should work properly on all platforms.

@fivdi
Copy link
Owner

fivdi commented Jun 23, 2021

Please, can you create a bugfix release 3.1.2?

Yes, I'll do that in the coming days. It shouldn't take too long.

@fivdi fivdi added the bug label Jun 23, 2021
@fivdi
Copy link
Owner

fivdi commented Jun 23, 2021

This issue has been fixed and the fix is available with spi-device@3.1.2 which has been published on npm.

@fivdi fivdi closed this as completed Jun 23, 2021
@fivdi
Copy link
Owner

fivdi commented Jun 23, 2021

@renkei @Flummi Thank you for the feedback and for helping to make spi-device better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants