Skip to content

Commit

Permalink
Fix arch detection on Apple M1 when using the fat-packed x86_64 rakubrew
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbkr committed Nov 29, 2021
1 parent e3ac6bc commit 2754139
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -119,3 +119,6 @@
23
- Fix arch detection on Apple M1. This solves the problem of M1 users only
receiving the x86_64 builds when using the `download` command.

24
- Fix arch detection on Apple M1 when using the fat-packed x86_64 rakubrew.
6 changes: 3 additions & 3 deletions lib/App/Rakubrew/Download.pm
Expand Up @@ -135,15 +135,15 @@ sub _my_arch {
$Config{archname} =~ /amd64/i ? 'x86_64' :
$Config{archname} =~ /x86/i ? 'x86' :
$Config{archname} =~ /i686/i ? 'x86' :
$Config{archname} =~ /darwin/i && `uname -m` =~ /arm64/i ? 'arm64' : # MacOS M1 / Apple Silicon
$Config{archname} =~ /darwin/i && `uname -m` =~ /x86_64/i ? 'x86_64' : # MacOS Intel
$Config{archname} =~ /darwin/i && `sysctl -n machdep.cpu.brand_string` =~ /Apple/i ? 'arm64' : # MacOS M1 / Apple Silicon
$Config{archname} =~ /darwin/i && `sysctl -n machdep.cpu.brand_string` =~ /Intel/i ? 'x86_64' : # MacOS Intel
$Config{archname} =~ /aarch64/i ? 'arm64' : # e.g. Raspi >= 2.1 with 64bit OS
$Config{archname} =~ /arm-linux-gnueabihf/i ? 'armhf' : # e.g. Raspi >= 2, with 32bit OS
'';

unless ($arch) {
say STDERR 'Couldn\'t detect system architecture. Current arch is: ' . $Config{archname};
say STDERR 'Current uname -m is: ' . `uname -m`;
say STDERR 'Current uname -a is: ' . `uname -a`;
exit 1;
}
return $arch;
Expand Down

0 comments on commit 2754139

Please sign in to comment.