aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2016-10-12 12:24:29 +0100
committerRenato Golin <renato.golin@linaro.org>2016-10-12 12:30:01 +0100
commit8ad9fca0a131c8eb68b1a656009e01925cecf1de (patch)
treed358701729c55c92b2c460359c09aef3c9909764
parent250b7aa1f79ef4377c7ae3e55560849db5b5bcf9 (diff)
[Cron] Add a new crontab builder for debug purposes
To investigate buildbot failures we rely on the ARM boards we have in the rack. But those boards take ~1h to build LLVM+Clang which does limit a lot on how fast we can test and act. To make that task easier, we decided to have a nightly build on the boards, for ARM and Thumb in debug mode, so we can start from a built tree, or at least a partially built tree if we need a more recent ToT. This script was made to work around crontab deficiencies and has been tested on my chromebook at home. It also makes sure it doesn't build if the script is already running or if the machine is busy or recuperating from a long build, as this may mean there's a bisection going on. Change-Id: I74f38c2ba874a4343bfcc9c24bcd8a157980c210
-rwxr-xr-xhelpers/llvm-cron-build81
1 files changed, 81 insertions, 0 deletions
diff --git a/helpers/llvm-cron-build b/helpers/llvm-cron-build
new file mode 100755
index 0000000..5ec4a4c
--- /dev/null
+++ b/helpers/llvm-cron-build
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+#
+# This script builds LLVM overnight in debug mode, so that daily investigations
+# of buildbot breakage can be done quickly without requiring a full build.
+#
+# The script is meant to be set on a cronjab for early morning build. It'll
+# default to debug build, as this is the most useful build for investigations.
+#
+# Syntax: env <environment variables> llvm-cron-build <environment-name>
+#
+# If the environment's name is "arm", it'll add -marm flags, if the name is
+# "thumb", it'll add -mthumb. Otherwise, it'll be a simple call to llvm-build.
+# Both ARM and Thumb builds will have "-mcpu=cortex-a15" added to match bots.
+#
+# Since these environments are just for debugging, we'll also force Clang+RT
+# projects, instead of leaving it free to choose.
+#
+# The environment variables tracked are CC/CXX and CFLAGS/CXXFLAGS.
+#
+# To install in the crontab every midnight, use:
+# 0 0 * * * bash -i <path-to-helpers>/llvm-cron-build <name>
+
+# Pre-run checks, make sure we only run when we can
+ROOT=$(dirname "$0")
+BIN=$(basename "$0")
+log="$HOME/$1.llvm-cron.log"
+err="$HOME/$1.llvm-cron.err"
+
+if [ "$1" = "" ]; then
+ echo "Syntax: $BIN <environment-name>" > "$err"
+ exit 1
+fi
+
+# Make sure we're not already running
+if [ "$(ps awwux | grep -v grep | grep "$BIN")" != "" ]; then
+ echo "Already running, won't flog" > "$err"
+ exit 1
+fi
+
+# Make sure machine is idle for long enough (load avg in cents)
+loadavg=$(awk '{print $1}' /proc/loadavg | sed -e 's/0*\.0*//')
+if [[ $loadavg -gt 100 ]]; then
+ echo "Machine too busy or still recuperating" > "$err"
+ exit 1
+fi
+
+# Crontab-specific, make sure the helpers directory is in the path
+if [ $(echo "$PATH" | grep "$ROOT") == "" ]; then
+ PATH="$PATH":"$ROOT"
+fi
+
+# Start the actual script
+. llvm-common
+
+# Update compiler flags
+case $1 in
+ arm)
+ CFLAGS="$CFLAGS -mcpu=cortex-a15 -marm"
+ CXXFLAGS="$CXXFLAGS -mcpu=cortex-a15 -marm"
+ ;;
+ thumb)
+ CFLAGS="$CFLAGS -mcpu=cortex-a15 -mthumb"
+ CXXFLAGS="$CXXFLAGS -mcpu=cortex-a15 -mthumb"
+ ;;
+ *)
+ ;;
+esac
+
+echo "Start date: $(date)" > "$log"
+
+PS1=" " # hack to trick llvm-env
+# Checkout the environment (create if doesn't exist) in debug mode
+safe_run . llvm-env "$1" -d >> "$log" 2>&1
+# Update the projects to Clang+RT
+safe_run llvm-projs rt >> "$log" 2>&1
+# Pull recent changes
+safe_run llvm-sync >> "$log" 2>&1
+# Call llvm-build (no tests wanted)
+env CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" llvm-build >> "$log" 2>&1
+
+echo "Finish date: $(date)" > "$log"