diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-11-07 17:09:52 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-11-14 09:42:22 +0000 |
commit | 8ba084e4586a883068b369ccf6cec557b23adf07 (patch) | |
tree | 68cef6c225d7483575c687cbc5f4b92329870396 /tcwg_kernel-build.sh | |
parent | c1566d008db7de7c8e4bde37b73174c9e999f556 (diff) |
tcwg_kernel-build.sh: Fill build_linux and count_linux_objs
Change-Id: I9cddd58582afd36e9dd6c10273c2d175dd9c076a
Diffstat (limited to 'tcwg_kernel-build.sh')
-rwxr-xr-x | tcwg_kernel-build.sh | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tcwg_kernel-build.sh b/tcwg_kernel-build.sh index abfac6b3..fe217607 100755 --- a/tcwg_kernel-build.sh +++ b/tcwg_kernel-build.sh @@ -380,12 +380,95 @@ build_llvm () ) } +# Build Linux kernel build_linux () { + ( + set -euf -o pipefail + + clone_repo linux + + rm -rf $(pwd)/bin + mkdir $(pwd)/bin + + case "$toolchain" in + llvm) + bin="$(pwd)/llvm-install/bin" + cc="$bin/clang" + ;; + gnu) + bin="$(pwd)/abe/builds/destdir/x86_64-unknown-linux-gnu/bin" + cc="$bin/$(print_gnu_target $target)-gcc" + ;; + esac + + # Use binutils, etc from $bin + export PATH="$bin:$PATH" + + # Use ccache only when bisecting linux. Otherwise the compiler is + # new in every build and we would only clobber ccache volume. + local ccache="" + if [ x"$mode" = x"bisect" -a x"$current_project" = x"linux" ]; then + ccache="ccache" + fi + cat > $(pwd)/bin/$target-cc <<EOF +#!/bin/sh +exec $ccache $cc "\$@" +EOF + chmod +x $(pwd)/bin/$target-cc + + # Define make variables. + opts="CC=$(pwd)/bin/$target-cc" + if [ x"$target" != x"native" ]; then + opts="$opts ARCH=$(print_kernel_target $target)" + opts="$opts CROSS_COMPILE=$(print_gnu_target $target)-" + opts="$opts HOSTCC=gcc" + fi + + cd ${git_dirs[linux]} + + make $opts distclean + + make $opts $linux_config + + ccache -z + make $opts -j$(nproc --all) -s -k & + res=0 && wait $! || res=$? + ccache -s + return $res + ) } +# Count number successfully built .o files in linux (and build linux) count_linux_objs () { + ( + set -euf -o pipefail + + # Run only if compiler was successfully built in the previous step. + if [ -f $run_step_prev_artifacts/build-ok ]; then + build_linux & + res=0; wait $! || res=$? + + # Number of .o files created is the main success metric. + echo "linux_n_obj:" >> $top_artifacts/results + if [ $res != 0 ]; then + local linux_n_obj + linux_n_obj=$(find ${git_dirs[linux]} -name "*.o" | wc -l) + echo "$linux_n_obj" >> $top_artifacts/results + else + echo "all" >> $top_artifacts/results + fi + + if $tidy; then + git_clean linux + fi + fi + + if $tidy; then + rm -rf abe/builds llvm-install + fi + ) } no_regression_p () |