Skip to content

Commit

Permalink
Merge pull request #701 from JuliaLang/sk/macos-uname-lies
Browse files Browse the repository at this point in the history
MacOS `uname -m` can lie due to Rosetta shenanigans
  • Loading branch information
davidanthoff authored Jul 27, 2023
2 parents 998e412 + dd45084 commit 7a9b3ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions deploy/shellscript/juliaup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,19 @@ get_architecture() {
_clibtype="musl"
fi

if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
# Darwin `uname -m` lies
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
_cputype=x86_64
if [ "$_ostype" = Darwin ]; then
# Darwin `uname -m` can lie due to Rosetta shenanigans. If you manage to
# invoke a native shell binary and then a native uname binary, you can
# get the real answer, but that's hard to ensure, so instead we use
# `sysctl` (which doesn't lie) to check for the actual architecture.
if [ "$_cputype" = i386 ]; then
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
_cputype=x86_64
fi
elif [ "$_cputype" = x86_64 ]; then
if sysctl hw.optional.arm64 | grep -q ': 1'; then
_cputype=arm64
fi
fi
fi

Expand Down

0 comments on commit 7a9b3ae

Please sign in to comment.