diff options
Diffstat (limited to 'tcwg_kernel-build.sh')
-rwxr-xr-x | tcwg_kernel-build.sh | 103 |
1 files changed, 65 insertions, 38 deletions
diff --git a/tcwg_kernel-build.sh b/tcwg_kernel-build.sh index 42ed4a55..53efe1b2 100755 --- a/tcwg_kernel-build.sh +++ b/tcwg_kernel-build.sh @@ -13,14 +13,14 @@ convert_args_to_variables "$@" obligatory_variables rr[ci_config] declare -A rr -# Execution mode: baseline, bisect, jenkins-full -rr[mode]="${rr[mode]-baseline}" +# Execution mode: build or bisect +rr[mode]="${rr[mode]-build}" # Set custom revision for one of the projects, and use baseline revisions # for all other projects. rr[ci_project]="${rr[ci_project]-tcwg_kernel}" rr[baseline_branch]="${rr[baseline_branch]-linaro-local/ci/${rr[ci_project]}/${rr[ci_config]}}" -rr[update_baseline]="${rr[update_baseline]-update}" +rr[update_baseline]="${rr[update_baseline]-ignore}" rr[top_artifacts]="${rr[top_artifacts]-$(pwd)/artifacts}" # {toolchain_name}-{toolchain_ver}-{target}-{linux}-{linux_config} @@ -28,9 +28,12 @@ IFS=- read -a ci_config <<EOF ${rr[ci_config]} EOF rr[toolchain]=${rr[toolchain]-${ci_config[0]}} -rr[release]=${rr[release]-${ci_config[1]}} rr[target]=${rr[target]-${ci_config[2]}} -rr[linux_config]=${rr[linux_config]-${ci_config[4]}} +linux_config=${linux_config-${ci_config[4]}} + +# Artifacts version +rr[major]=4 +rr[minor]=0 case "${rr[toolchain]}" in llvm) @@ -58,21 +61,16 @@ trap print_traceback EXIT default_start_at="" default_finish_at="" case "${rr[mode]}" in - "baseline") - default_finish_at="update_baseline" - ;; "bisect") case "$(print_single_updated_component)" in binutils) default_start_at="build_abe-binutils" ;; gcc) default_start_at="build_abe-stage1" ;; - llvm) default_start_at="build_llvm" ;; + llvm) default_start_at="build_kernel_llvm" ;; linux) default_start_at="build_linux" ;; qemu) default_start_at="build_abe-qemu" ;; *) assert false ;; esac - default_finish_at="check_regression" ;; - "jenkins-full") ;; esac if [ x"$start_at" = x"default" ]; then start_at="$default_start_at" @@ -83,6 +81,30 @@ fi run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose" +# Build LLVM for building Linux kernel +build_kernel_llvm () +{ + ( + set -euf -o pipefail + + local host target extra_targets="" + + host=$(print_llvm_target native) + target=$(print_llvm_target ${rr[target]}) + + if [ x"$target" != x"$host" ]; then + # We need $host target for HOSTCC + extra_targets="$extra_targets;$host" + fi + if [ x"$target" = x"AArch64" ]; then + # We need 32-bit ARM target to compile vdso32 + extra_targets="$extra_targets;ARM" + fi + + build_llvm "clang;lld" "$extra_targets" + ) +} + # Build Linux kernel build_linux_1 () { @@ -97,7 +119,7 @@ build_linux_1 () rm -rf "$(pwd)"/bin mkdir "$(pwd)"/bin - local gnu_host abe_bin cc ld_opt="" + local gnu_host abe_bin cc ld hostcc ld_opt="" gnu_host=$(print_gnu_target native) abe_bin="$(pwd)/abe/builds/destdir/$gnu_host/bin" @@ -114,19 +136,25 @@ build_linux_1 () export PATH="$llvm_bin:$PATH" cc="$llvm_bin/clang" - ld_opt="LD=$llvm_bin/ld.lld" + ld="$llvm_bin/ld.lld" + hostcc="$cc" + + ld_opt="LD=$ld" ;; gnu) cc="$abe_bin/$(print_gnu_target ${rr[target]})-gcc" + ld="$abe_bin/$(print_gnu_target ${rr[target]})-ld" + hostcc=gcc ;; esac + echo -n "Compiler: "; $cc --version | head -n1 + echo -n "Linker: "; $ld --version | head -n1 # Use ccache only when bisecting linux or qemu (or preparing to). # Otherwise the compiler is new in every build and we would # only clobber ccache volume. local ccache="" case "${rr[mode]}:$(print_single_updated_component)" in - "baseline:") ccache="ccache" ;; "bisect:linux") ccache="ccache" ;; "bisect:qemu") ccache="ccache" ;; esac @@ -142,14 +170,15 @@ EOF if [ x"${rr[target]}" != x"$(uname -m)" ]; then opts="$opts ARCH=$(print_kernel_target ${rr[target]})" opts="$opts CROSS_COMPILE=$(print_gnu_target ${rr[target]})-" - opts="$opts HOSTCC=gcc" + opts="$opts HOSTCC=$hostcc" + echo -n "Host cc: "; $cc --version | head -n1 fi cd linux make $opts distclean - make $opts ${rr[linux_config]} + make $opts $linux_config sed -i -e 's:CONFIG_LOCALVERSION_AUTO=y:# CONFIG_LOCALVERSION_AUTO is not set:' .config set +f; rm -f localversion*; set -f make $opts oldconfig @@ -253,6 +282,24 @@ no_regression_p () if [ x"$res" = x"" ]; then res=$build_res + + # Handle a corner case when a linux commit removes a few + # files from the tree, causing number of object to decrease. + # We do not consider it a regression when the count of object + # files decreases by less than 1%. + if [ x"$res" != x"0" ]; then + if [ x"$(print_single_updated_component)" = x"linux" ] \ + && [ $linux_n_obj -gt 0 ] \ + && [ $linux_n_obj -lt $base_linux_n_obj ]; then + local ratio + ratio=$(($base_linux_n_obj - $linux_n_obj)) + ratio=$((100 * $ratio / $base_linux_n_obj)) + if [ $ratio = 0 ]; then + # Difference in object count is less than 1%. + res=0 + fi + fi + fi fi fi @@ -260,25 +307,7 @@ no_regression_p () ) } -# Implement rr[breakup_updated_components] hook. -tcwg_kernel_breakup_updated_components () -{ - ( - set -euf -o pipefail - - # Linux changes tend to cause the most regressions. - # Breakup updated components into linux and the rest of components - # to reduce the number of builds. - if print_updated_components "\n" | grep -q "^linux\$"; then - echo "linux" - print_updated_components "\n" | grep -v "^linux\$" | tr '\n' ' ' | sed -e "s/ \$//g" - echo - else - print_updated_components "\n" - fi - ) -} -rr[breakup_updated_components]=tcwg_kernel_breakup_updated_components +rr[breakup_changed_components]="breakup_changed_components linux" run_step stop_on_fail -10 reset_artifacts run_step stop_on_fail x prepare_abe @@ -288,14 +317,12 @@ case "${rr[toolchain]}" in run_step skip_on_fail -5 build_abe stage1 ;; llvm) - run_step skip_on_fail -5 build_llvm + run_step skip_on_fail -5 build_kernel_llvm ;; esac run_step skip_on_fail -2 build_abe qemu run_step skip_on_fail x build_linux run_step skip_on_fail x boot_linux run_step reset_on_fail x check_regression -run_step stop_on_fail x update_baseline -run_step stop_on_fail x push_baseline trap "" EXIT |