diff options
Diffstat (limited to 'nacl/do')
-rwxr-xr-x | nacl/do | 468 |
1 files changed, 0 insertions, 468 deletions
diff --git a/nacl/do b/nacl/do deleted file mode 100755 index f953508d..00000000 --- a/nacl/do +++ /dev/null | |||
@@ -1,468 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # nacl/do | ||
4 | # D. J. Bernstein | ||
5 | # Public domain. | ||
6 | |||
7 | version=`cat version` | ||
8 | project=nacl | ||
9 | shorthostname=`hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]'` | ||
10 | |||
11 | top="`pwd`/build/$shorthostname" | ||
12 | bin="$top/bin" | ||
13 | lib="$top/lib" | ||
14 | include="$top/include" | ||
15 | work="$top/work" | ||
16 | |||
17 | PATH="/usr/local/bin:$PATH" | ||
18 | PATH="/usr/sfw/bin:$PATH" | ||
19 | PATH="$bin:$PATH" | ||
20 | export PATH | ||
21 | |||
22 | LD_LIBRARY_PATH="/usr/local/lib/sparcv9:/usr/local/lib:$LD_LIBRARY_PATH" | ||
23 | LD_LIBRARY_PATH="/usr/sfw/lib/sparcv9:/usr/sfw/lib:$LD_LIBRARY_PATH" | ||
24 | export LD_LIBRARY_PATH | ||
25 | |||
26 | # and wacky MacOS X | ||
27 | DYLD_LIBRARY_PATH="/usr/local/lib/sparcv9:/usr/local/lib:$DYLD_LIBRARY_PATH" | ||
28 | DYLD_LIBRARY_PATH="/usr/sfw/lib/sparcv9:/usr/sfw/lib:$DYLD_LIBRARY_PATH" | ||
29 | export DYLD_LIBRARY_PATH | ||
30 | |||
31 | # and work around bug in GNU sort | ||
32 | LANG=C | ||
33 | export LANG | ||
34 | |||
35 | rm -rf "$top" | ||
36 | mkdir -p "$top" | ||
37 | mkdir -p "$bin" | ||
38 | mkdir -p "$lib" | ||
39 | mkdir -p "$include" | ||
40 | |||
41 | exec >"$top/log" | ||
42 | exec 2>&1 | ||
43 | exec 5>"$top/data" | ||
44 | exec </dev/null | ||
45 | |||
46 | echo "=== `date` === starting" | ||
47 | |||
48 | echo "=== `date` === hostname" | ||
49 | hostname || : | ||
50 | echo "=== `date` === uname -a" | ||
51 | uname -a || : | ||
52 | echo "=== `date` === uname -M" | ||
53 | uname -M || : | ||
54 | echo "=== `date` === uname -F" | ||
55 | uname -F || : | ||
56 | echo "=== `date` === /usr/sbin/lscfg | grep proc" | ||
57 | /usr/sbin/lscfg | grep proc || : | ||
58 | echo "=== `date` === /usr/sbin/lsattr -El proc0" | ||
59 | /usr/sbin/lsattr -El proc0 || : | ||
60 | echo "=== `date` === cat /proc/cpuinfo" | ||
61 | cat /proc/cpuinfo || : | ||
62 | echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" | ||
63 | cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq || : | ||
64 | echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" | ||
65 | cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq || : | ||
66 | echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" | ||
67 | cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq || : | ||
68 | echo "=== `date` === cat /sys/devices/system/cpu/cpu0/clock_tick" | ||
69 | cat /sys/devices/system/cpu/cpu0/clock_tick || : | ||
70 | echo "=== `date` === sysctl hw.model" | ||
71 | sysctl hw.model || : | ||
72 | echo "=== `date` === sysctl machdep.tsc_freq" | ||
73 | sysctl machdep.tsc_freq || : | ||
74 | echo "=== `date` === /usr/sbin/psrinfo -v" | ||
75 | /usr/sbin/psrinfo -v || : | ||
76 | |||
77 | echo "=== `date` === building okcompilers" | ||
78 | rm -rf "$work" | ||
79 | mkdir -p "$work" | ||
80 | cp -pr okcompilers/* "$work" | ||
81 | ( cd "$work" && sh do ) | ||
82 | cp -p "$work"/bin/* "$bin" | ||
83 | |||
84 | echo "=== `date` === building cpuid" | ||
85 | rm -rf "$work" | ||
86 | mkdir -p "$work" | ||
87 | cp -pr cpuid/* "$work" | ||
88 | ( cd "$work" && sh do ) | ||
89 | cp -pr "$work"/include/* "$include" | ||
90 | |||
91 | echo "=== `date` === building inttypes" | ||
92 | rm -rf "$work" | ||
93 | mkdir -p "$work" | ||
94 | cp -pr inttypes/* "$work" | ||
95 | ( cd "$work" && sh do ) | ||
96 | cp -pr "$work"/include/* "$include" | ||
97 | |||
98 | echo "=== `date` === building cpucycles" | ||
99 | rm -rf "$work" | ||
100 | mkdir -p "$work" | ||
101 | cp -pr cpucycles/* "$work" | ||
102 | ( cd "$work" && sh do ) | ||
103 | cp -pr "$work"/lib/* "$lib" | ||
104 | cp -pr "$work"/include/* "$include" | ||
105 | |||
106 | echo "=== `date` === building randombytes" | ||
107 | rm -rf "$work" | ||
108 | mkdir -p "$work" | ||
109 | cp -pr randombytes/* "$work" | ||
110 | ( cd "$work" && sh do ) | ||
111 | cp -pr "$work"/lib/* "$lib" | ||
112 | cp -pr "$work"/include/* "$include" | ||
113 | |||
114 | okabi \ | ||
115 | | while read abi | ||
116 | do | ||
117 | rm -rf "$work" | ||
118 | mkdir -p "$work" | ||
119 | echo 'void crypto_'"$project"'_base(void) { ; }' > "$work/${project}_base.c" | ||
120 | okc-$abi \ | ||
121 | | while read compiler | ||
122 | do | ||
123 | ( cd "$work" && $compiler -c ${project}_base.c ) && break | ||
124 | done | ||
125 | okar-$abi cr "$lib/$abi/lib${project}.a" "$work/${project}_base.o" | ||
126 | ( ranlib "$lib/$abi/lib${project}.a" || exit 0 ) | ||
127 | done | ||
128 | |||
129 | # loop over operations | ||
130 | cat OPERATIONS \ | ||
131 | | while read o | ||
132 | do | ||
133 | [ -d "$o" ] || continue | ||
134 | |||
135 | selected='' | ||
136 | [ -f "$o/selected" ] && selected=`cat "$o/selected"` | ||
137 | |||
138 | # for each operation, loop over primitives | ||
139 | ls "$o" \ | ||
140 | | sort \ | ||
141 | | while read p | ||
142 | do | ||
143 | [ -d "$o/$p" ] || continue | ||
144 | expectedchecksum='' | ||
145 | [ -f "$o/$p/checksum" ] && expectedchecksum=`cat "$o/$p/checksum"` | ||
146 | op="${o}_${p}" | ||
147 | |||
148 | startdate=`date +%Y%m%d` | ||
149 | |||
150 | # for each operation primitive, loop over abis | ||
151 | okabi \ | ||
152 | | while read abi | ||
153 | do | ||
154 | echo "=== `date` === $abi $o/$p" | ||
155 | libs=`"oklibs-$abi"` | ||
156 | libs="$lib/$abi/cpucycles.o $libs" | ||
157 | [ -f "$lib/$abi/lib${project}.a" ] && libs="$lib/$abi/lib${project}.a $libs" | ||
158 | |||
159 | rm -rf "$work" | ||
160 | mkdir -p "$work" | ||
161 | mkdir -p "$work/best" | ||
162 | |||
163 | # for each operation primitive abi, loop over implementations | ||
164 | find "$o/$p" -follow -name "api.h" \ | ||
165 | | sort \ | ||
166 | | while read doth | ||
167 | do | ||
168 | implementationdir=`dirname $doth` | ||
169 | opi=`echo "$implementationdir" | tr ./- ___` | ||
170 | |||
171 | echo "=== `date` === $abi $implementationdir" | ||
172 | |||
173 | rm -rf "$work/compile" | ||
174 | mkdir -p "$work/compile" | ||
175 | |||
176 | cfiles=`ls "$implementationdir" | grep '\.c$' || :` | ||
177 | sfiles=`ls "$implementationdir" | grep '\.[sS]$' || :` | ||
178 | cppfiles=`ls "$o" | grep '\.cpp$' || :` | ||
179 | |||
180 | cp -p "$o"/*.c "$work/compile/" | ||
181 | cp -p "$o"/*.cpp "$work/compile/" | ||
182 | |||
183 | cp -pr "$implementationdir"/* "$work/compile" | ||
184 | |||
185 | cp -p "try-anything.c" "$work/compile/try-anything.c" | ||
186 | cp -p "measure-anything.c" "$work/compile/measure-anything.c" | ||
187 | |||
188 | cp -p MACROS "$work/compile/MACROS" | ||
189 | cp -p PROTOTYPES.c "$work/compile/PROTOTYPES.c" | ||
190 | cp -p PROTOTYPES.cpp "$work/compile/PROTOTYPES.cpp" | ||
191 | |||
192 | ( | ||
193 | cd "$work/compile" | ||
194 | ( | ||
195 | echo "#ifndef ${o}_H" | ||
196 | echo "#define ${o}_H" | ||
197 | echo "" | ||
198 | echo "#include \"${op}.h\"" | ||
199 | echo "" | ||
200 | egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \ | ||
201 | | sed "s/$o/$op/" | while read mop | ||
202 | do | ||
203 | echo "#define ${mop} ${mop}" | sed "s/$op/$o/" | ||
204 | done | ||
205 | echo "#define ${o}_PRIMITIVE \"${p}\"" | ||
206 | echo "#define ${o}_IMPLEMENTATION ${op}_IMPLEMENTATION" | ||
207 | echo "#define ${o}_VERSION ${op}_VERSION" | ||
208 | echo "" | ||
209 | echo "#endif" | ||
210 | ) > "$o.h" | ||
211 | ( | ||
212 | echo "#ifndef ${op}_H" | ||
213 | echo "#define ${op}_H" | ||
214 | echo "" | ||
215 | sed 's/[ ]CRYPTO_/ '"${opi}"'_/g' < api.h | ||
216 | echo '#ifdef __cplusplus' | ||
217 | echo '#include <string>' | ||
218 | egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.cpp \ | ||
219 | | sed "s/$o/$opi/" | ||
220 | echo 'extern "C" {' | ||
221 | echo '#endif' | ||
222 | egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.c \ | ||
223 | | sed "s/$o/$opi/" | ||
224 | echo '#ifdef __cplusplus' | ||
225 | echo '}' | ||
226 | echo '#endif' | ||
227 | echo "" | ||
228 | egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \ | ||
229 | | sed "s/$o/$opi/" | while read mopi | ||
230 | do | ||
231 | echo "#define ${mopi} ${mopi}" | sed "s/$opi/$op/" | ||
232 | done | ||
233 | echo "#define ${op}_IMPLEMENTATION \"${implementationdir}\"" | ||
234 | echo "#ifndef ${opi}_VERSION" | ||
235 | echo "#define ${opi}_VERSION \"-\"" | ||
236 | echo "#endif" | ||
237 | echo "#define ${op}_VERSION ${opi}_VERSION" | ||
238 | echo "" | ||
239 | echo "#endif" | ||
240 | ) > "$op.h" | ||
241 | |||
242 | okc-$abi \ | ||
243 | | while read compiler | ||
244 | do | ||
245 | echo "=== `date` === $abi $implementationdir $compiler" | ||
246 | compilerword=`echo "$compiler" | tr ' ' '_'` | ||
247 | ok=1 | ||
248 | for f in $cfiles $sfiles | ||
249 | do | ||
250 | if [ "$ok" = 1 ] | ||
251 | then | ||
252 | $compiler \ | ||
253 | -I. -I"$include" -I"$include/$abi" \ | ||
254 | -c "$f" >../errors 2>&1 || ok=0 | ||
255 | ( if [ `wc -l < ../errors` -lt 25 ] | ||
256 | then | ||
257 | cat ../errors | ||
258 | else | ||
259 | head ../errors | ||
260 | echo ... | ||
261 | tail ../errors | ||
262 | fi | ||
263 | ) \ | ||
264 | | while read err | ||
265 | do | ||
266 | echo "$version $shorthostname $abi $startdate $o $p fromcompiler $implementationdir $compilerword $f $err" >&5 | ||
267 | done | ||
268 | fi | ||
269 | done | ||
270 | |||
271 | [ "$ok" = 1 ] || continue | ||
272 | okar-$abi cr "$op.a" *.o || continue | ||
273 | ranlib "$op.a" | ||
274 | |||
275 | $compiler \ | ||
276 | -I. -I"$include" -I"$include/$abi" \ | ||
277 | -o try try.c try-anything.c \ | ||
278 | "$op.a" $libs >../errors 2>&1 || ok=0 | ||
279 | cat ../errors \ | ||
280 | | while read err | ||
281 | do | ||
282 | echo "$version $shorthostname $abi $startdate $o $p fromcompiler $implementationdir $compilerword try.c $err" >&5 | ||
283 | done | ||
284 | [ "$ok" = 1 ] || continue | ||
285 | |||
286 | if sh -c './try || exit $?' >../outputs 2>../errors | ||
287 | then | ||
288 | checksum=`awk '{print $1}' < ../outputs` | ||
289 | cycles=`awk '{print $2}' < ../outputs` | ||
290 | checksumcycles=`awk '{print $3}' < ../outputs` | ||
291 | cyclespersecond=`awk '{print $4}' < ../outputs` | ||
292 | impl=`awk '{print $5}' < ../outputs` | ||
293 | else | ||
294 | echo "$version $shorthostname $abi $startdate $o $p tryfails $implementationdir $compilerword error $?" >&5 | ||
295 | cat ../outputs ../errors \ | ||
296 | | while read err | ||
297 | do | ||
298 | echo "$version $shorthostname $abi $startdate $o $p tryfails $implementationdir $compilerword $err" >&5 | ||
299 | done | ||
300 | continue | ||
301 | fi | ||
302 | |||
303 | checksumok=fails | ||
304 | [ "x$expectedchecksum" = "x$checksum" ] && checksumok=ok | ||
305 | [ "x$expectedchecksum" = "x" ] && checksumok=unknown | ||
306 | echo "$version $shorthostname $abi $startdate $o $p try $checksum $checksumok $cycles $checksumcycles $cyclespersecond $impl $compilerword" >&5 | ||
307 | [ "$checksumok" = fails ] && continue | ||
308 | |||
309 | [ -s ../bestmedian ] && [ `cat ../bestmedian` -le $cycles ] && continue | ||
310 | echo "$cycles" > ../bestmedian | ||
311 | |||
312 | $compiler -D'COMPILER="'"$compiler"'"' \ | ||
313 | -DLOOPS=1 \ | ||
314 | -I. -I"$include" -I"$include/$abi" \ | ||
315 | -o measure measure.c measure-anything.c \ | ||
316 | "$op.a" $libs >../errors 2>&1 || ok=0 | ||
317 | cat ../errors \ | ||
318 | | while read err | ||
319 | do | ||
320 | echo "$version $shorthostname $abi $startdate $o $p fromcompiler $implementationdir $compilerword measure.c $err" >&5 | ||
321 | done | ||
322 | [ "$ok" = 1 ] || continue | ||
323 | |||
324 | for f in $cppfiles | ||
325 | do | ||
326 | okcpp-$abi \ | ||
327 | | while read cppcompiler | ||
328 | do | ||
329 | echo "=== `date` === $abi $implementationdir $cppcompiler" | ||
330 | $cppcompiler \ | ||
331 | -I. -I"$include" -I"$include/$abi" \ | ||
332 | -c "$f" && break | ||
333 | done | ||
334 | done | ||
335 | |||
336 | rm -f ../best/*.o ../best/measure || continue | ||
337 | for f in *.o | ||
338 | do | ||
339 | cp -p "$f" "../best/${opi}-$f" | ||
340 | done | ||
341 | cp -p "$op.h" "../$op.h" | ||
342 | cp -p "$o.h" "../$o.h" | ||
343 | cp -p measure ../best/measure | ||
344 | done | ||
345 | ) | ||
346 | done | ||
347 | |||
348 | echo "=== `date` === $abi $o/$p measuring" | ||
349 | |||
350 | "$work/best/measure" \ | ||
351 | | while read measurement | ||
352 | do | ||
353 | echo "$version $shorthostname $abi $startdate $o $p $measurement" >&5 | ||
354 | done | ||
355 | |||
356 | [ -f "$o/$p/used" ] \ | ||
357 | && okar-$abi cr "$lib/$abi/lib${project}.a" "$work/best"/*.o \ | ||
358 | && ( ranlib "$lib/$abi/lib${project}.a" || exit 0 ) \ | ||
359 | && cp -p "$work/$op.h" "$include/$abi/$op.h" \ | ||
360 | && [ -f "$o/$p/selected" ] \ | ||
361 | && cp -p "$work/$o.h" "$include/$abi/$o.h" \ | ||
362 | || : | ||
363 | done | ||
364 | done | ||
365 | done | ||
366 | |||
367 | for language in c cpp | ||
368 | do | ||
369 | for bintype in commandline tests | ||
370 | do | ||
371 | ls $bintype \ | ||
372 | | sed -n 's/\.'$language'$//p' \ | ||
373 | | sort \ | ||
374 | | while read cmd | ||
375 | do | ||
376 | echo "=== `date` === starting $bintype/$cmd" | ||
377 | |||
378 | rm -rf "$work" | ||
379 | mkdir -p "$work/compile" | ||
380 | |||
381 | cp "$bintype/$cmd.$language" "$work/compile/$cmd.$language" | ||
382 | [ "$bintype" = tests ] && cp -p "$bintype/$cmd.out" "$work/compile/$cmd.out" | ||
383 | |||
384 | okabi \ | ||
385 | | while read abi | ||
386 | do | ||
387 | [ -x "$bin/$cmd" ] && break | ||
388 | |||
389 | libs=`"oklibs-$abi"` | ||
390 | libs="$lib/$abi/cpucycles.o $libs" | ||
391 | libs="$libs $lib/$abi/randombytes.o" | ||
392 | |||
393 | ok${language}-$abi \ | ||
394 | | while read compiler | ||
395 | do | ||
396 | [ -x "$bin/$cmd" ] && break | ||
397 | |||
398 | echo "=== `date` === $bintype/$cmd $abi $compiler" | ||
399 | ( | ||
400 | cd "$work/compile" | ||
401 | if $compiler \ | ||
402 | -I"$include" -I"$include/$abi" \ | ||
403 | -o "$cmd" "$cmd.${language}" \ | ||
404 | "$lib/$abi/lib${project}.a" $libs | ||
405 | then | ||
406 | case "$bintype" in | ||
407 | commandline) cp -p "$cmd" "$bin/$cmd" ;; | ||
408 | tests) "./$cmd" | cmp - "$cmd.out" || "./$cmd" ;; | ||
409 | esac | ||
410 | fi | ||
411 | ) | ||
412 | done | ||
413 | done | ||
414 | done | ||
415 | done | ||
416 | done | ||
417 | |||
418 | echo "=== `date` === starting curvecp" | ||
419 | |||
420 | okabi \ | ||
421 | | awk ' | ||
422 | { if ($1=="amd64" || $1=="ia64" || $1=="ppc64" || $1=="sparcv9" || $1=="mips64") print 1,$1 | ||
423 | else if ($1 == "mips32") print 2,$1 | ||
424 | else print 3,$1 | ||
425 | } | ||
426 | ' \ | ||
427 | | sort \ | ||
428 | | while read okabipriority abi | ||
429 | do | ||
430 | [ -x "$bin/curvecpmessage" ] && break | ||
431 | libs=`"oklibs-$abi"` | ||
432 | libs="$lib/$abi/cpucycles.o $libs" | ||
433 | libs="$libs $lib/$abi/randombytes.o" | ||
434 | |||
435 | okc-$abi \ | ||
436 | | while read compiler | ||
437 | do | ||
438 | [ -x "$bin/curvecpmessage" ] && break | ||
439 | |||
440 | echo "=== `date` === curvecp $abi $compiler" | ||
441 | rm -rf "$work" | ||
442 | mkdir -p "$work/compile" | ||
443 | cp curvecp/* "$work/compile" | ||
444 | ( | ||
445 | cd "$work/compile" | ||
446 | cat SOURCES \ | ||
447 | | while read x | ||
448 | do | ||
449 | $compiler -I"$include" -I"$include/$abi" -c "$x.c" | ||
450 | done | ||
451 | |||
452 | if okar-$abi cr curvecplibs.a `cat LIBS` | ||
453 | then | ||
454 | cat TARGETS \ | ||
455 | | while read x | ||
456 | do | ||
457 | $compiler -I"$include" -I"$include/$abi" \ | ||
458 | -o "$x" "$x.o" \ | ||
459 | curvecplibs.a "$lib/$abi/lib${project}.a" $libs \ | ||
460 | && cp -p "$x" "$bin/$x" | ||
461 | done | ||
462 | fi | ||
463 | ) | ||
464 | done | ||
465 | |||
466 | done | ||
467 | |||
468 | echo "=== `date` === finishing" | ||