bindings-cpp icon indicating copy to clipboard operation
bindings-cpp copied to clipboard

ARM version not detected for 32-bit arm versions

Open paulober opened this issue 2 years ago • 3 comments

SerialPort Bindings Version

10.7.0

Node Version

16.15.0

Electron Version

19.0.12

Platform

Linux raspberrypi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux

Architecture

ARM

Hardware or chipset of serialport

Etc

What steps will reproduce the bug?

Run a VSCode extension with serialport on a raspberry pi with the 32-bit Raspberry Pi OS.

What happens?

At runtime node-gyp-build gets "default" as the value for "armv". But actually the armv on a 32-bit Raspberry Pi 4b is 7. So the result is that it compares 6 and 7 (the two prebuild arm version) agains "default" which will of course fail! The reason for that is following line https://github.com/prebuild/node-gyp-build/blob/0078d7884dfeb0e708477b3e20bfc4f520c1e2f8/index.js#L16

var vars = (process.config && process.config.variables) || {}
.
.
.
var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || ''

What should have happened?

That the arm version is correctly detected so it can detect which prebuild is the right.

Additional information

You either have to set process.env.ARM_VERSION or ensure that process.config.variables.arm_version get overwritten to "default".

paulober avatar Nov 09 '22 22:11 paulober

I think that serialport or one of its dependency does somewhere overwrite the process.config.variables.arm_version with "default" as the normal nodejs install on this system shows "7" for process.config.variables which is correct. Or maybe VSCode or electron does overwrite it.

paulober avatar Nov 09 '22 23:11 paulober

My current patch is to replace the var armv line in node-gyp-build with following:

// ARMv7 detection patched to avoid arm_version === "default" on other arm systems than arm64 ones
var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : (arch === 'arm' ? (vars.arm_version === 'default' ? '7' : vars.arm_version) : '')) || ''

This defaults to armv7 for arm systems where the arm_version has been overwritten to "default".

Note that's not a node-gyp-build bug as it functions perfectly well if the global process.config.variables.arm_version variable would not be overwritten with "default".

paulober avatar Nov 09 '22 23:11 paulober

It's not something serialport does directly.

reconbot avatar Apr 20 '23 03:04 reconbot