Mon Dec 8 17:40:14 2008 UTC ()
Updated devel/cpuflags to 1.22

  - Updates for NetBSD:
    - Report OS version in verbose mode
    - Cleanup the parsing of "cpuctl identify 0" / "grep ^cpu0: dmesg"
    - Add cases for:
      - 'AMD Athlon 64 X2 (686-class)' - thanks Ryo HAYASAKA
      - 'Intel Pentium M (Yonah) (686-class)' - thanks Juho Juopperi
      - 'Intel Pentium III (Katmai) (686-class)'
    - Adjust '-march=core2' facllback to pentium-m - thanks Thomas E. Spanjaard
    - Pickup -'msse3'
  - Updates for gcc:
    - Add some more x86 -march cases from gcc 4.3


(abs)
diff -r1.127 -r1.128 pkgsrc/devel/cpuflags/Makefile
diff -r1.5 -r1.6 pkgsrc/devel/cpuflags/files/subr_NetBSD
diff -r1.4 -r1.5 pkgsrc/devel/cpuflags/files/subr_gcc

cvs diff -r1.127 -r1.128 pkgsrc/devel/cpuflags/Makefile (expand / switch to unified diff)

--- pkgsrc/devel/cpuflags/Makefile 2008/12/05 00:41:31 1.127
+++ pkgsrc/devel/cpuflags/Makefile 2008/12/08 17:40:14 1.128
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1# $NetBSD: Makefile,v 1.127 2008/12/05 00:41:31 abs Exp $ 1# $NetBSD: Makefile,v 1.128 2008/12/08 17:40:14 abs Exp $
2 2
3DISTNAME= cpuflags-1.21 3DISTNAME= cpuflags-1.22
4CATEGORIES= devel sysutils 4CATEGORIES= devel sysutils
5MASTER_SITES= # empty 5MASTER_SITES= # empty
6DISTFILES= # empty 6DISTFILES= # empty
7 7
8MAINTAINER= abs@NetBSD.org 8MAINTAINER= abs@NetBSD.org
9COMMENT= Determine compiler flags to best target current cpu 9COMMENT= Determine compiler flags to best target current cpu
10 10
11PKG_DESTDIR_SUPPORT= user-destdir 11PKG_DESTDIR_SUPPORT= user-destdir
12 12
13ONLY_FOR_PLATFORM= NetBSD-*-* Linux-*-* SunOS-*-* FreeBSD-*-* 13ONLY_FOR_PLATFORM= NetBSD-*-* Linux-*-* SunOS-*-* FreeBSD-*-*
14 14
15USE_LANGUAGES= # empty 15USE_LANGUAGES= # empty
16NO_CHECKSUM= yes 16NO_CHECKSUM= yes

cvs diff -r1.5 -r1.6 pkgsrc/devel/cpuflags/files/subr_NetBSD (expand / switch to unified diff)

--- pkgsrc/devel/cpuflags/files/subr_NetBSD 2008/12/05 00:41:31 1.5
+++ pkgsrc/devel/cpuflags/files/subr_NetBSD 2008/12/08 17:40:14 1.6
@@ -1,45 +1,43 @@ @@ -1,45 +1,43 @@
1# $NetBSD: subr_NetBSD,v 1.5 2008/12/05 00:41:31 abs Exp $ 1# $NetBSD: subr_NetBSD,v 1.6 2008/12/08 17:40:14 abs Exp $
2 2
3AWK=awk 3AWK=awk
4SED=sed 4SED=sed
5 5
6display_hw_details() 6display_hw_details()
7 { 7 {
8 cat <<END 8 cat <<END
9OS : '$(uname)' 9OS : '$(uname)'
 10OS version : '$(uname -r)'
10hw.model : '$hw_model' 11hw.model : '$hw_model'
11hw.machine : '$hw_machine' 12hw.machine : '$hw_machine'
12hw.machine_arch : '$hw_machine_arch' 13hw.machine_arch : '$hw_machine_arch'
13cpu details : '$cpu' 14CPU : '$cpu'
 15$cpu_details
14END 16END
15  
16 sed -n -e 's/^/ /' -e '/^ cpu/p' /var/run/dmesg.boot 
17 if [ -x /usr/sbin/cpuctl ]; then 
18 cpuctl identify 0 
19 fi 
20 } 17 }
21 18
22extract_hw_details() 19extract_hw_details()
23 { 20 {
24 hw_model=$(sysctl -n hw.model | sed 's/^ *//') 21 hw_model=$(sysctl -n hw.model | sed 's/^ *//')
25 hw_machine=$(sysctl -n hw.machine) 22 hw_machine=$(sysctl -n hw.machine)
26 hw_machine_arch=$(sysctl -n hw.machine_arch) 23 hw_machine_arch=$(sysctl -n hw.machine_arch)
27 if [ "$hw_machine_arch" = i386 -o "$hw_machine_arch" = x86_64 ] ; then 24 if [ "$hw_machine_arch" = i386 -o "$hw_machine_arch" = x86_64 ] ; then
28 if [ -x /usr/sbin/cpuctl ] ; then 25 if [ -x /usr/sbin/cpuctl ] ; then
29 cpu=$(cpuctl identify 0|awk '/cpu0:/{sub("cpu0: ","");print;exit}') 26 cpu_details="$(cpuctl identify 0 | grep ^cpu0:)"
30 else 27 else
31 cpu=$(awk '/cpu0:/{sub("cpu0: ","");print;exit}'</var/run/dmesg.boot) 28 cpu_details="$(grep ^cpu0: /var/run/dmesg.boot)"
32 fi 29 fi
 30 cpu=$(echo "$cpu_details"|awk '/cpu0:/{sub("cpu0: ","");print;exit}')
33 fi 31 fi
34 32
35 # We're almost certainly crosscompiling 33 # We're almost certainly crosscompiling
36 if [ -n "$MACHINE" -a $hw_machine != "$MACHINE" ]; then 34 if [ -n "$MACHINE" -a $hw_machine != "$MACHINE" ]; then
37 echo 35 echo
38 exit 36 exit
39 fi 37 fi
40 } 38 }
41 39
42determine_arch() 40determine_arch()
43 { 41 {
44 ARCH= 42 ARCH=
45 # When adding $hw_model tests use maximum context (such as trailing space) 43 # When adding $hw_model tests use maximum context (such as trailing space)
@@ -84,49 +82,53 @@ determine_arch() @@ -84,49 +82,53 @@ determine_arch()
84 hppa) 82 hppa)
85 case "$(egrep '^cpu0 ' /var/run/dmesg.boot)" in 83 case "$(egrep '^cpu0 ' /var/run/dmesg.boot)" in
86 *\ PA7100\ *) ARCH="-march=1.1 -mschedule=7100" ;; # untested 84 *\ PA7100\ *) ARCH="-march=1.1 -mschedule=7100" ;; # untested
87 *\ PA7150\ *) ARCH="-march=1.1 -mschedule=7100" ;; # untested 85 *\ PA7150\ *) ARCH="-march=1.1 -mschedule=7100" ;; # untested
88 *\ PA7100LC\ *) ARCH="-march=1.1 -mschedule=7100LC" ;; # untested 86 *\ PA7100LC\ *) ARCH="-march=1.1 -mschedule=7100LC" ;; # untested
89 *\ PA7200\ *) ARCH="-march=1.1 -mschedule=7200" ;; # untested 87 *\ PA7200\ *) ARCH="-march=1.1 -mschedule=7200" ;; # untested
90 *\ PA7300LC\ *) ARCH="-march=1.1 -mschedule=7300" ;; # B180L 88 *\ PA7300LC\ *) ARCH="-march=1.1 -mschedule=7300" ;; # B180L
91 *\ PA8*) ARCH="-march=2.0 -mschedule=8000" ;; # untested 89 *\ PA8*) ARCH="-march=2.0 -mschedule=8000" ;; # untested
92 esac 90 esac
93 ;; 91 ;;
94 92
95 i386 | x86_64) 93 i386 | x86_64)
96 case "$cpu" in 94 case "$cpu" in
97 'AMD Athlon 64 or Athlon 64 FX or Opteron '*) ARCH='-march=opteron' ;; 95 'AMD Athlon 64 X2 (686-class)'*) ARCH='-march=athlon64' ;;
98 'AMD Athlon 64 or Sempron (686-class)'*) ARCH='-march=athlon64' ;; 96 'AMD Athlon 64 or Athlon 64 FX or Opteron '*) ARCH='-march=opteron' ;;
99 'AMD Dual-Core Opteron or Athlon 64 X2 '*) ARCH='-march=opteron' ;; 97 'AMD Athlon 64 or Sempron (686-class)'*) ARCH='-march=athlon64' ;;
100 'AMD Athlon Model 4 (Thunderbird) '*) ARCH='-march=athlon-tbird' ;; 98 'AMD Athlon Model 4 (Thunderbird) '*) ARCH='-march=athlon-tbird' ;;
101 'Intel (686-class)'*) ARCH='-march=pentiumpro' ;; 99 'AMD Dual-Core Opteron or Athlon 64 X2 '*) ARCH='-march=opteron' ;;
102 'Intel Celeron (686-class)'*) ARCH='-march=pentiumpro' ;; 100 'Intel (686-class)'*) ARCH='-march=pentiumpro' ;;
103 'Intel Core 2 (Merom) (686-class)'*) ARCH='-march=core2' ;; 101 'Intel Celeron (686-class)'*) ARCH='-march=pentiumpro' ;;
104 'Intel Pentium 4 (686-class)'*) ARCH='-march=pentium4' ;; 102 'Intel Core 2 (Merom) (686-class)'*) ARCH='-march=core2' ;;
105 'Intel Pentium II (686-class)'*) ARCH='-march=pentium2' ;; 103 'Intel Pentium 4 (686-class)'*) ARCH='-march=pentium4' ;;
106 'Intel Pentium III (686-class)'*) ARCH='-march=pentium3' ;; 104 'Intel Pentium II (686-class)'*) ARCH='-march=pentium2' ;;
107 'Intel Pentium III Xeon (686-class)'*) ARCH='-march=pentium3' ;; 105 'Intel Pentium III (686-class)'*) ARCH='-march=pentium3' ;;
108 'Intel Pentium M (Dothan) (686-class)'*) ARCH='-march=pentium-m' ;; 106 'Intel Pentium III (Katmai) (686-class)'*) ARCH='-march=pentium3' ;;
109 # Fallback classes 107 'Intel Pentium III Xeon (686-class)'*) ARCH='-march=pentium3' ;;
110 *'(586-class)'*) ARCH='-march=pentium' ;; 108 'Intel Pentium M (Dothan) (686-class)'*) ARCH='-march=pentium-m' ;;
111 *'(486-class)'*) ARCH='-march=i486' ;; 109 'Intel Pentium M (Yonah) (686-class)'*) ARCH='-march=pentium-m' ;;
 110
 111 # Fallback classes
 112 *'(586-class)'*) ARCH='-march=pentium' ;;
 113 *'(486-class)'*) ARCH='-march=i486' ;;
112 esac 114 esac
113 ;; 115 ;;
114 116
115 m68k) case $hw_model in # Examples 117 m68k) case $hw_model in # Examples
116 *\(68020*|*\ MC68020\ *) ARCH='-m68020' ;; # Untested 118 *\(68020*|*\ MC68020\ *) ARCH='-m68020' ;; # Untested
117 *\(68030*|*\ MC68030\ *) ARCH='-m68030' ;; # Mac LC III 119 *\(68030*|*\ MC68030\ *) ARCH='-m68030' ;; # Mac LC III
118 *\(68040*|*\ MC68040\ *) ARCH='-m68040' ;; # Untested 120 *\(68040*|*\ MC68040\ *) ARCH='-m68040' ;; # Untested
119 *\(68060*|*\ MC68060\ *) ARCH='-m68060' ;; # Upgraded amiga 3000 121 *\(68060*|*\ MC68060\ *) ARCH='-m68060' ;; # Upgraded amiga 3000
120 esac 122 esac
121 ;; 123 ;;
122 124
123 mipseb|mipsel) 125 mipseb|mipsel)
124 # cpu0 at mainbus0: QED R4600 Orion CPU (0x2020) Rev. 2.0 with ... 126 # cpu0 at mainbus0: QED R4600 Orion CPU (0x2020) Rev. 2.0 with ...
125 case $hw_model in 127 case $hw_model in
126 Infineon\ ADM5120) ARCH='-march=4kc' ;; 128 Infineon\ ADM5120) ARCH='-march=4kc' ;;
127 *) 129 *)
128 case "$(egrep '^cpu0 ' /var/run/dmesg.boot)" in 130 case "$(egrep '^cpu0 ' /var/run/dmesg.boot)" in
129 *\ MIPS\ R2000\ *) ARCH="-march=r2000" ;; 131 *\ MIPS\ R2000\ *) ARCH="-march=r2000" ;;
130 *\ MIPS\ R3000\ *) ARCH="-march=r3000" ;; 132 *\ MIPS\ R3000\ *) ARCH="-march=r3000" ;;
131 *\ MIPS\ R3000A\ *) ARCH="-march=r3000" ;; 133 *\ MIPS\ R3000A\ *) ARCH="-march=r3000" ;;
132 *\ Toshiba\ TX3912\ *) ARCH="-march=r3900" ;; 134 *\ Toshiba\ TX3912\ *) ARCH="-march=r3900" ;;
@@ -149,61 +151,72 @@ determine_arch() @@ -149,61 +151,72 @@ determine_arch()
149 601\ *) ARCH='-mcpu=601' ;; # Untested 151 601\ *) ARCH='-mcpu=601' ;; # Untested
150 602\ *) ARCH='-mcpu=602' ;; # Untested 152 602\ *) ARCH='-mcpu=602' ;; # Untested
151 603\ *) ARCH='-mcpu=603' ;; # Untested 153 603\ *) ARCH='-mcpu=603' ;; # Untested
152 603e\ *|603ev\ *) ARCH='-mcpu=603e' ;; # Umax C500 / PM4400 154 603e\ *|603ev\ *) ARCH='-mcpu=603e' ;; # Umax C500 / PM4400
153 604\ *) ARCH='-mcpu=604' ;; # Mac 8500 155 604\ *) ARCH='-mcpu=604' ;; # Mac 8500
154 604e\ *) ARCH='-mcpu=604e' ;; # upgr B&W G3 156 604e\ *) ARCH='-mcpu=604e' ;; # upgr B&W G3
155 604ev\ *) ARCH='-mcpu=604e' ;; # usually 604e 157 604ev\ *) ARCH='-mcpu=604e' ;; # usually 604e
156 620\ *) ARCH='-mcpu=620' ;; # Untested 158 620\ *) ARCH='-mcpu=620' ;; # Untested
157 7400\ *) ARCH='-mcpu=7400' ;; # AGP G4/400 Mac 159 7400\ *) ARCH='-mcpu=7400' ;; # AGP G4/400 Mac
158 740\ *) ARCH='-mcpu=740' ;; # Untested 160 740\ *) ARCH='-mcpu=740' ;; # Untested
159 7410\ *) ARCH='-mcpu=7400' ;; # powerbook g4 161 7410\ *) ARCH='-mcpu=7400' ;; # powerbook g4
160 7447A\ *) ARCH='-mcpu=7450' ;; # 162 7447A\ *) ARCH='-mcpu=7450' ;; #
161 7450\ *) ARCH='-mcpu=7450' ;; # tibook 550 163 7450\ *) ARCH='-mcpu=7450' ;; # tibook 550
162 750\ *) ARCH='-mcpu=750' ;; # orig. iBook 164 750\ *) ARCH='-mcpu=750' ;; # orig. iBook
163 165
164 esac ;; 166 esac ;;
165 167
166 sparc | sparc64) case " $hw_model" in # Examples 168 sparc | sparc64) case " $hw_model" in # Examples
167 *[\ \(]MB86900/1A*) ARCH='-mcpu=cypress' ;; # ss1+ 169 *[\ \(]MB86900/1A*) ARCH='-mcpu=cypress' ;; # ss1+
168 *[\ \(]L64811*) ARCH='-mcpu=cypress' ;; # sun4/sun4c 170 *[\ \(]L64811*) ARCH='-mcpu=cypress' ;; # sun4/sun4c
169 *[\ \(]CY7C601*) ARCH='-mcpu=cypress' ;; # ss2 171 *[\ \(]CY7C601*) ARCH='-mcpu=cypress' ;; # ss2
170 *[\ \(]W8601/8701*) ARCH='-mcpu=cypress' ;; # elc 172 *[\ \(]W8601/8701*) ARCH='-mcpu=cypress' ;; # elc
171 *[\ \(]MB86904*) ARCH='-mcpu=supersparc' ;; # ss5 usparc 173 *[\ \(]MB86904*) ARCH='-mcpu=supersparc' ;; # ss5 usparc
172 *[\ \(]MB86907*) ARCH='-mcpu=supersparc' ;; # ss5 usparc 174 *[\ \(]MB86907*) ARCH='-mcpu=supersparc' ;; # ss5 usparc
173 *[\ \(]TMS390S10*) ARCH='-mcpu=supersparc' ;; # classic " 175 *[\ \(]TMS390S10*) ARCH='-mcpu=supersparc' ;; # classic "
174 *[\ \(]TMS390Z50*) ARCH='-mcpu=supersparc' ;; # ss10/ss20 176 *[\ \(]TMS390Z50*) ARCH='-mcpu=supersparc' ;; # ss10/ss20
175 *[\ \(]RT620/625*) ARCH='-mcpu=hypersparc' ;; # ss20 ross 177 *[\ \(]RT620/625*) ARCH='-mcpu=hypersparc' ;; # ss20 ross
176 *[\ \(]MB86930*) ARCH='-mcpu=sparclite' ;; # from gcc 178 *[\ \(]MB86930*) ARCH='-mcpu=sparclite' ;; # from gcc
177 *[\ \(]MB86934*) ARCH='-mcpu=sparclite' ;; # from gcc 179 *[\ \(]MB86934*) ARCH='-mcpu=sparclite' ;; # from gcc
178 # under 1.5.1 -mcpu=ultrasparc chokes egcs-2.91.66 compiling perl 180 # under 1.5.1 -mcpu=ultrasparc chokes egcs-2.91.66 compiling perl
179 *[\ \(]SUNW,UltraSPARC*) ARCH='-mcpu=v9' ;; # Ultra 181 *[\ \(]SUNW,UltraSPARC*) ARCH='-mcpu=v9' ;; # Ultra
180 esac ;; 182 esac ;;
181 183
182 vax) # No VAX specific gcc optimisations available 184 vax) # No VAX specific gcc optimisations available
183 NOARCH=1 185 NOARCH=1
184 ;; 186 ;;
185 187
186 esac 188 esac
187 echo $ARCH 189 echo $ARCH
188 } 190 }
189 191
190determine_features() 192determine_features()
191 { 193 {
192 FEATURES= 194 FEATURES=
 195
193 case $hw_machine_arch in 196 case $hw_machine_arch in
194 i386) 197 i386 | x86_64)
195 if [ "$(sysctl -n machdep.sse2)" = 1 ] ; then 198 # Set cpu_feature_FOO=1 for each 'FOO' feature reported
 199 eval $(echo "$cpu_details" | awk -F , '
 200 /cpu0: features/ {
 201 sub(".*<","");
 202 sub(">.*","");
 203 gsub("[^,A-Z0-9]","_");
 204 for (i = 1; i < NR; i++) { print "cpu_feature_"$i"=1" } }
 205 ')
 206 if [ -n "$cpu_feature_SSE3" ] ; then
 207 FEATURES="-mfpmath=sse -msse3"
 208 elif [ -n "$cpu_feature_SSE2" ] ; then
196 FEATURES="-mfpmath=sse -msse2" 209 FEATURES="-mfpmath=sse -msse2"
197 elif [ "$(sysctl -n machdep.sse)" = 1 ] ; then 210 elif [ -n "$cpu_feature_SSE" ] ; then
198 FEATURES="-mfpmath=sse -msse" 211 FEATURES="-mfpmath=sse -msse"
199 fi 212 fi
200 ;; 213 ;;
201 m68k) 214 m68k)
202 case "$(egrep '^fpu0 ' /var/run/dmesg.boot)" in 215 case "$(egrep '^fpu0 ' /var/run/dmesg.boot)" in
203 *\(emulator\)*) FEATURES="-msoft-float" ;; 216 *\(emulator\)*) FEATURES="-msoft-float" ;;
204 *\(no\ math\ support\)*) FEATURES="-msoft-float" ;; 217 *\(no\ math\ support\)*) FEATURES="-msoft-float" ;;
205 esac 218 esac
206 ;; 219 ;;
207 esac 220 esac
208 echo $FEATURES 221 echo $FEATURES
209 } 222 }

cvs diff -r1.4 -r1.5 pkgsrc/devel/cpuflags/files/subr_gcc (expand / switch to unified diff)

--- pkgsrc/devel/cpuflags/files/subr_gcc 2008/12/04 11:45:35 1.4
+++ pkgsrc/devel/cpuflags/files/subr_gcc 2008/12/08 17:40:14 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: subr_gcc,v 1.4 2008/12/04 11:45:35 abs Exp $ 1# $NetBSD: subr_gcc,v 1.5 2008/12/08 17:40:14 abs Exp $
2 2
3# Return gcc version string 3# Return gcc version string
4gcc_ver() 4gcc_ver()
5 { 5 {
6 gcc=$1 6 gcc=$1
7 ${gcc} -dumpversion | $SED -e 's/^[^0-9\.]\{1,\}//' -e 's/[^0-9\.]\{1,\}$//' 7 ${gcc} -dumpversion | $SED -e 's/^[^0-9\.]\{1,\}//' -e 's/[^0-9\.]\{1,\}$//'
8 } 8 }
9 9
10gcc_ser() 10gcc_ser()
11 { 11 {
12 gcc=$1 12 gcc=$1
13 gcc_ver $gcc | $AWK -F. '{ print ($1*1000+$2)}' 13 gcc_ver $gcc | $AWK -F. '{ print ($1*1000+$2)}'
14 } 14 }
@@ -99,16 +99,22 @@ gcc_fixup_arch_flags() @@ -99,16 +99,22 @@ gcc_fixup_arch_flags()
993.4:-march=athlon-fx:-march=athlon-xp 993.4:-march=athlon-fx:-march=athlon-xp
1003.4:-march=athlon64:-march=athlon-xp 1003.4:-march=athlon64:-march=athlon-xp
1013.4:-march=c3-2:-march=c3 1013.4:-march=c3-2:-march=c3
1023.4:-march=k8:-march=athlon-xp 1023.4:-march=k8:-march=athlon-xp
1033.4:-march=nocona:-march=pentium4 1033.4:-march=nocona:-march=pentium4
1043.4:-march=opteron:-march=athlon-xp 1043.4:-march=opteron:-march=athlon-xp
1053.4:-march=pentium-m:-march=pentium3 1053.4:-march=pentium-m:-march=pentium3
1063.4:-march=pentium3m:-march=pentium3 1063.4:-march=pentium3m:-march=pentium3
1073.4:-march=pentium4m:-march=pentium4 1073.4:-march=pentium4m:-march=pentium4
1083.4:-march=prescott:-march=pentium4 1083.4:-march=prescott:-march=pentium4
1093.4:-msse3: 1093.4:-msse3:
1104.2:-m3dnow: 1104.2:-m3dnow:
1114.2:-march=native: 1114.2:-march=native:
1124.3:-march=core2:-march=pentium3 1124.3:-march=amdfam10:-march=athlon64
 1134.3:-march=athlon64-sse3:-march=athlon64
 1144.3:-march=barcelona:-march=athlon64
 1154.3:-march=core2:-march=pentium-m
 1164.3:-march=geode:-march=k6-3
 1174.3:-march=k8-sse3:-march=k8
 1184.3:-march=opteron-sse3:-march=opteron
113EOD 119EOD
114 } 120 }