Lines 23-216
Link Here
|
23 |
return detected_platform |
23 |
return detected_platform |
24 |
|
24 |
|
25 |
|
25 |
|
26 |
# Set gcc_3_4 to false for versions of gcc below 3.4. |
|
|
27 |
def processor(gcc_3_4=True): |
28 |
print "Detecting processor..." |
29 |
|
30 |
try: |
31 |
f = open('/proc/cpuinfo', 'r') |
32 |
except IOError: |
33 |
import platform |
34 |
bits = platform.architecture()[0] |
35 |
if bits == '32bit': |
36 |
# default to i686 on 32 bit platforms without /proc/cpuinfo |
37 |
print " couldn't detect; assuming Pentium Pro or better" |
38 |
archflags=['-march=i686'] |
39 |
else: |
40 |
print " couldn't detect" |
41 |
archflags=[] |
42 |
return archflags |
43 |
|
44 |
str = f.readline() |
45 |
family="" |
46 |
model=-1 |
47 |
vendor="" |
48 |
archflags=[] |
49 |
while str: |
50 |
if str.startswith("vendor_id"): |
51 |
if str.find("GenuineTMx86") != -1: |
52 |
# Transmeta |
53 |
vendor="GenuineTMx86" |
54 |
elif str.find("GenuineIntel") != -1: |
55 |
# Intel |
56 |
vendor="GenuineIntel" |
57 |
elif str.find("AuthenticAMD") != -1: |
58 |
# AMD |
59 |
vendor="AuthenticAMD" |
60 |
elif str.startswith("cpu"): |
61 |
# first re does not do anything more than family = str.strip() in my case |
62 |
family = re.sub('^[^0-9A-Za-z]*', '', str).strip() |
63 |
# this is more useful, finds the first block of numbers |
64 |
family_number = re.findall('[0-9]+', str)[0] |
65 |
elif str.startswith("model") and str.find("name") == -1: |
66 |
model = re.sub('^[^0-9]*', '', str).strip() |
67 |
if vendor == "GenuineTMx86": |
68 |
if str.startswith("model name"): |
69 |
if str.find("Transmeta Efficeon") != -1: |
70 |
# Automatically reorders/realigns when |
71 |
# converting to VLIW, so no alignment |
72 |
# saves space without sacrificing speed |
73 |
print " found Transmeta Efficeon" |
74 |
archflags=['-march=i686'] |
75 |
if gcc_3_4: archflags+=['-mtune=pentium3'] |
76 |
else: archflags+=['-mcpu=pentium3'] |
77 |
archflags+=['-msse2', '-mfpmath=sse', '-falign-functions=0', '-falign-jumps=0', '-falign-loops=0'] |
78 |
elif vendor == "GenuineIntel": |
79 |
if str.startswith("model name"): |
80 |
if str.find("Intel(R) Pentium(R) 4 CPU") != -1: |
81 |
print " found Intel Pentium 4" |
82 |
archflags=['-march=pentium4'] |
83 |
elif str.find("Coppermine") != -1: |
84 |
print " found Intel Celeron (Coppermine)" |
85 |
archflags=['-march=pentium3'] |
86 |
elif str.find("Pentium III") != -1: |
87 |
print " found Intel Pentium III" |
88 |
archflags=['-march=pentium3'] |
89 |
elif str.find("Pentium II") != -1: |
90 |
print " found Intel Pentium II" |
91 |
archflags=['-march=pentium2'] |
92 |
elif str.find("Intel(R) Celeron(R) CPU") != -1: |
93 |
print " found Intel Celeron (Willamette)" |
94 |
archflags=['-march=pentium4'] |
95 |
elif str.find("Celeron") != -1: |
96 |
print " found Intel Celeron 1" |
97 |
archflags=['-march=pentium2'] |
98 |
elif str.find("Intel(R) Pentium(R) M") != -1: |
99 |
print " found Intel Pentium-M" |
100 |
if gcc_3_4: archflags=['-march=pentium-m'] |
101 |
else: |
102 |
print "WARNING: gcc versions below 3.4 don't support -march=pentium-m, using -march=pentium4 instead" |
103 |
archflags=['-march=pentium4'] |
104 |
elif str.find("Intel(R) Xeon(TM) CPU") != -1: |
105 |
print " found Intel Xeon w/EM64T" |
106 |
archflags=['-march=nocona', '-mmmx', '-msse3'] |
107 |
elif vendor == "AuthenticAMD": |
108 |
if str.startswith("model name"): |
109 |
if str.find("Duron") != -1: |
110 |
if model == 7: |
111 |
print " found AMD Duron Morgan" |
112 |
archflags=['-march=athlon-xp'] |
113 |
elif model == 3: |
114 |
print " found AMD Mobile Duron" |
115 |
archflags=['-march=athlon-tbird'] |
116 |
else: |
117 |
print " found AMD Duron" |
118 |
archflags=['-march=athlon-tbird'] |
119 |
elif str.find("Sempron") != -1: |
120 |
print " found AMD Sempron 64" |
121 |
if gcc_3_4: archflags=['-march=athlon64'] |
122 |
else: |
123 |
print "WARNING: gcc versions below 3.4 don't support -march=athlon64, using -march=athlon-4 -msse2 -mfpmath=sse instead" |
124 |
archflags=['-march=athlon', '-msse2', '-mfpmath=sse'] |
125 |
elif str.find("Athlon") != -1: |
126 |
if str.find("64") != -1: |
127 |
print " found AMD Athlon 64" |
128 |
if gcc_3_4: archflags=['-march=athlon64'] |
129 |
else: |
130 |
print "WARNING: gcc versions below 3.4 don't support -march=athlon64, using -march=athlon-4 -msse2 -mfpmath=sse instead" |
131 |
archflags=['-march=athlon', '-msse2', '-mfpmath=sse'] |
132 |
# maybe this should use int(family_number) rather than family |
133 |
# i have no way of checking |
134 |
elif family == 6 and model == 8: |
135 |
print " found AMD Athlon Thunderbird XP" |
136 |
archflags=['-march=athlon-xp'] |
137 |
else: |
138 |
print " found AMD Athlon" |
139 |
archflags=['-march=athlon'] |
140 |
elif str.find("Opteron") != -1: |
141 |
print " found AMD Opteron" |
142 |
if gcc_3_4: archflags=['-march=opteron'] |
143 |
else: |
144 |
print "WARNING: gcc versions below 3.4 don't support -march=opteron, using -march=athlon-4 -msse2 -mfpmath=sse instead" |
145 |
archflags=['-march=athlon-4', '-msse2', '-mfpmath=sse'] |
146 |
else: |
147 |
if str.find("Nehemiah") != -1: |
148 |
print " found VIA Nehemiah" |
149 |
archflags=['-march=c3-2'] |
150 |
elif str.find("Eden") != -1: |
151 |
print " found VIA Eden C3" |
152 |
archflags=['-march=c3'] |
153 |
elif str.find("Ezra") != -1: |
154 |
print " found VIA Ezra" |
155 |
archflags=['-march=c3'] |
156 |
|
157 |
str = f.readline() |
158 |
if len(archflags) == 0: |
159 |
if vendor == "": |
160 |
if family != -1: # has to be checked... |
161 |
if family_number in ('970'): |
162 |
print " found PowerPC 970 (G5)" |
163 |
archflags=['-mtune=G5', '-maltivec', '-mabi=altivec'] |
164 |
#i think these are all the same as far as gcc cares |
165 |
elif family_number in ('7450','7455','7445','7447','7457'): |
166 |
print " found PowerPC 7450 (G4 v2)" |
167 |
archflags=['-mtune=7450', '-maltivec', '-mabi=altivec'] |
168 |
elif family_number in ('7400','7410'): |
169 |
print " found PowerPC 7400 (G4)" |
170 |
archflags=['-mtune=7400', '-maltivec', '-mabi=altivec'] |
171 |
elif family_number in ('750'): |
172 |
print " found PowerPC 750 (G3)" |
173 |
archflags=['-mtune=750'] |
174 |
elif family_number in ('740'): |
175 |
print " found PowerPC 740 (G3)" |
176 |
archflags=['-mtune=740'] |
177 |
elif family_number in ('604'): |
178 |
print " found PowerPC 604" |
179 |
archflags=['-mtune=604'] |
180 |
elif family_number in ('603'): |
181 |
print " found PowerPC 603" |
182 |
archflags=['-mtune=603'] |
183 |
|
184 |
|
185 |
|
186 |
f.close() |
187 |
if len(archflags) == 0: |
188 |
print "Couldn't detect your CPU, guessing i686 compatible.." |
189 |
archflags=['-march=i686'] |
190 |
return archflags |
191 |
|
192 |
|
193 |
|
194 |
|
195 |
def check_gcc_version(env, conf = None): |
196 |
# The GCC version is needed by the detect.processor() function to recognize |
197 |
# versions below 3.4 and versions equal to or greater than 3.4. |
198 |
# As opposed to the other functions in this file, which are called from the |
199 |
# configure() function below, this one is called directly from rts.py while |
200 |
# parsing `optimize=' configure argument. |
201 |
print env.subst("Checking $CC version..."), |
202 |
try: |
203 |
f = os.popen(env.subst('$CC --version')) |
204 |
version = f.read() |
205 |
finally: |
206 |
f.close() |
207 |
if version: |
208 |
version = re.search('[0-9]\.[0-9]\.[0-9]', version).group() |
209 |
print version |
210 |
return re.split('\.', version) |
211 |
else: |
212 |
print env.subst("$CC not found") |
213 |
env.Exit(1) |
214 |
|
26 |
|
215 |
|
27 |
|
216 |
|
28 |
|
Lines 341-347
Link Here
|
341 |
if args.has_key('platform'): env['platform'] = args['platform'] |
153 |
if args.has_key('platform'): env['platform'] = args['platform'] |
342 |
else: env['platform'] = platform() |
154 |
else: env['platform'] = platform() |
343 |
|
155 |
|
344 |
gcc_version = check_gcc_version(env) |
|
|
345 |
|
156 |
|
346 |
|
157 |
|
347 |
|
158 |
|
Lines 393-421
Link Here
|
393 |
print "\ninvalid debug option, must be one of: yes, true, no, false, 0, 1, 2, 3." |
204 |
print "\ninvalid debug option, must be one of: yes, true, no, false, 0, 1, 2, 3." |
394 |
env.Exit(1) |
205 |
env.Exit(1) |
395 |
|
206 |
|
396 |
# optimize? |
|
|
397 |
if args.has_key('optimize'): |
398 |
level = args['optimize'] |
399 |
if level == 'no' or level == 'false': level = '0' |
400 |
elif level == 'yes' or level == 'true': level = '1' |
401 |
else: |
402 |
if env['debug']: level = '0' |
403 |
else: level = '1' |
404 |
if level == 'noarch': |
405 |
print "noarch optimizing" |
406 |
env['optimize'] = 'noarch' |
407 |
env.AppendUnique(CCFLAGS=['-O1', '-pipe']) |
408 |
elif int(level) >= 1 and int(level) <= 3: |
409 |
print "level", level, "optimizing enabled" |
410 |
env['optimize'] = level |
411 |
archflags = processor(gcc_version >= ['3','4','0']) |
412 |
env.AppendUnique(CCFLAGS=['-O'+level, '-pipe']+archflags) |
413 |
elif int(level) == 0: |
414 |
print "optimizing NOT enabled," |
415 |
env['optimize'] = 0 |
416 |
else: |
417 |
print "\ninvalid optimize option, must be one of: yes, true, no, false, 0, 1, 2, 3, noarch." |
418 |
env.Exit(1) |
419 |
|
207 |
|
420 |
|
208 |
|
421 |
|
209 |
|