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

Outdated list of architectures for process.arch? #41900

Closed
evanw opened this issue Feb 9, 2022 · 7 comments
Closed

Outdated list of architectures for process.arch? #41900

evanw opened this issue Feb 9, 2022 · 7 comments
Labels
doc Issues and PRs related to the documentations. process Issues and PRs related to the process subsystem.

Comments

@evanw
Copy link

evanw commented Feb 9, 2022

Affected URL(s)

https://nodejs.org/api/process.html

Description of the problem

I'm trying to figure out which architectures node supports since I publish binary executables esbuild for various platforms. The documentation says this:

process.arch

The operating system CPU architecture for which the Node.js binary was compiled. Possible values are: 'arm', 'arm64', 'ia32', 'mips','mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.

However, the code says this:

valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc',
              'ppc64', 'x32','x64', 'x86', 'x86_64', 's390x', 'riscv64',
              'loong64')

These are the differences:

 arm
 arm64
 ia32
+loong64
 mips
+mips64el
 mipsel
 ppc
 ppc64
+riscv64
-s390
 s390x
 x32
 x64
+x86_64
+x86

Is the documentation outdated? Are all architectures in that code officially supported by node, or only some of them?

@evanw evanw added the doc Issues and PRs related to the documentations. label Feb 9, 2022
@VoltrexKeyva VoltrexKeyva added the process Issues and PRs related to the process subsystem. label Feb 9, 2022
@mscdex
Copy link
Contributor

mscdex commented Feb 9, 2022

Related: #40576

Also: the x86 and x86_64 are not the values that end up in process.arch, they get changed to ia32 and x64 respectively.

@mhdawson
Copy link
Member

Is the documentation outdated? Are all architectures in that code officially supported by node, or only some of them?

Not all architectures in the code are officially supported. The project will accept code for architectures, but that does not mean they are fully supported. This page explains the support levels - https://github.com/nodejs/node/blob/master/BUILDING.md#supported-platforms

Having said that, process.arch does not necessarily related to being supported or not, only what the binary you are running was build for. We could update the docs, or possibly re-write so that it says some examples are x,y,z so it would not have to be updated when an architecture is added. I'd prefer we update the doc to list everything that is now possible.

@loretoparisi
Copy link

@evanw @mhdawson on Apple Silicons I get

node -e "console.log(process.arch)"
x64

while it should be arm64. Is it correct?

@targos
Copy link
Member

targos commented Apr 29, 2022

@loretoparisi That's probably because you are running the x64 version of Node.js with Rosetta 2.

@loretoparisi
Copy link

@targos ah indeed! Which version I have to install then on apple silicon? I though I did in the usual way. Thanks!

@loretoparisi
Copy link

loretoparisi commented Apr 29, 2022

So assumed that I install a fresh node under a arm64 like described here, if one switches to x64 using

arch -x86_64 zsh

you will come out with

$ node -p process.arch
x64

anyways! So a safer way to check if we are on a Apple Silicon despite of arch switch should be

const os = require('os')
let cpuCore = os.cpus()
let isIntel = cpuCore[0].model.includes("Intel")
let isM1 = cpuCore[0].model.includes("Apple")

@bnoordhuis
Copy link
Member

Seems like this was a question that's been answered. Closing but LMK if I should reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

No branches or pull requests

7 participants