3 # This script will run all our supported compilers (see the "images" set)
4 # against gem5. The "ubuntu-20.04_all-dependencies" and "clang-version-9"
5 # images are run against all built targets. The remainder are evaluated
6 # against a random shuffling of built targets.
8 dir
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
10 build_dir
="${gem5_root}/build"
12 # All Docker images in the gem5 testing GCR which we want to compile with.
13 images
=("gcc-version-10"
27 # A subset of the above list: these images will build against every target,
28 # ignoring builds_per_compiler.
29 comprehensive
=("gcc-version-10"
32 # All build targets in build_opt/ which we want to build using each image.
34 "ARM_MESI_Three_Level"
39 "NULL_MOESI_CMP_directory"
40 "NULL_MOESI_CMP_token"
48 # The optimizations to use for each build target.
52 # The number of build targets to randomly pull from the build target list for
53 # each compiler. To perform a full comprehensive test which covers every
54 # possible pair of compiler and build target, set builds_per_compiler equal to
55 # the expression ${#builds[@]}.
58 # Base URL of the gem5 testing images.
59 base_url
="gcr.io/gem5-test"
61 # Arguments passed into scons on every build target test.
64 # Testing directory variables
65 mkdir
-p "${build_dir}" # Create the build directory if it doesn't exist.
66 test_dir_final
="${gem5_root}/compile-test-out"
67 test_dir
="${gem5_root}/.compile-test-out"
68 exits
="${test_dir}/exit-codes.csv"
70 # Create the testing output directory and files
71 rm -rf "${test_dir_final}"
75 echo "compiler,build_target,exit_code" >> "${exits}"
77 exit_code
=0 # We return a non-zero exit code if any of the compilations fail.
79 for compiler
in ${images[@]}; do
80 echo "Starting build tests with '${compiler}'..."
81 # Generate a randomized list of build targets
82 build_permutation
=($
(shuf
-i 0-$
((${#builds[@]} - 1)) ))
84 builds_count
=$builds_per_compiler
85 if [[ " ${comprehensive[@]} " =~
" $compiler " ]]; then
86 echo "'$compiler' was found in the comprehensive tests. All ISAs will be built."
87 builds_count
=${#builds[@]}
90 # Slice the first $builds_count entries of the permutation to get our
91 # targets for this test
92 build_indices
=(${build_permutation[@]:0:$builds_count})
94 repo_name
="${base_url}/${compiler}:latest"
97 docker pull
$repo_name >/dev
/null
99 mkdir
"${test_dir}/${compiler}"
101 for build_index
in ${build_indices[@]}; do
102 for build_opt
in ${opts[@]}; do
103 build
="${builds[$build_index]}"
104 build_out
="build/$build/gem5$build_opt"
105 build_stdout
="${test_dir}/${compiler}/${build}${build_opt}.stdout"
106 build_stderr
="${test_dir}/${compiler}/${build}${build_opt}.stderr"
109 rm -rf "${build_dir}"
111 touch "${build_stdout}"
112 touch "${build_stderr}"
114 echo " * Building target '${build}${build_opt}' with '${compiler}'..."
116 # Build with container
118 docker run
--rm -v "${gem5_root}":"/gem5" -u $UID:$GID \
119 -w /gem5
$repo_name scons
"${build_out}" "${build_args}"
120 }>"${build_stdout}" 2>"${build_stderr}"
123 echo "${compiler},${build}/gem5${build_opt},${result}" >>"${exits}"
125 if [ ${result} -ne 0 ]; then
127 echo " ! Failed with exit code ${result}."
135 mv "${test_dir}" "${test_dir_final}"