Skip to content

Commit

Permalink
[config] improve cputype detection
Browse files Browse the repository at this point in the history
set proper amd64 on darwin with Intel Core cpu.
fix the _parse_cpuinfo() call in auto::arch
honor simple -m64/-m32 with x86
  • Loading branch information
Reini Urban committed Nov 7, 2014
1 parent 55fa37e commit 55f261b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions config/auto/arch.pm
@@ -1,4 +1,4 @@
# Copyright (C) 2001-2013, Parrot Foundation.
# Copyright (C) 2001-2014, Parrot Foundation.

=head1 NAME
Expand Down Expand Up @@ -67,7 +67,7 @@ sub runstep {
$osname = 'darwin';
$cpuarch = ( $self->{unamep} eq 'powerpc' )
? 'ppc'
: 'i386';
: 'x86';
}

# cpuarch and osname are reversed in archname on windows
Expand All @@ -76,7 +76,7 @@ sub runstep {
$osname = 'MSWin32';
}
elsif ( $osname =~ /cygwin/i || $cpuarch =~ /cygwin/i ) {
$cpuarch = 'i386';
$cpuarch = 'x86'; # 64 how?
$osname = 'cygwin';
}
elsif ( $osname =~ /msys/i || $cpuarch =~ /msys/i ) {
Expand Down Expand Up @@ -108,18 +108,27 @@ sub runstep {
$cpuarch =~ s/i[456]86/i386/i;
$cpuarch =~ s/x86_64/amd64/i;
$cpuarch =~ s/x86/i386/i;
if ($conf->options->get('m')) {
if ($conf->options->get('m') eq '64' and $cpuarch eq 'i386') {
$cpuarch = 'amd64';
}
elsif ($conf->options->get('m') eq '32' and $cpuarch eq 'amd64') {
$cpuarch = 'i386';
}
}

my $cpu_type = "unknown";
eval {
if ( -e '/proc/cpuinfo' ) {
$cpu_type = _parse_cpuinfo('cat /proc/cpuinfo',
qr/model name\s+:/);
} elsif ($^O eq 'solaris' and -x '/usr/bin/kstat') {
$cpu_type = _cpu_type('/usr/bin/kstat -m cpu_info',
qr/brand/);
$cpu_type = _parse_cpuinfo('/usr/bin/kstat -m cpu_info',
qr/brand/);
} elsif ($^O eq 'darwin' and -x '/usr/sbin/system_profiler') {
$cpu_type = _cpu_type('/usr/sbin/system_profiler SPHardwareDataType',
qr/Processor Name:/i);
$cpu_type = _parse_cpuinfo('/usr/sbin/system_profiler SPHardwareDataType',
qr/Processor Name:/i);
$cpuarch = 'amd64' if $cpu_type =~ /^Intel Core/;
} elsif ($^O eq 'MSWin32' and defined $ENV{PROCESSOR_IDENTIFIER}) {
$cpu_type = $ENV{PROCESSOR_IDENTIFIER};
}
Expand Down

0 comments on commit 55f261b

Please sign in to comment.