3 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
10 # The script is located in "native_client/tests/spec2k"
13 if [[ $(basename "$(pwd)") != "spec2k" ]] ; then
14 echo "ERROR: cannot find the spec2k/ directory"
18 # TODO(pdox): Remove this dependency.
19 source ../../pnacl/scripts/common-tools.sh
20 readonly NACL_ROOT="$(GetAbsolutePath "../../")"
21 SetScriptPath "$(pwd)/run_all.sh"
22 SetLogDirectory "${NACL_ROOT}/toolchain/test-log"
23 readonly TESTS_ARCHIVE=arm-spec.tar.gz
25 ######################################################################
27 ######################################################################
28 # TODO(robertm): make this configurable from the commandline
30 readonly LIST_INT_C="164.gzip 175.vpr 176.gcc 181.mcf 186.crafty 197.parser \
31 253.perlbmk 254.gap 255.vortex 256.bzip2 300.twolf"
33 readonly LIST_FP_C="177.mesa 179.art 183.equake 188.ammp"
35 readonly LIST_INT_CPP="252.eon"
37 SPEC2K_BENCHMARKS="${LIST_FP_C} ${LIST_INT_C} ${LIST_INT_CPP}"
39 # One of {./run.train.sh, ./run.ref.sh}
40 SPEC2K_SCRIPT="./run.train.sh"
42 # Uncomment this to disable verification of test results.
43 # Otherwise, verification time is part of overall benchmarking time
44 # (should probably separate that out).
46 export VERIFY=${VERIFY:-yes}
47 export MAKEOPTS=${MAKEOPTS:-}
49 # Helper script to process timing / other perf data.
50 # Export these paths to Makefile.common, which will be included by other
51 # Makefiles in random sub-directories (where pwd will be different).
52 export PERF_LOGGER="$(pwd)/emit_perf_log.sh"
53 export COMPILE_REPEATER="$(pwd)/compile_repeater.sh"
54 # Number of times to repeat a timed step.
55 export SPEC_RUN_REPETITIONS=${SPEC_RUN_REPETITIONS:-1}
56 export SPEC_COMPILE_REPETITIONS=${SPEC_COMPILE_REPETITIONS:-1}
60 ######################################################################
62 ######################################################################
64 readonly SCONS_OUT="${NACL_ROOT}/scons-out"
65 readonly TC_ROOT="${NACL_ROOT}/toolchain"
66 readonly TC_BASE="${TC_ROOT}/${SCONS_BUILD_PLATFORM}_${BUILD_ARCH_SHORT}"
68 readonly ARM_TRUSTED_TC="${TC_BASE}/arm_trusted"
69 readonly QEMU_TOOL="${ARM_TRUSTED_TC}/run_under_qemu_arm"
71 readonly ARM_LLC_NEXE="${TC_BASE}/pnacl_translator/translator/arm/bin/pnacl-llc.nexe"
73 readonly NNACL_TC="${TC_BASE}/nacl_${BUILD_ARCH_SHORT}_glibc"
74 readonly RUNNABLE_LD_X8632="${NNACL_TC}/x86_64-nacl/lib32/runnable-ld.so"
75 readonly RUNNABLE_LD_X8664="${NNACL_TC}/x86_64-nacl/lib/runnable-ld.so"
79 echo "Uncompressed size of ${file} is $(cat ${file} | wc -c)"
80 echo "Gzipped size of ${file} is $(gzip ${file} -c | wc -c)"
83 ######################################################################
85 ######################################################################
87 #@ run_all.sh <mode> <mode-arg>*
89 #@ ------------------------------------------------------------
91 #@ ------------------------------------------------------------
93 # Setups for building (but not running) Pexes only. Used for arm-hw translator
94 # testing where pexes are build on x86 and translated on arm
96 SUFFIX=opt.stripped.pexe
100 SUFFIX=unopt.stripped.pexe
105 #@ use system compiler for x86-32
113 #@ use system compiler for x86-32 with optimization
121 #@ use system compiler for x86-64
129 #@ use system compiler for x86-64 with optimization
137 #@ use Emscripten emcc compiler for Asm.js JavaScript generation
139 PREFIX=../run_asmjs.sh
146 #@ use system compiler for x86-32
154 #@ use system compiler for x86-32 with optimization
155 SetupLlvmX8632Opt() {
157 SUFFIX=llvm.opt.x8632
162 #@ use system compiler for x86-64
170 #@ use system compiler for x86-64 with optimization
171 SetupLlvmX8664Opt() {
173 SUFFIX=llvm.opt.x8664
178 #@ use system compiler for ARM
186 #@ use system compiler for ARM with optimization
189 SUFFIX=llvm.opt.hw.arm
192 ######################################################################
194 SetupNaclX8632Common() {
200 #@ use nacl-gcc compiler
208 #@ use nacl-gcc compiler with optimizations
209 SetupNaclX8632Opt() {
211 SUFFIX=nacl.opt.x8632
214 SetupNaclX8664Common() {
220 #@ use nacl-gcc64 compiler
228 #@ use nacl-gcc64 compiler with optimizations
229 SetupNaclX8664Opt() {
231 SUFFIX=nacl.opt.x8664
234 SetupNaclDynX8632Common() {
235 SetupSelLdr x86-32 "" "-s" "${RUNNABLE_LD_X8632}"
240 #@ use nacl-gcc compiler with glibc toolchain and dynamic linking
241 SetupNaclDynX8632() {
242 SetupNaclDynX8632Common
243 SUFFIX=nacl.dyn.x8632
247 #@ SetupNaclDynX8632Opt
248 #@ use nacl-gcc compiler with glibc toolchain and dynamic linking
249 SetupNaclDynX8632Opt() {
250 SetupNaclDynX8632Common
251 SUFFIX=nacl.dyn.opt.x8632
254 SetupNaclDynX8664Common() {
255 SetupSelLdr x86-64 "" "-s" "${RUNNABLE_LD_X8664}"
260 #@ use nacl64-gcc compiler with glibc toolchain and dynamic linking
261 SetupNaclDynX8664() {
262 SetupNaclDynX8664Common
263 SUFFIX=nacl.dyn.x8664
267 #@ SetupNaclDynX8664Opt
268 #@ use nacl64-gcc compiler with glibc toolchain and dynamic linking
269 SetupNaclDynX8664Opt() {
270 SetupNaclDynX8664Common
271 SUFFIX=nacl.dyn.opt.x8664
274 ######################################################################
276 SetupPnaclX8664Common() {
282 #@ use pnacl x86-64 compiler (no lto)
284 SetupPnaclX8664Common
289 #@ SetupPnaclX8664Opt
290 #@ use pnacl x86-64 compiler (with lto)
291 SetupPnaclX8664Opt() {
292 SetupPnaclX8664Common
293 SUFFIX=pnacl.opt.x8664
297 #@ SetupPnaclX8664ZBSOpt
298 #@ use pnacl x86-64 compiler (with lto)
299 #@ use x86-64 zero-based sandbox
300 SetupPnaclX8664ZBSOpt() {
301 SetupSelLdr x86-64 "" "-c"
302 # TODO(arbenson): Give this a different suffix to differentitate
303 # from the existing x86-64 build, and make the corresponding
304 # changes to the build process.
305 SUFFIX=pnacl.opt.x8664
309 #@ SetupPnaclTranslatorX8664
310 #@ use pnacl x8664 translator (no lto)
311 SetupPnaclTranslatorX8664() {
312 SetupPnaclX8664Common
313 SUFFIX=pnacl_translator.x8664
317 #@ SetupPnaclTranslatorX8664Opt
318 #@ use pnacl x8664 translator (with lto)
319 SetupPnaclTranslatorX8664Opt() {
320 SetupPnaclX8664Common
321 SUFFIX=pnacl_translator.opt.x8664
325 #@ SetupPnaclTranslatorFastX8664Opt
326 #@ use pnacl x8664 translator fast mode (with lto)
327 SetupPnaclTranslatorFastX8664Opt() {
328 SetupPnaclX8664Common
329 SUFFIX=pnacl_translator_fast.opt.x8664
334 #@ SetupPnaclTranslator1ThreadX8664Opt
335 #@ use pnacl x8664 translator (with lto). Compile w/ 1 thread.
336 SetupPnaclTranslator1ThreadX8664Opt() {
337 SetupPnaclX8664Common
338 SUFFIX=pnacl_translator_1thread.opt.x8664
342 #@ SetupPnaclTranslatorFast1ThreadX8664Opt
343 #@ use pnacl x8664 translator fast mode (with lto). Compile w/ 1 thread.
344 SetupPnaclTranslatorFast1ThreadX8664Opt() {
345 SetupPnaclX8664Common
346 SUFFIX=pnacl_translator_fast_1thread.opt.x8664
350 SetupPnaclX8632Common() {
356 #@ use pnacl x86-32 compiler (no lto)
358 SetupPnaclX8632Common
363 #@ SetupPnaclX8632Opt
364 #@ use pnacl x86-32 compiler (with lto)
365 SetupPnaclX8632Opt() {
366 SetupPnaclX8632Common
367 SUFFIX=pnacl.opt.x8632
372 #@ SetupPnaclTranslatorX8632
373 #@ use pnacl x8632 translator (no lto)
374 SetupPnaclTranslatorX8632() {
375 SetupPnaclX8632Common
376 SUFFIX=pnacl_translator.x8632
380 #@ SetupPnaclTranslatorX8632Opt
381 #@ use pnacl x8632 translator (with lto)
382 SetupPnaclTranslatorX8632Opt() {
383 SetupPnaclX8632Common
384 SUFFIX=pnacl_translator.opt.x8632
388 #@ SetupPnaclTranslatorFastX8632Opt
389 #@ use pnacl x8632 translator fast mode (with lto)
390 SetupPnaclTranslatorFastX8632Opt() {
391 SetupPnaclX8632Common
392 SUFFIX=pnacl_translator_fast.opt.x8632
396 #@ SetupPnaclTranslator1ThreadX8632Opt
397 #@ use pnacl x8632 translator (with lto). Compile w/ 1 thread.
398 SetupPnaclTranslator1ThreadX8632Opt() {
399 SetupPnaclX8632Common
400 SUFFIX=pnacl_translator_1thread.opt.x8632
404 #@ SetupPnaclTranslatorFast1ThreadX8632Opt
405 #@ use pnacl x8632 translator fast mode (with lto). Compile w/ 1 thread.
406 SetupPnaclTranslatorFast1ThreadX8632Opt() {
407 SetupPnaclX8632Common
408 SUFFIX=pnacl_translator_fast_1thread.opt.x8632
414 #@ use gcc cross compiler
416 PREFIX="${QEMU_TOOL}"
422 #@ use gcc cross compiler
424 PREFIX="${QEMU_TOOL}"
429 SetupPnaclArmCommon() {
430 SetupSelLdr arm "${QEMU_TOOL}" "-Q"
435 #@ use pnacl arm compiler (with lto) -- run with QEMU
443 #@ use pnacl arm compiler (no lto) -- run with QEMU
450 #@ SetupPnaclTranslatorArm
451 #@ use pnacl arm translator (no lto)
452 SetupPnaclTranslatorArm() {
454 SUFFIX=pnacl_translator.arm
458 #@ SetupPnaclTranslatorArmOpt
459 #@ use pnacl arm translator (with lto)
460 SetupPnaclTranslatorArmOpt() {
462 SUFFIX=pnacl_translator.opt.arm
466 #@ SetupPnaclTranslatorFastArmOpt
467 #@ use pnacl arm translator fast mode (with lto)
468 SetupPnaclTranslatorFastArmOpt() {
470 SUFFIX=pnacl_translator_fast.opt.arm
475 SetupPnaclArmCommonHW() {
480 #@ SetupPnaclArmOptHW
481 #@ use pnacl arm compiler (with lto) -- run on ARM hardware
482 SetupPnaclArmOptHW() {
483 SetupPnaclArmCommonHW
489 #@ use pnacl arm compiler (no lto) -- run on ARM hardware
491 SetupPnaclArmCommonHW
496 #@ SetupPnaclTranslatorArmHW
497 #@ use pnacl arm translator (no lto) -- run on ARM hardware
498 SetupPnaclTranslatorArmHW() {
499 SetupPnaclArmCommonHW
500 SUFFIX=pnacl_translator.hw.arm
504 #@ SetupPnaclTranslatorArmOptHW
505 #@ use pnacl arm translator (with lto) -- run on ARM hardware
506 SetupPnaclTranslatorArmOptHW() {
507 SetupPnaclArmCommonHW
508 SUFFIX=pnacl_translator.opt.hw.arm
512 #@ SetupPnaclTranslatorFastArmOptHW
513 #@ use pnacl arm translator fast mode (with lto) -- run on ARM hardware
514 SetupPnaclTranslatorFastArmOptHW() {
515 SetupPnaclArmCommonHW
516 SUFFIX=pnacl_translator_fast.opt.hw.arm
520 #@ SetupPnaclTranslator1ThreadArmOptHW
521 #@ use pnacl arm translator (with lto) -- run on ARM hardware.
522 #@ compile with 1 thread.
523 SetupPnaclTranslator1ThreadArmOptHW() {
524 SetupPnaclArmCommonHW
525 SUFFIX=pnacl_translator_1thread.opt.hw.arm
529 #@ SetupPnaclTranslatorFast1ThreadArmOptHW
530 #@ use pnacl arm translator fast mode (with lto) -- run on ARM hardware
531 #@ compile with 1 thread.
532 SetupPnaclTranslatorFast1ThreadArmOptHW() {
533 SetupPnaclArmCommonHW
534 SUFFIX=pnacl_translator_fast_1thread.opt.hw.arm
540 SubBanner "Config Info"
541 echo "benchmarks: $(GetBenchmarkList "$@")"
542 echo "script: $(GetInputSize "$@")"
543 echo "suffix ${SUFFIX}"
544 echo "verify ${VERIFY}"
545 echo "prefix ${PREFIX}"
549 ######################################################################
550 # Functions intended to be called
551 ######################################################################
553 #@ ------------------------------------------------------------
555 #@ ------------------------------------------------------------
560 #@ Show available benchmarks
562 if [[ $# -ge 1 ]]; then
563 if [[ ($1 == "ref") || ($1 == "train") ]]; then
568 if [[ ($# == 0) || ($1 == "all") ]] ; then
569 echo "${SPEC2K_BENCHMARKS[@]}"
576 #+ GetInputSize [train|ref]
578 #+ Picks input size for spec runs (train or ref)
580 if [[ $# -ge 1 ]]; then
583 echo "./run.train.sh"
592 echo ${SPEC2K_SCRIPT}
596 #+ CheckFileBuilt <depname> <file> -
598 #+ Check that a dependency is actually built.
602 if [[ ! -f "${filename}" ]] ; then
603 echo "You have not built ${depname} yet (${filename})!" 1>&2
609 #+ SetupSelLdr <arch> <prefix> <extra_flags> <preload>
611 #+ Set up PREFIX to run sel_ldr on <arch>.
612 #+ <prefix> precedes sel_ldr in the command.
613 #+ <extra_flags> are additional flags to sel_ldr.
614 #+ <preload> is used as the actual nexe to load, making the real nexe an arg.
618 local extra_flags="${3-}"
619 local preload="${4-}"
621 local staging="${SCONS_OUT}/opt-${SCONS_BUILD_PLATFORM}-${arch}/staging"
622 SEL_LDR="${staging}/sel_ldr"
623 CheckFileBuilt "sel_ldr" "${SEL_LDR}"
624 if [[ ${SCONS_BUILD_PLATFORM} = "linux" ]]; then
625 SEL_LDR_BOOTSTRAP="${staging}/nacl_helper_bootstrap"
626 CheckFileBuilt "bootstrap" "${SEL_LDR_BOOTSTRAP}"
628 IRT_IMAGE="${SCONS_OUT}/nacl_irt-${arch}/staging/irt_core.nexe"
629 CheckFileBuilt "IRT image" "${IRT_IMAGE}"
631 local validator_bin="ncval"
632 if [[ ${arch} = "arm" ]]; then
633 validator_bin="arm-ncval-core"
635 VALIDATOR="${staging}/${validator_bin}"
636 # We don't CheckFileBuilt for VALIDATOR because we currently don't build
639 if [[ ${SCONS_BUILD_PLATFORM} = "linux" ]]; then
640 TEMPLATE_DIGITS="XXXXXXXXXXXXXXXX"
641 PREFIX="${prefix} ${SEL_LDR_BOOTSTRAP} \
642 ${SEL_LDR} --r_debug=0x${TEMPLATE_DIGITS} \
643 --reserved_at_zero=0x${TEMPLATE_DIGITS} -B ${IRT_IMAGE} \
644 -a ${extra_flags} -f ${preload}"
646 PREFIX="${prefix} ${SEL_LDR} -B ${IRT_IMAGE} -a ${extra_flags} \
652 SCONS_COMMON="./scons --mode=opt-host,nacl -j8 --verbose"
654 EnableX8664ZeroBasedSandbox() {
655 export NACL_ENABLE_INSECURE_ZERO_BASED_SANDBOX=1
660 local runtime_pieces=$2
661 local extra_flags="${3-}"
662 for platform in ${platforms} ; do
663 echo "build-runtime: scons ${runtime_pieces} [${platform}]"
665 ${SCONS_COMMON} ${extra_flags} platform=${platform} ${runtime_pieces})
672 for platform in ${platforms} ; do
673 echo "build-libs-nacl: scons build_lib [${platform}] $*"
675 ${SCONS_COMMON} platform=${platform} build_lib "$@")
681 # TODO(dschuff/jvoung): fix this circular dependency with the toolchain build
682 TOOLCHAIN_LABEL=pnacl_linux_x86 pnacl/build.sh sdk newlib
687 #@ CleanBenchmarks <benchmark>*
689 #@ this is a deep clean and you have to rerun PopulateFromSpecHarness
691 local list=$(GetBenchmarkList "$@")
693 for i in ${list} ; do
694 SubBanner "Cleaning: $i"
703 #@ BuildBenchmarks <do_timing> <setup> <benchmark>*
705 #@ Build all benchmarks according to the setup
706 #@ First arg should be either 0 (no timing) or 1 (run timing measure).
707 #@ Results are delivered to {execname}.compile_time
715 local list=$(GetBenchmarkList "$@")
717 for i in ${list} ; do
718 SubBanner "Building: $i"
720 # SPEC_COMPONENT is used for Asm.js builds in Makefile.common.
721 export SPEC_COMPONENT="${i}"
723 make ${MAKEOPTS} measureit=${timeit} \
724 PERF_LOGGER="${PERF_LOGGER}" \
725 REPETITIONS="${SPEC_COMPILE_REPETITIONS}" \
726 COMPILE_REPEATER="${COMPILE_REPEATER}" \
727 SCONS_BUILD_PLATFORM=${SCONS_BUILD_PLATFORM} \
728 BUILD_ARCH_SHORT=${BUILD_ARCH_SHORT} \
735 #@ TimedRunCmd <time_result_file> {actual_cmd }
737 #@ Run the command under time and dump time data to file.
742 /usr/bin/time -f "%U %S %e %C" --append -o "${target}" "$@"
746 #@ RunBenchmarks <setup> [ref|train] <benchmark>*
748 #@ Run all benchmarks according to the setup.
754 local list=$(GetBenchmarkList "$@")
755 local script=$(GetInputSize "$@")
757 for i in ${list} ; do
758 SubBanner "Benchmarking: $i"
760 target_file=./${i#*.}.${SUFFIX}
761 echo_file_size ${target_file}
762 # SCRIPTNAME is needed by run_asmjs.sh so that it knows
763 # which version of the prepackaged files to use.
764 export SCRIPTNAME="${script}"
765 echo "Running: ${script} ${target_file}"
766 ${script} ${target_file}
773 #@ RunTimedBenchmarks <setup> [ref|train] <benchmark>*
775 #@ Run all benchmarks according to the setup.
776 #@ All timing related files are stored in {execname}.run_time
777 #@ Note that the VERIFY variable effects the timing!
778 RunTimedBenchmarks() {
782 local list=$(GetBenchmarkList "$@")
783 local script=$(GetInputSize "$@")
786 for i in ${list} ; do
787 SubBanner "Benchmarking: $i"
789 local benchname=${i#*.}
790 local target_file=./${benchname}.${SUFFIX}
791 local time_file=${target_file}.run_time
792 echo_file_size ${target_file}
793 # SCRIPTNAME is needed by run_asmjs.sh so that it knows
794 # which version of the prepackaged files to use.
795 export SCRIPTNAME="${script}"
796 # Clear out the previous times.
798 echo "Running benchmark ${SPEC_RUN_REPETITIONS} times"
799 for ((i=0; i<${SPEC_RUN_REPETITIONS}; i++))
801 TimedRunCmd ${time_file} ${script} ${target_file}
803 # TODO(jvoung): split runtimes by arch as well
804 # i.e., pull "arch" out of SUFFIX and add to the "runtime" label.
805 "${PERF_LOGGER}" LogRealTime "${time_file}" "runtime" \
806 ${benchname} ${SUFFIX}
815 local list=$(GetBenchmarkList "$@")
817 SubBanner "Validating: $i"
819 local benchname=${i#*.}
820 local target_file=./${benchname}.${SUFFIX}
821 local time_file=${target_file}.validation_time
823 for ((i=0; i<${SPEC_RUN_REPETITIONS}; i++))
825 TimedRunCmd ${time_file} "${VALIDATOR}" ${target_file}
827 "${PERF_LOGGER}" LogRealTime "${time_file}" "validationtime" \
828 ${benchname} ${SUFFIX}
831 if [[ ${setup_func} =~ "Arm" ]]; then
832 TimedRunCmd llc.validation_time "${VALIDATOR}" "${ARM_LLC_NEXE}"
833 "${PERF_LOGGER}" LogRealTime llc.validation_time "validationtime" \
839 #@ BuildAndRunBenchmarks <setup> [ref|train] <benchmark>*
841 #@ Builds and run all benchmarks according to the setup
842 BuildAndRunBenchmarks() {
845 BuildBenchmarks 0 ${setup} "$@"
846 RunBenchmarks ${setup} "$@"
850 #@ TimedBuildAndRunBenchmarks <setup> [ref|train] <benchmark>*
852 #@ Builds and run all benchmarks according to the setup, using
853 #@ and records the time spent at each task..
854 #@ Results are saved in {execname}.compile_time and
855 #@ {execname}.run_time for each benchmark executable
856 #@ Note that the VERIFY variable effects the timing!
857 TimedBuildAndRunBenchmarks() {
860 BuildBenchmarks 1 ${setup} "$@"
861 RunTimedBenchmarks ${setup} "$@"
865 #@ PackageArmBinaries [usual var-args for RunBenchmarks]
867 #@ Archives ARM binaries built from a local QEMU run of spec
869 #@ Note: <setup> should be the QEMU setup (e.g., SetupPnaclArmOpt)
870 #@ Note: As with the other modes in this script, this script should be
871 #@ run from the directory of the script (not the native_client directory).
873 PackageArmBinaries() {
874 local BENCH_LIST=$(GetBenchmarkList "$@")
876 local UNZIPPED_TAR=$(basename ${TESTS_ARCHIVE} .gz)
878 # Switch to native_client directory (from tests/spec2k) so that
879 # when we extract, the builder will have a more natural directory layout.
881 # Carefully tar only the parts of the spec harness that we need.
883 find tests/spec2k -name '*.bc' -delete
884 find tests/spec2k -maxdepth 1 -type f -print |
885 xargs tar --no-recursion -cvf ${UNZIPPED_TAR}
886 tar -rvf ${UNZIPPED_TAR} tests/spec2k/bin
887 for i in ${BENCH_LIST} ; do
888 tar -rvf ${UNZIPPED_TAR} tests/spec2k/$i
890 gzip -f ${UNZIPPED_TAR}
895 #@ Unpack a packaged archive of ARM SPEC binaries. The archive is
896 #@ located in the nacl root directory, but the script is run from the spec dir.
897 UnpackArmBinaries() {
899 tar xvzf ${TESTS_ARCHIVE})
902 GetTestArchiveName() {
903 echo ${TESTS_ARCHIVE}
907 #@ PopulateFromSpecHarness <path> <benchmark>*
909 #@ populate a few essential directories (src, date) from
910 #@ the given spec2k harness
911 PopulateFromSpecHarness() {
914 cp -r ${harness}/bin .
915 local list=$(GetBenchmarkList "$@")
917 for i in ${list} ; do
918 SubBanner "Populating: $i"
919 # fix the dir with the same name inside spec harness
920 src=$(find -H ${harness} -name $i)
921 # copy relevant dirs over
924 cp -r ${src}/data ${src}/src $i
926 if [[ -e $i/diff ]] ; then
928 patch -d $i --verbose -p0 < $i/diff
936 #@ BuildPrerequisites <platform> <bitcode>
938 #@ Invoke scons to build some potentially missing components, e.g.
939 #@ sel_ldr, sel_universal, irt, some untrusted libraries.
940 #@ Those compoents should be present in the SDK but are not in the
941 #@ standard toolchain tarballs.
942 BuildPrerequisites() {
945 local extrabuild="${3-}"
946 local extra_flags="${4-}"
947 # Sel universal is only used for the pnacl sandboxed translator,
948 # but prepare it just in case.
949 # IRT is used both to run the tests and to run the pnacl sandboxed translator.
950 build-runtime "${platforms}" "sel_ldr sel_universal irt_core ${extrabuild}" \
952 if [ ${bitcode} == "bitcode" ] ; then
955 # libs may be unnecessary for the glibc build, but build it just in case.
956 build-libs-nacl "${platforms}"
961 #@ BuildPrerequisitesSetupBased <setup>
963 #@ Convenience wrapper for BuildPrerequisites
964 BuildPrerequisitesSetupBased() {
967 if [[ "$1" == SetupPnacl* ]] ; then
970 if [[ "$1" == Setup*Arm* ]] ; then
972 elif [[ "$1" == Setup*X8632* ]] ; then
974 elif [[ "$1" == Setup*X8664* ]] ; then
977 echo "Bad setup [$1]"
980 BuildPrerequisites "${platforms}" "${bitcode}"
982 ######################################################################
984 ######################################################################
986 [ $# = 0 ] && set -- help # Avoid reference to undefined $1.
988 if [ "$(type -t $1)" != "function" ]; then
990 echo "ERROR: unknown mode '$1'." >&2