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

Nix Shell returns arm64 processor architecture on M1 Mac #147914

Closed
jakubgs opened this issue Nov 29, 2021 · 6 comments
Closed

Nix Shell returns arm64 processor architecture on M1 Mac #147914

jakubgs opened this issue Nov 29, 2021 · 6 comments
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin

Comments

@jakubgs
Copy link
Contributor

jakubgs commented Nov 29, 2021

Describe the bug

I've discovered that the results of uname -p are different in Nix shell compared to all other shells:

[nix-shell:~]$ uname -p
arm64
[nix-shell:~]$ uname -m
arm64

I do not know if this behavior is not causing other issues in other places.

Steps To Reproduce

  1. Run Nix on 5th Gen Mac Mini with Apple Silicon M1 CPU
  2. Open nix-shell of any kind
  3. Check output of uname -p

Expected behavior

I'm not 100% sure if the correct behavior is to show arm when uname -p is called, but this is what other shells do:

Env uname -p uname -m
/bin/bash arm arm64
/bin/zsh arm arm64
/opt/homebrew/bin/zsh arm arm64
nix-shell arm64 arm64

Additional context

Discovered while trying to resolve build issues with SQLCipher for our application in status-im/status-mobile#12799.
This is causing a build failure for SQLCipher because the configure script expects arm instead of arm64.
I have already opened an issue for that: sqlcipher/sqlcipher#413

Notify maintainers

Not sure who...

Metadata

 - system: `"aarch64-darwin"`
 - host os: `Darwin 20.6.0, macOS 11.6`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.16`
 - channels(jenkins): `"nixpkgs-21.11pre333180.98747f27ecf"`
 - nixpkgs: `/Users/jenkins/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@jakubgs
Copy link
Contributor Author

jakubgs commented Nov 29, 2021

According to this issue this is normal on M1 machines:

I can reproduce what you are seeing on our Macs on 11.2.3 and 11.3.1 - we get arm64 / arm / arm64 reliably back despite different shells and homebrew (or lack thereof) setups on each.

https://apple.stackexchange.com/questions/420452/running-uname-m-gives-x86-64-on-m1-mac-mini

@jakubgs
Copy link
Contributor Author

jakubgs commented Nov 29, 2021

Apparently current version of config.guess from GNU Config repo because it includes the following fix.

Thanks to that the architecture reported is aarch64-apple-darwin20.6.0 instead of arm64-apple-darwin20.6.0.

This might be able to fix my issue if such updated config.guess is used, but the return value from uname -p might still be an issue for other software and build setups.

@jakubgs
Copy link
Contributor Author

jakubgs commented Dec 2, 2021

My fix for SQLCipher was rejected. Seems to me like this needs to be fixed in the Nix shell itself and how it reports the processor architecture.

Based on contributions in #95903 I'm going to ping @domenkozar and @kloenk.

@autc04
Copy link

autc04 commented Dec 5, 2021

Apparently, this is a difference between GNU coreutils' uname and Apple's uname.

@jakubgs
Copy link
Contributor Author

jakubgs commented Dec 6, 2021

Oh yeah, @autc04 you're right, if I try the uname provided by Homebrew returns arm:

 > uname -m
arm64
 > uname -p 
arm
 > /opt/homebrew//Cellar/coreutils/9.0/bin/guname -m
arm64
 > /opt/homebrew//Cellar/coreutils/9.0/bin/guname -p
arm64

So this might actually be an issue with coreutils from GNU. I'll take a look at their bugs list.

@jakubgs
Copy link
Contributor Author

jakubgs commented Dec 9, 2021

Thanks to help from Paul Eggert we now have a patch in GNU Coreutils that fixes this:

Thanks @autc04 for suggesting this might be specific to coreutils. When this gets into a release is anybody's guess.

@jakubgs jakubgs closed this as completed Dec 9, 2021
HerrSpace added a commit to HerrSpace/nixpkgs that referenced this issue Dec 21, 2021
Until a recent patch in coreutils, gnus uname -p returned a different
arch on apple silicon macs, compared to the uname shipped with macos.
This causes config.guess to produce incorrect build system triplets
for various projects on these systems when in a nix-shell.[23][42]

As coreutils only releases every few months/years and no release is
planned at the moment, I'm introducing the patch here. We can drop it
once the next coreutils version is released.

I made a tiny adjustment to the patch from [23]. I removed the usage
of MAYBE_UNUSED, which currently only compiles against HEAD.

[23] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52330
[42] NixOS#147914
happysalada pushed a commit that referenced this issue Dec 22, 2021
Until a recent patch in coreutils, gnus uname -p returned a different
arch on apple silicon macs, compared to the uname shipped with macos.
This causes config.guess to produce incorrect build system triplets
for various projects on these systems when in a nix-shell.[23][42]

As coreutils only releases every few months/years and no release is
planned at the moment, I'm introducing the patch here. We can drop it
once the next coreutils version is released.

I made a tiny adjustment to the patch from [23]. I removed the usage
of MAYBE_UNUSED, which currently only compiles against HEAD.

[23] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52330
[42] #147914
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

No branches or pull requests

3 participants