summaryrefslogtreecommitdiff
path: root/nacl/do
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/do')
-rwxr-xr-xnacl/do468
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
7version=`cat version`
8project=nacl
9shorthostname=`hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]'`
10
11top="`pwd`/build/$shorthostname"
12bin="$top/bin"
13lib="$top/lib"
14include="$top/include"
15work="$top/work"
16
17PATH="/usr/local/bin:$PATH"
18PATH="/usr/sfw/bin:$PATH"
19PATH="$bin:$PATH"
20export PATH
21
22LD_LIBRARY_PATH="/usr/local/lib/sparcv9:/usr/local/lib:$LD_LIBRARY_PATH"
23LD_LIBRARY_PATH="/usr/sfw/lib/sparcv9:/usr/sfw/lib:$LD_LIBRARY_PATH"
24export LD_LIBRARY_PATH
25
26# and wacky MacOS X
27DYLD_LIBRARY_PATH="/usr/local/lib/sparcv9:/usr/local/lib:$DYLD_LIBRARY_PATH"
28DYLD_LIBRARY_PATH="/usr/sfw/lib/sparcv9:/usr/sfw/lib:$DYLD_LIBRARY_PATH"
29export DYLD_LIBRARY_PATH
30
31# and work around bug in GNU sort
32LANG=C
33export LANG
34
35rm -rf "$top"
36mkdir -p "$top"
37mkdir -p "$bin"
38mkdir -p "$lib"
39mkdir -p "$include"
40
41exec >"$top/log"
42exec 2>&1
43exec 5>"$top/data"
44exec </dev/null
45
46echo "=== `date` === starting"
47
48echo "=== `date` === hostname"
49hostname || :
50echo "=== `date` === uname -a"
51uname -a || :
52echo "=== `date` === uname -M"
53uname -M || :
54echo "=== `date` === uname -F"
55uname -F || :
56echo "=== `date` === /usr/sbin/lscfg | grep proc"
57/usr/sbin/lscfg | grep proc || :
58echo "=== `date` === /usr/sbin/lsattr -El proc0"
59/usr/sbin/lsattr -El proc0 || :
60echo "=== `date` === cat /proc/cpuinfo"
61cat /proc/cpuinfo || :
62echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
63cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq || :
64echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
65cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq || :
66echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
67cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq || :
68echo "=== `date` === cat /sys/devices/system/cpu/cpu0/clock_tick"
69cat /sys/devices/system/cpu/cpu0/clock_tick || :
70echo "=== `date` === sysctl hw.model"
71sysctl hw.model || :
72echo "=== `date` === sysctl machdep.tsc_freq"
73sysctl machdep.tsc_freq || :
74echo "=== `date` === /usr/sbin/psrinfo -v"
75/usr/sbin/psrinfo -v || :
76
77echo "=== `date` === building okcompilers"
78rm -rf "$work"
79mkdir -p "$work"
80cp -pr okcompilers/* "$work"
81( cd "$work" && sh do )
82cp -p "$work"/bin/* "$bin"
83
84echo "=== `date` === building cpuid"
85rm -rf "$work"
86mkdir -p "$work"
87cp -pr cpuid/* "$work"
88( cd "$work" && sh do )
89cp -pr "$work"/include/* "$include"
90
91echo "=== `date` === building inttypes"
92rm -rf "$work"
93mkdir -p "$work"
94cp -pr inttypes/* "$work"
95( cd "$work" && sh do )
96cp -pr "$work"/include/* "$include"
97
98echo "=== `date` === building cpucycles"
99rm -rf "$work"
100mkdir -p "$work"
101cp -pr cpucycles/* "$work"
102( cd "$work" && sh do )
103cp -pr "$work"/lib/* "$lib"
104cp -pr "$work"/include/* "$include"
105
106echo "=== `date` === building randombytes"
107rm -rf "$work"
108mkdir -p "$work"
109cp -pr randombytes/* "$work"
110( cd "$work" && sh do )
111cp -pr "$work"/lib/* "$lib"
112cp -pr "$work"/include/* "$include"
113
114okabi \
115| while read abi
116do
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 )
127done
128
129# loop over operations
130cat OPERATIONS \
131| while read o
132do
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
365done
366
367for language in c cpp
368do
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
416done
417
418echo "=== `date` === starting curvecp"
419
420okabi \
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
429do
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
466done
467
468echo "=== `date` === finishing"