blob: c1a5b95cfb07ace486d225ed1f39dbf83b3e13c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
#!/bin/sh
# $NetBSD: cpuflags.NetBSD,v 1.57 2004/11/14 21:51:05 abs Exp $
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
if [ "$1" = -v ] ; then
shift
opt_v=1
fi
if [ -n "$1" ]; then
CC=$1
else
CC=gcc
fi
display_hw_details()
{
echo " OS : '$(uname)'"
echo " hw.model : '$hw_model'"
echo " hw.machine : '$hw_machine'"
echo " hw.machine_arch : '$hw_machine_arch'"
echo " cpu details :"
sed -n -e 's/^/ /' -e '/^ cpu/p' /var/run/dmesg.boot
}
hw_model=$(sysctl -n hw.model)
hw_machine=$(sysctl -n hw.machine)
hw_machine_arch=$(sysctl -n hw.machine_arch)
# We're almost certainly crosscompiling
if [ -n "$MACHINE" -a $hw_machine != "$MACHINE" ]; then
echo
exit
fi
# When adding $hw_model tests use maximum context (such as trailing space)
case $hw_machine_arch in
alpha)
# cpu0 at mainbus0: ID 0 (primary), 21164A-0 (unknown ...
case "$(egrep '^cpu0 ' /var/run/dmesg.boot)" in
*[\(\ ]2106[46][-A\ \)]*) FLAGS="-mcpu=21064" ;;
*[\(\ ]21164[-\ \)]*) FLAGS="-mcpu=21164" ;;
*[\(\ ]21164A[-\ \)]*) FLAGS="-mcpu=21164a" ;;
*[\(\ ]21264[-\ \)]*) FLAGS="-mcpu=21264" ;;
*[\(\ ]21264[AB][-\ \)]*) FLAGS="-mcpu=21264a" ;;
*\ PCA56-2) FLAGS="-mcpu=21164pc" ;;
esac
;;
arm | arm32) case $hw_model in
ARM610*) FLAGS="-mcpu=arm610" ;; # risc pc
ARM710*) FLAGS="-mcpu=arm710" ;; # risc pc
i80321\ *) FLAGS="-mcpu=xscale" ;; # iyonix
SA-110*)
case $hw_machine in # arm32 split post 1.5
cats|shark|hpcarm|netwinder)
FLAGS="-mcpu=strongarm110" ;;
acorn32)
FLAGS="-march=armv3m -mtune=strongarm" ;;
*)
# memorybus in strongarm risc pc machines cannot support
# certain strongarm instructions, but in 1.5 and earlier
# all strongarm machines are 'arm32', so uname and sysctl
# no use
if egrep -q 'ofbus0|footbridge0' /var/run/dmesg.boot \
2>/dev/null ; then
FLAGS="-mcpu=strongarm110" # shark/cats
else
FLAGS="-march=armv3m -mtune=strongarm" # risc pc
fi
esac ;;
esac ;;
i386) case $hw_model in
*Intel\ Pentium/MMX\ *) FLAGS='-march=pentium-mmx' ;;
*Intel\ Pentium\ II\ *) FLAGS='-march=pentium2' ;;
*Intel\ Pentium\ III\ *) FLAGS='-march=pentium3' ;;
*Intel\ Mobile\ Pentium\ III\ *) FLAGS='-march=pentium3' ;;
*Intel\ Celeron\ \(Mendocino\)\ *) FLAGS='-march=pentium3 -mno-sse' ;;
*Intel\ Pentium\ M\ *) FLAGS='-march=pentium3m' ;;
*Intel\ Mobile\ Pentium\ 4\ *) FLAGS='-march=pentium4m' ;;
*Intel\ Pentium\ 4\ *) FLAGS='-march=pentium4' ;;
*VIA\ C3*\ Samuel*) FLAGS='-march=c3' ;;
*AMD\ K6-III*) FLAGS='-march=k6-3' ;;
*AMD\ K6-2*) FLAGS='-march=k6-2' ;;
*AMD\ K6*) FLAGS='-march=k6' ;;
*AMD\ Duron*) FLAGS='-march=athlon' ;;
*AMD\ Athlon\ 4*) FLAGS='-march=athlon-4' ;;
*AMD\ Athlon\ MP*) FLAGS='-march=athlon-mp' ;;
*AMD\ K7\ \(Athlon\)\ XP\ *) FLAGS='-march=athlon-xp' ;;
*AMD\ Athlon\ XP\ *) FLAGS='-march=athlon-xp' ;;
*AMD\ K7*|*AMD\ Athlon*) FLAGS='-march=athlon' ;;
*386-class*) FLAGS='-march=i386' ;;
*486-class*) FLAGS='-march=i486' ;;
*586-class*) FLAGS='-march=pentium' ;;
*686-class*) FLAGS='-march=pentiumpro' ;;
esac
;;
m68k) case $hw_model in # Examples
*\(68020*|*\ MC68020\ *) FLAGS='-m68020' ;; # Untested
*\(68030*|*\ MC68030\ *) FLAGS='-m68030' ;; # Mac LC III
*\(68040*|*\ MC68040\ *) FLAGS='-m68040' ;; # Untested
*\(68060*|*\ MC68060\ *) FLAGS='-m68060' ;; # Upgr amiga 3000
esac
case "$(egrep '^fpu0 ' /var/run/dmesg.boot)" in
*\(emulator\)*) FLAGS="$FLAGS -msoft-float" ;;
*\(no\ math\ support\)*) FLAGS="$FLAGS -msoft-float" ;;
esac
;;
mipseb|mipsel)
# cpu0 at mainbus0: QED R4600 Orion CPU (0x2020) Rev. 2.0 with ...
case "$(egrep '^cpu0 ' /var/run/dmesg.boot)" in
*\ MIPS\ R2000\ *) FLAGS="-march=r2000" ;;
*\ MIPS\ R3000\ *) FLAGS="-march=r3000" ;;
*\ MIPS\ R3000A\ *) FLAGS="-march=r3000" ;;
*\ Toshiba\ TX3912\ *) FLAGS="-march=r3900" ;;
*\ Toshiba\ TX392[27]\ *) FLAGS="-march=r3900" ;;
*\ MIPS\ R4000\ *) FLAGS="-mtune=r4000 -mips2" ;; # really mips3
*\ MIPS\ R4400\ *) FLAGS="-mtune=r4400 -mips2" ;; # really mips3
*\ NEC\ VR4100\ *) FLAGS="-mtune=r4100 -mips2" ;; # really mips3
*\ NEC\ VR4300\ *) FLAGS="-mtune=r4300 -mips2" ;; # really mips3
*\ QED\ R4600\ *) FLAGS="-mtune=r4600 -mips2" ;; # really mips3
*\ MIPS\ R5000\ *) FLAGS="-mtune=r5000 -mips2" ;; # really mips4
*\ QED\ RM5200\ *) FLAGS="-mtune=r5000 -mips2" ;; # really mips4
*\ MIPS\ R6000\ *) FLAGS="-mtune=r6000 -mips2" ;;
*\ MIPS\ R8000\ *) FLAGS="-mtune=r8000 -mips2" ;; # really mips4
esac
;;
powerpc) case $hw_model in # Examples
601\ *) FLAGS='-mcpu=601' ;; # Untested
602\ *) FLAGS='-mcpu=602' ;; # Untested
603\ *) FLAGS='-mcpu=603' ;; # Untested
603e\ *|603ev\ *) FLAGS='-mcpu=603e' ;; # Umax C500 / PM4400
604\ *) FLAGS='-mcpu=604' ;; # Mac 8500
604ev\ *) FLAGS='-mcpu=604e' ;; # upgr B&W G3
620\ *) FLAGS='-mcpu=620' ;; # Untested
7400\ *) FLAGS='-mcpu=7400' ;; # AGP G4/400 Mac
7410\ *) FLAGS='-mcpu=7400' ;; # powerbook g4
740\ *) FLAGS='-mcpu=740' ;; # Untested
7450\ *) FLAGS='-mcpu=7450' ;; # tibook 550
750\ *) FLAGS='-mcpu=750' ;; # Untested
esac ;;
sparc | sparc64) case " $hw_model" in # Examples
*[\ \(]MB86900/1A*) FLAGS='-mcpu=cypress' ;; # ss1+
*[\ \(]L64811*) FLAGS='-mcpu=cypress' ;; # sun4/sun4c
*[\ \(]CY7C601*) FLAGS='-mcpu=cypress' ;; # ss2
*[\ \(]W8601/8701*) FLAGS='-mcpu=cypress' ;; # elc
*[\ \(]MB86904*) FLAGS='-mcpu=supersparc' ;; # ss5 usparc
*[\ \(]MB86907*) FLAGS='-mcpu=supersparc' ;; # ss5 usparc
*[\ \(]TMS390S10*) FLAGS='-mcpu=supersparc' ;; # classic "
*[\ \(]TMS390Z50*) FLAGS='-mcpu=supersparc' ;; # ss10/ss20
*[\ \(]RT620/625*) FLAGS='-mcpu=hypersparc' ;; # ss20 ross
*[\ \(]MB86930*) FLAGS='-mcpu=sparclite' ;; # from gcc
*[\ \(]MB86934*) FLAGS='-mcpu=sparclite' ;; # from gcc
# under 1.5.1 -mcpu=ultrasparc chokes egcs-2.91.66 compiling perl
*[\ \(]SUNW,UltraSPARC*) FLAGS='-mcpu=v9' ;; # Ultra
esac ;;
x86_64) # No x86_64 specific gcc optimisations yet
NONE=1
;;
vax) # No VAX specific gcc optimisations available
NONE=1
;;
esac
############
# Everything from this point common between all cpuflags variants.
if [ -n "$opt_v" ] ; then
if [ -z "$NONE" ] ; then
echo "CPUFLAGS=Unknown"
else
echo "CPUFLAGS=None"
fi
display_hw_details
exit
fi
if [ -z "$FLAGS" -a -z "$NONE" ] ; then
echo 'Unknown machine - please send details to abs@netbsd.org' >&2
display_hw_details >&2
fi
# Fixup options for older gccs.
# Entries can be recursive - eg:
# -march=k6-3 -> -march=k6 -> -march=pentium -> -march=i486
#
# The format of table is
# gcc_version_in_which_option_was_introduced new_option old_option
if [ -n "$FLAGS" ]; then
gcc_ver=`${CC} -dumpversion | sed 's/^egcs-//'`
FLAGS=`awk -F: -v "flags=$FLAGS" -v "gcc_ver=$gcc_ver" '
{ if (gcc_ver < $1){map[$2] = ""$3} }
END { while (flags in map) {flags = map[flags]} print flags }
' <<EOD
2.90:-march=i386:-mno-486
2.90:-march=i486:-m486
2.90:-march=pentium:-m486
2.90:-march=pentiumpro:-m486
2.90:-mcpu=21164a:
2.90:-mcpu=arm610:-m6
2.90:-mcpu=arm710:-m6
2.90:-mcpu=cypress:-mcypress
2.90:-mcpu=sparclite:-msparclite
2.90:-mcpu=strongarm110:-m6
2.90:-mcpu=supersparc:-msupersparc
2.90:-mcpu=v9:-mv8
2.95:-march=k6:-march=pentium
3.0:-march=athlon:-march=pentiumpro
3.1:-march=athlon-4:-march=athlon
3.1:-march=athlon-mp:-march=athlon
3.1:-march=athlon-tbird:-march=athlon
3.1:-march=athlon-xp:-march=athlon
3.1:-march=k6-2:-march=k6
3.1:-march=k6-3:-march=k6
3.1:-march=pentium-mmx:-march=pentium
3.1:-march=pentium2:-march=pentiumpro
3.1:-march=pentium3 -mno-sse:-march=pentiumpro
3.1:-march=pentium3:-march=pentiumpro
3.1:-march=pentium4:-march=pentiumpro
3.1:-march=r2000:-cpu=r2000
3.1:-march=r3000:-cpu=r3000
3.1:-march=r3900:-cpu=r3900
3.1:-march=r4000:-cpu=r4000
3.1:-march=r4100:-cpu=r4100
3.1:-march=r4300:-cpu=r4300
3.1:-march=r4400:-cpu=r4400
3.1:-march=r4600:-cpu=r4600
3.1:-march=r5000:-cpu=r5000
3.1:-march=r6000:-cpu=r6000
3.1:-march=r8000:-cpu=r8000
3.1:-mcpu=21264a:-mcpu=21264
3.1:-mcpu=7400:-mcpu=750
3.1:-mcpu=7450:-mcpu=750
3.1:-mtune=r2000:-cpu=r2000
3.1:-mtune=r3000:-cpu=r3000
3.1:-mtune=r3900:-cpu=r3900
3.1:-mtune=r4000:-cpu=r4000
3.1:-mtune=r4100:-cpu=r4100
3.1:-mtune=r4300:-cpu=r4300
3.1:-mtune=r4400:-cpu=r4400
3.1:-mtune=r4600:-cpu=r4600
3.1:-mtune=r5000:-cpu=r5000
3.1:-mtune=r6000:-cpu=r6000
3.1:-mtune=r8000:-cpu=r8000
3.3:-march=c3:-march=i586
3.3:-march=winchip-c6:-march=i586
3.3:-march=winchip2:-march=i586
3.4:-march=athlon-fx:-march=athlon-xp
3.4:-march=athlon64:-march=athlon-xp
3.4:-march=c3-2:-march=c3
3.4:-march=k8:-march=athlon-xp
3.4:-march=nocona:-march=pentium4
3.4:-march=opteron:-march=athlon-xp
3.4:-march=pentium-m:-march=pentium3
3.4:-march=pentium3m:-march=pentium3
3.4:-march=pentium4m:-march=pentium4
3.4:-march=prescott:-march=pentium4
EOD
`
fi
echo $FLAGS
exit 0
|