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

process.arch not matching with systems arch output for ARM #9491

Closed
Regaddi opened this issue Nov 6, 2016 · 15 comments
Closed

process.arch not matching with systems arch output for ARM #9491

Regaddi opened this issue Nov 6, 2016 · 15 comments
Labels
arm Issues and PRs related to the ARM platform. feature request Issues that request new features to be added to Node.js. os Issues and PRs related to the os subsystem.

Comments

@Regaddi
Copy link

Regaddi commented Nov 6, 2016

  • Version: v6.9.1
  • Platform: Linux jessie 3.4.0-g9e59eab deps: update openssl to 1.0.1j #1 SMP PREEMPT Tue Nov 1 00:35:37 UTC 2016 armv7l GNU/Linux
  • Subsystem: Debian jessie, armv7l

When calling process.arch it returns 'arm', which is not the expected output. I'd expect process.arch to return the exact same value as uname or arch on my linux system returns.

However I found out, that process.config.variables.arm_version returns the correct ARM version.
But anyway: when handling with specific ARM versions, it would be helpful, if process.arch returned the correct architecture value, as arch does.

Console output:

$ node
> process.arch
'arm'
> process.config.variables.arm_version
'7'
> .exit
$ uname -m
armv7l
$ arch
armv7l

This problem occured for me first, when trying to build Atom with electron-packager for my ARMv7 Debian Jessie system.

Related issues:

electron/packager#523
atom/atom#5584

@addaleax addaleax added process Issues and PRs related to the process subsystem. arm Issues and PRs related to the ARM platform. labels Nov 6, 2016
@mscdex
Copy link
Contributor

mscdex commented Nov 6, 2016

process.arch exists to provide a normalized architecture value. If you want the information provided by uname, then there would probably need to be a new os module function that returns the machine value from the struct utsname on *nix.

One problem with that though is Windows. While it has a GetSystemInfo() that returns a structure containing processor architecture, they're not string values. Also the ARM value is generic, so there is no indicator whether it's ARMv7, ARMv8, etc. (unlike uname which does provide such information).

@Regaddi
Copy link
Author

Regaddi commented Nov 6, 2016

I think this is still necessary. When it comes to build tasks, there are slight differences between ARM versions and you need (in best case) an integrated way to check for specific ARM versions.

So this might be some sort of feature request.

@mscdex mscdex added os Issues and PRs related to the os subsystem. feature request Issues that request new features to be added to Node.js. and removed arm Issues and PRs related to the ARM platform. process Issues and PRs related to the process subsystem. labels Nov 6, 2016
@rvagg
Copy link
Member

rvagg commented Nov 8, 2016

process.arch isn't going to change from 'arm', that would break existing uses too hard, process.config.variables.arm_version exists and is already being used in the ecosystem for this kind of thing.

$ node -p 'process.arch + "v" + process.config.variables.arm_version'
armv7

@XadillaX
Copy link
Contributor

I think something goes wrong with arm_version.

This is under my Raspberry Pi 3:

$ uname -m
armv7l
$ node -p "process.config.variables.arm_version"
6

@addaleax addaleax added the arm Issues and PRs related to the ARM platform. label Jun 16, 2017
@XadillaX
Copy link
Contributor

I think its because of this:

$ echo '\n' | gcc -dM -E - | grep __ARM_ARCH
#define __ARM_ARCH_ISA_ARM 1
#define __ARM_ARCH_6__ 1
#define __ARM_ARCH_ISA_THUMB 1
#define __ARM_ARCH 6

and refers to https://github.com/nodejs/node/blob/master/configure#L650-L685

@silverwind
Copy link
Contributor

silverwind commented Jun 16, 2017

Looking fine on my RPi3 (using Arch Linux ARM):

$ uname -m
armv7l
$ node -p "process.config.variables.arm_version"
7
$ echo '\n' | gcc -dM -E - | grep __ARM_ARCH
27:#define __ARM_ARCH_ISA_ARM 1
245:#define __ARM_ARCH_PROFILE 65
292:#define __ARM_ARCH_ISA_THUMB 2
294:#define __ARM_ARCH 7
347:#define __ARM_ARCH_7A__ 1

@XadillaX
Copy link
Contributor

XadillaX commented Jun 16, 2017

I think it's due to gcc. The arm version can't be gotten from gcc.

@silverwind
Copy link
Contributor

Maybe it's because your binary was built on armv6?

@XadillaX
Copy link
Contributor

XadillaX commented Jun 16, 2017

I'm not sure. GCC is installed at the very beginning in the image of Raspbian.

@silverwind
Copy link
Contributor

What does /proc/cpuinfo show? Here's mine:

processor	: 0
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 38.40
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

@XadillaX
Copy link
Contributor

@silverwind same with yours. Mine is RPi3 too.

@silverwind
Copy link
Contributor

Weird, I have no idea except that maybe gcc is out of date.

@bnoordhuis
Copy link
Member

Raspbian is ARMv6+VFP2. ARMv7+ binaries don't work on it, as far as I'm aware; install Debian/armhf for that.

@XadillaX
Copy link
Contributor

@silverwind I think so too. So my suggestion is that we can't get arm version from GCC.

@bnoordhuis
Copy link
Member

I'll close this out. Per the discussion, there is no support for changing process.arch.

The process.config.variables.arm_version thing is being tracked in nodejs/build#897.

BurningEnlightenment added a commit to adessoSE/node-api-prebuilts that referenced this issue May 10, 2023
The node `process.arch` variable doesn't differentiate between armv6 or
armv7. Therefore we need to additionally consult
`process.config.variables.arm_version` when computing the host triplet.

See nodejs/node#9491

BREAKING CHANGE: The library won't find arm prebuilts from previous
                 alphas unless the package is rebuilt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm Issues and PRs related to the ARM platform. feature request Issues that request new features to be added to Node.js. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

No branches or pull requests

7 participants