pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/cpuflags Updated devel/cpuflags to 1.24



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b5a0f320178a
branches:  trunk
changeset: 551233:b5a0f320178a
user:      abs <abs%pkgsrc.org@localhost>
date:      Wed Dec 10 23:27:17 2008 +0000

description:
Updated devel/cpuflags to 1.24

        Add map_x86_brand_string to subr_x86 and use in NetBSD,
        Linux and Solaris to determine ARCH for Intel CPUs after PIII.
        (Still need to rework AMD CPU detection to use family and
        extended family)
        Added 'AMD K6-2 (586-class)' - thanks Brian Ginsbach
        Added 'Pentium(R) Dual-Core  CPU      E5200' - thanks Andreas Burghardt

diffstat:

 devel/cpuflags/Makefile           |   4 +-
 devel/cpuflags/files/subr_FreeBSD |   4 +-
 devel/cpuflags/files/subr_Linux   |  48 ++++++++++++++++----------------------
 devel/cpuflags/files/subr_NetBSD  |  48 ++++++++++++++++++++++++--------------
 devel/cpuflags/files/subr_SunOS   |  14 +++++++----
 devel/cpuflags/files/subr_x86     |  23 +++++++++++++++++-
 6 files changed, 85 insertions(+), 56 deletions(-)

diffs (272 lines):

diff -r 863d4b07c990 -r b5a0f320178a devel/cpuflags/Makefile
--- a/devel/cpuflags/Makefile   Wed Dec 10 23:12:43 2008 +0000
+++ b/devel/cpuflags/Makefile   Wed Dec 10 23:27:17 2008 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.129 2008/12/08 19:46:58 abs Exp $
+# $NetBSD: Makefile,v 1.130 2008/12/10 23:27:17 abs Exp $
 
-DISTNAME=      cpuflags-1.23
+DISTNAME=      cpuflags-1.24
 CATEGORIES=    devel sysutils
 MASTER_SITES=  # empty
 DISTFILES=     # empty
diff -r 863d4b07c990 -r b5a0f320178a devel/cpuflags/files/subr_FreeBSD
--- a/devel/cpuflags/files/subr_FreeBSD Wed Dec 10 23:12:43 2008 +0000
+++ b/devel/cpuflags/files/subr_FreeBSD Wed Dec 10 23:27:17 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subr_FreeBSD,v 1.2 2007/08/27 10:08:29 abs Exp $
+# $NetBSD: subr_FreeBSD,v 1.3 2008/12/10 23:27:17 abs Exp $
 
 AWK=awk
 SED=sed
@@ -38,7 +38,7 @@
        Pentium\ II*)                   ARCH='-march=pentium2'          ;;
        Intel\ Pentium\ III\ *)         ARCH='-march=pentium3'          ;;
        Intel\ Pentium\ 4\ *)           ARCH='-march=pentium4'          ;;
-       Intel\ Core2\ *)                ARCH='-march=prescott'          ;;
+       Intel\ Core2\ *)                ARCH='-march=core2'             ;;
        AMD\ Athlon\ XP*)               ARCH='-march=athlon-xp'         ;;
        AMD\ Sempron\ Processor\ *)     ARCH='-march=athlon-xp'         ;;
        # last resort:
diff -r 863d4b07c990 -r b5a0f320178a devel/cpuflags/files/subr_Linux
--- a/devel/cpuflags/files/subr_Linux   Wed Dec 10 23:12:43 2008 +0000
+++ b/devel/cpuflags/files/subr_Linux   Wed Dec 10 23:27:17 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subr_Linux,v 1.1 2007/08/20 11:21:21 abs Exp $
+# $NetBSD: subr_Linux,v 1.2 2008/12/10 23:27:17 abs Exp $
 
 AWK=awk
 SED=sed
@@ -32,37 +32,29 @@
        parisc) case $hw_model in
            "Mirage 100+")                      ARCH='-march=1.1'       ;;
        esac ;;
-       i386)                           ARCH='-march=i386'      ;;
-       i486)                           ARCH='-march=i486'      ;;
-       i586)                           ARCH='-march=pentium'   ;;
-       i686) case $hw_model in
+       i386)                                   ARCH='-march=i386'      ;;
+       i486)                                   ARCH='-march=i486'      ;;
+       i586)                                   ARCH='-march=pentium'   ;;
+       i686 | x86_64)
+       include subr_x86        # this provides map_x86_brand_string()
+       ARCH=$(map_x86_brand_string "$cpu_brand")
+       if [ -z "$ARCH" ] ; then
+       case $hw_model in
            "AMD Athlon(TM) XP "*)              ARCH='-march=athlon-xp' ;;
+           "AMD Athlon(tm) 64"*)               ARCH='-march=athlon64'  ;;
            "AMD Athlon(tm) XP"*)               ARCH='-march=athlon-xp' ;;
-           "AMD Duron(TM)")            ARCH='-march=athlon'    ;;
-           "AMD Duron(tm) ")           ARCH='-march=athlon'    ;;
-           "Pentium II (Deschutes)")   ARCH='-march=pentium2'  ;;
+           "AMD Duron(TM)")                    ARCH='-march=athlon'    ;;
+           "AMD Duron(tm) ")                   ARCH='-march=athlon'    ;;
+           "AMD Opteron(tm) Processor "*)      ARCH='-march=opteron'   ;;
+           "AMD Sempron(tm) Processor "*)      ARCH='-march=athlon-xp' ;;
+
+           # Intel PIII & earlier - later Intel handled by map_x86_brand_string
            "Celeron (Coppermine)")             ARCH='-march=pentium3'  ;;
-           "Intel(R) Pentium(R) 4 CPU "*)      ARCH='-march=pentium4'  ;;
-           "Intel(R) Pentium(R) III Mobile CPU"*) ARCH='-march=pentium3m' ;;
-           "Intel(R) Pentium(R) M processor"*) ARCH='-march=pentium3m' ;;
-           "Mobile Intel(R) Pentium(R) 4 - M "*) ARCH='-march=pentium4m' ;;
-           "Pentium III (Coppermine)") ARCH='-march=pentium3'  ;;
+           "Pentium II (Deschutes)")           ARCH='-march=pentium2'  ;;
+           "Pentium III (Coppermine)")         ARCH='-march=pentium3'  ;;
            "Pentium III (Katmai)")             ARCH='-march=pentium3'  ;;
-           "AMD Athlon(tm) 64"*)               ARCH='-march=athlon-xp' ;;
-           "AMD Opteron(tm) Processor "*)      ARCH='-march=opteron'   ;;
-           "Intel(R) Celeron(R) CPU "* | "Intel(R) Xeon(TM) CPU "*)
-               case "$feat_flags" in
-                   *" sse2 "*)
-                                           ARCH='-march=pentium4'      ;;
-               esac;;
-           "AMD Sempron(tm) Processor "*)      ARCH='-march=athlon-xp' ;;
-           "Intel(R) Core(TM)2 CPU "*) ARCH='-march=prescott'  ;;
-       esac ;;
-       x86_64) case $hw_model in
-           "AMD Sempron(tm) Processor "*)      ARCH='-march=athlon64'  ;;
-           "AMD Athlon(tm) 64"*)               ARCH='-march=athlon64'  ;;
-           "Intel(R) Core(TM)2 CPU "*) ARCH='-march=nocona'    ;;
-       esac ;;
+       esac
+       fi ;;
     esac
     echo $ARCH
     }
diff -r 863d4b07c990 -r b5a0f320178a devel/cpuflags/files/subr_NetBSD
--- a/devel/cpuflags/files/subr_NetBSD  Wed Dec 10 23:12:43 2008 +0000
+++ b/devel/cpuflags/files/subr_NetBSD  Wed Dec 10 23:27:17 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subr_NetBSD,v 1.7 2008/12/08 19:46:59 abs Exp $
+# $NetBSD: subr_NetBSD,v 1.8 2008/12/10 23:27:17 abs Exp $
 
 AWK=awk
 SED=sed
@@ -12,13 +12,14 @@
 hw.machine     : '$hw_machine'
 hw.machine_arch : '$hw_machine_arch'
 CPU            : '$cpu'
-$cpu_details
 END
+    extract_x86_cpu_vars
+    echo "$cpu_details"
     }
 
 extract_hw_details()
     {
-    hw_model=$(sysctl -n hw.model | sed 's/^  *//')
+    hw_model=$(sysctl -n hw.model | $SED 's/^  *//')
     hw_machine=$(sysctl -n hw.machine)
     hw_machine_arch=$(sysctl -n hw.machine_arch)
     if [ "$hw_machine_arch" = i386 -o "$hw_machine_arch" = x86_64 ] ; then
@@ -27,7 +28,7 @@
        else
            cpu_details="$(grep ^cpu0: /var/run/dmesg.boot)"
        fi
-       cpu=$(echo "$cpu_details"|awk '/cpu0:/{sub("cpu0: ","");print;exit}')
+       eval $(extract_x86_cpu_vars)
     fi
 
     # We're almost certainly crosscompiling
@@ -37,6 +38,23 @@
     fi
     }
 
+extract_x86_cpu_vars()
+    {
+    # Set: cpu_feature_FOO=1 for each 'FOO' feature reported
+    #      cpu_name="NAME" taken from the first cpu0: line
+    #      cpu_brand="BRAND" the CPU branding string
+    echo "$cpu_details" | $AWK -F , '
+    { if (/cpu0:/ && !n) { sub("cpu0: ",""); n=1; print "cpu_name=\""$0"\"" } }
+    /cpu0: ".*"/ { sub("[^\"]*", ""); print "cpu_brand="$0 }
+    /cpu0: features/ {
+       sub(".*<","");
+       sub(">.*","");
+       gsub("[^,A-Z0-9]","_");
+       for (i = 1; i < NR; i++) { print "cpu_feature_"$i"=1" }
+       }
+    '
+    }
+
 determine_arch()
     {
     ARCH=
@@ -91,28 +109,30 @@
        ;;
 
     i386 | x86_64)
-       case "$cpu" in
+       include subr_x86        # this provides map_x86_brand_string()
+       ARCH=$(map_x86_brand_string "$cpu_brand")
+       if [ -z "$ARCH" ] ; then
+       case "$cpu_name" in
        'AMD Athlon 64 X2 (686-class)'*)           ARCH='-march=athlon64' ;;
        'AMD Athlon 64 or Athlon 64 FX or Opteron '*) ARCH='-march=opteron' ;;
        'AMD Athlon 64 or Sempron (686-class)'*)   ARCH='-march=athlon64' ;;
        'AMD Athlon Model 4 (Thunderbird) '*)      ARCH='-march=athlon-tbird' ;;
        'AMD Dual-Core Opteron or Athlon 64 X2 '*) ARCH='-march=opteron' ;;
        'AMD Family 10h (686-class)'*)             ARCH='-march=amdfam10' ;;
+       'AMD K6-2 (586-class)'*)                   ARCH="-march=k6-2" ;;
+
+       # Intel PIII & earlier - later Intel handled by map_x86_brand_string
        'Intel (686-class)'*)                      ARCH='-march=pentiumpro' ;;
-       'Intel Celeron (686-class)'*)              ARCH='-march=pentiumpro' ;;
-       'Intel Core 2 (Merom) (686-class)'*)       ARCH='-march=core2' ;;
-       'Intel Pentium 4 (686-class)'*)            ARCH='-march=pentium4' ;;
        'Intel Pentium II (686-class)'*)           ARCH='-march=pentium2' ;;
        'Intel Pentium III (686-class)'*)          ARCH='-march=pentium3' ;;
        'Intel Pentium III (Katmai) (686-class)'*) ARCH='-march=pentium3' ;;
        'Intel Pentium III Xeon (686-class)'*)     ARCH='-march=pentium3' ;;
-       'Intel Pentium M (Dothan) (686-class)'*)   ARCH='-march=pentium-m' ;;
-       'Intel Pentium M (Yonah) (686-class)'*)    ARCH='-march=pentium-m' ;;
 
        # Fallback classes
        *'(586-class)'*)                           ARCH='-march=pentium' ;;
        *'(486-class)'*)                           ARCH='-march=i486' ;;
        esac
+       fi
        ;;
 
     m68k) case $hw_model in                               # Examples
@@ -196,14 +216,6 @@
 
     case $hw_machine_arch in
        i386 | x86_64)
-           # Set cpu_feature_FOO=1 for each 'FOO' feature reported
-           eval $(echo "$cpu_details" | awk -F , '
-           /cpu0: features/ {
-               sub(".*<","");
-               sub(">.*","");
-               gsub("[^,A-Z0-9]","_");
-               for (i = 1; i < NR; i++) { print "cpu_feature_"$i"=1" } }
-               ')
            if [ -n "$cpu_feature_SSE3" ] ; then
                FEATURES="-mfpmath=sse -msse3"
            elif [ -n "$cpu_feature_SSE2" ] ; then
diff -r 863d4b07c990 -r b5a0f320178a devel/cpuflags/files/subr_SunOS
--- a/devel/cpuflags/files/subr_SunOS   Wed Dec 10 23:12:43 2008 +0000
+++ b/devel/cpuflags/files/subr_SunOS   Wed Dec 10 23:27:17 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subr_SunOS,v 1.1 2007/08/20 11:21:21 abs Exp $
+# $NetBSD: subr_SunOS,v 1.2 2008/12/10 23:27:17 abs Exp $
 
 AWK=nawk
 SED=sed
@@ -15,7 +15,7 @@
 extract_hw_details()
     {
     hw_arch=`/usr/bin/uname -m`
-    hw_psrinfo=`psrinfo -v | $AWK 'NR==3{print}'` # Just gets the first CPU
+    hw_psrinfo=`psrinfo -pv | $AWK 'NR==3{print}'` # Just gets the first CPU
     }
 
 determine_arch()
@@ -26,9 +26,13 @@
        sun4m )                 ARCH='-mcpu=supersparc' ;;
        sun4u )                 ARCH='-mcpu=v9' ;;
        i86pc )
-           case "$hw_psrinfo" in
-               *AMD\ Opteron\(tm\)*)   ARCH="-mcpu=opteron"    ;;
-           esac
+           include subr_x86    # this provides map_x86_brand_string()
+           ARCH=$(map_x86_brand_string "$cpu_brand")
+           if [ -z "$ARCH" ] ; then
+               case "$hw_psrinfo" in
+                   *)
+               esac
+           fi
            ;;
     esac
     echo $ARCH
diff -r 863d4b07c990 -r b5a0f320178a devel/cpuflags/files/subr_x86
--- a/devel/cpuflags/files/subr_x86     Wed Dec 10 23:12:43 2008 +0000
+++ b/devel/cpuflags/files/subr_x86     Wed Dec 10 23:27:17 2008 +0000
@@ -1,4 +1,25 @@
-# $NetBSD: subr_x86,v 1.2 2007/08/27 10:09:22 abs Exp $
+# $NetBSD: subr_x86,v 1.3 2008/12/10 23:27:17 abs Exp $
+
+# Apparently the only way to reliably determine the architecture of a recent
+# Intel CPU is to use the cpu brand string - as they reused family and
+# extended family bitflags... annoying
+map_x86_brand_string()
+    {
+    case "$1" in
+       "Genuine Intel(R) CPU           T2400"*) echo '-march=core2' ;;
+       "Intel(R) Celeron(R) CPU        E1400"*) echo '-march=core2' ;;
+       "Intel(R) Celeron(R) CPU 2.40GHz")      echo '-march=pentium4' ;;
+       "Intel(R) Core(TM)2 CPU "*)             echo '-march=core2' ;;
+       "Intel(R) Core(TM)2 Duo CPU "*)         echo '-march=core2' ;;
+       "Intel(R) Core(TM)2 Quad  CPU"*)        echo '-march=core2' ;;
+       "Intel(R) Pentium(R) 4 CPU 3.00GHz")    echo '-march=prescott' ;;
+       "Intel(R) Pentium(R) D CPU "*)          echo '-march=prescott' ;;
+       "Intel(R) Xeon(R) CPU            3040"*) echo '-march=core2' ;;
+       "Intel(R) Xeon(R) CPU            3050"*) echo '-march=core2' ;;
+       "Pentium(R) Dual-Core  CPU      E5200"*) echo '-march=core2' ;;
+
+    esac
+    }
 
 flags_fixup_x86arch()
     {



Home | Main Index | Thread Index | Old Index