The Wayback Machine - https://web.archive.org/web/20201117093522/https://github.com/vercel/pkg-fetch/pull/106
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

Improve ARM architecture detection: arm64 and armv7 #106

Open
wants to merge 1 commit into
base: master
from

Conversation

@pdcastro
Copy link

@pdcastro pdcastro commented Oct 14, 2020

When running pkg in a Docker Desktop ARM-image container on an Intel laptop, using binfmt_misc / QEMU architecture emulation, /proc/cpuinfo reports the Intel processor rather than the emulated ARM processor. The existing architecture detection then fails. Also, the existing detection code does not support arm64 (e.g. the Raspberry Pi 4), reporting armv6 instead.

if (unameOut.includes('armv7')) return 'armv7';
return '';
}

This comment has been minimized.

@pdcastro

pdcastro Oct 14, 2020
Author

It was only after writing and testing the code that I realised that there is already an open PR on the same topic: #101

I'd say that this PR (#106) is a bit more robust / conservative and complete, because:

  • It falls back to the existing /proc/cpuinfo implementation if uname is not available (however unlikely). Note that spawnSync('uname', ['-a']) does not throw an Error if uname does not exist, but sets uname.error which the code detects.
  • uname -a is a bit more robust than uname -m (thinking of all different Unix kernels out there: BSD, Solaris, Linux, even perhaps macOS...), as it does not rely on a particular field or implementation of uname.
  • The detection is case insensitive.
  • It detects arm64 (e.g. Raspberry Pi 4) in addition to armv7 (e.g. Raspberry Pi 2/3). I've tested on both!

This comment has been minimized.

@robertsLando

robertsLando Oct 15, 2020

Close this PR so :)

This comment has been minimized.

@pdcastro

pdcastro Oct 15, 2020
Author

Sorry, my writing was ambiguous (I've now edited it): I meant that this PR (#106) is better than the pre-existing one (#101). But I leave it for reviewers to decide whether they agree! :-)

This comment has been minimized.

@robertsLando

robertsLando Oct 15, 2020

Oh ok sorry I misunderstood the comment

@robertsLando
Copy link

@robertsLando robertsLando commented Oct 15, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.