Skip to content

Commit 8334a0c

Browse files
committed
[sanitizer] Extract build_step function
1 parent 0751daa commit 8334a0c

File tree

8 files changed

+52
-48
lines changed

8 files changed

+52
-48
lines changed

zorg/buildbot/builders/sanitizers/buildbot_android.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CMAKE_COMMON_OPTIONS+=" -DLLVM_ENABLE_ASSERTIONS=ON"
2121

2222
build_stage2_android
2323

24-
echo @@@BUILD_STEP run cmake@@@
24+
build_step "run cmake"
2525
configure_android aarch64 aarch64-linux-android
2626
# Testing armv7 instead of plain arm to work around
2727
# https://code.google.com/p/android/issues/detail?id=68779

zorg/buildbot/builders/sanitizers/buildbot_android_functions.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function download_android_tools {
99
local FILE_NAME=${VERSION}-linux-x86_64.zip
1010
local NDK_URL=https://dl.google.com/android/repository/${FILE_NAME}
1111
if [[ "$(cat ${NDK_DIR}/android_ndk_url)" != ${NDK_URL} ]] ; then
12-
echo @@@BUILD_STEP downloading Android NDK@@@
12+
build_step "downloading Android NDK"
1313
[[ -d ${NDK_DIR} ]] && rm -rf ${NDK_DIR}
1414
[[ -d ${VERSION} ]] && rm -rf ${VERSION}
1515
[[ -f ${FILE_NAME} ]] && rm -f ${FILE_NAME}
@@ -20,7 +20,7 @@ function download_android_tools {
2020
fi
2121

2222
if [[ ! -d platform-tools ]] ; then
23-
echo @@@BUILD_STEP downloading Android Platform Tools@@@
23+
build_step "downloading Android Platform Tools"
2424
local FILE_NAME=platform-tools-latest-linux.zip
2525
[[ -f ${FILE_NAME} ]] && rm -f ${FILE_NAME}
2626
wget -e dotbytes=10m https://dl.google.com/android/repository/${FILE_NAME}
@@ -34,7 +34,7 @@ function build_stage2_android() {
3434
local CMAKE_OPTIONS="${CMAKE_COMMON_OPTIONS} -DLLVM_ENABLE_WERROR=ON ${STAGE1_AS_COMPILER}"
3535
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DLLVM_ENABLE_PROJECTS='clang;lld' -DCLANG_DEFAULT_RTLIB=libgcc"
3636

37-
echo @@@BUILD_STEP bootstrap clang@@@
37+
build_step "bootstrap clang"
3838
mkdir -p llvm_build64
3939
if [[ "$(cat llvm_build64/CMAKE_OPTIONS)" != "${CMAKE_OPTIONS}" ]] ; then
4040
(cd llvm_build64 && cmake ${CMAKE_OPTIONS} $LLVM && \
@@ -105,7 +105,7 @@ BUILD_RT_ERR=""
105105
function build_android {
106106
local _arch=$1
107107
wait
108-
echo @@@BUILD_STEP build android/$_arch@@@
108+
build_step "build android/$_arch"
109109
if ! ninja -C llvm_build_android_$_arch llvm-symbolizer ; then
110110
BUILD_RT_ERR="${BUILD_RT_ERR}|${_arch}|"
111111
build_failure
@@ -134,7 +134,7 @@ function patch_abilist { # IN OUT
134134

135135
function restart_adb_server {
136136
ADB=adb
137-
echo @@@BUILD_STEP restart adb server@@@
137+
build_step "restart adb server"
138138
$ADB kill-server
139139
sleep 2
140140
$ADB start-server
@@ -184,7 +184,7 @@ function test_android {
184184
fi
185185

186186
ADB=adb
187-
echo @@@BUILD_STEP run all tests@@@
187+
build_step "run all tests"
188188
ANDROID_DEVICES=$(${ADB} devices | grep 'device$' | sort -r | awk '{print $1}')
189189

190190
rm -rf test_android_log_*
@@ -200,7 +200,7 @@ function test_android {
200200
for _arg in "$@"; do
201201
local _arch=${_arg%:*}
202202
if [[ ! -f tested_arch_$_arch ]]; then
203-
echo @@@BUILD_STEP unavailable device android/$_arch@@@
203+
build_step "unavailable device android/$_arch"
204204
echo @@@STEP_EXCEPTION@@@
205205
fi
206206
done
@@ -220,7 +220,7 @@ function run_tests_sharded {
220220

221221
local NUM_SHARDS=4
222222
local _log_prefix=$(mktemp shards_XXXX_)
223-
echo @@@BUILD_STEP run $_test_name tests [$DEVICE_DESCRIPTION]@@@
223+
build_step "run $_test_name tests [$DEVICE_DESCRIPTION]"
224224
LOGS=
225225
for ((SHARD=0; SHARD < $NUM_SHARDS; SHARD++)); do
226226
LOG=${_log_prefix}_$SHARD
@@ -253,7 +253,7 @@ function test_arch_on_device {
253253
export ANDROID_SERIAL=$_serial
254254
echo "Serial $_serial"
255255

256-
echo @@@BUILD_STEP device setup [$DEVICE_DESCRIPTION]@@@
256+
build_step "device setup [$DEVICE_DESCRIPTION]"
257257
$ADB wait-for-device
258258
$ADB devices
259259
$ADB shell getprop ro.build.version.release
@@ -276,7 +276,7 @@ function test_arch_on_device {
276276
done
277277
wait
278278

279-
echo @@@BUILD_STEP run lit tests [$DEVICE_DESCRIPTION]@@@
279+
build_step "run lit tests [$DEVICE_DESCRIPTION]"
280280
(cd $COMPILER_RT_BUILD_DIR && ninja check-all) || build_failure
281281

282282
run_tests_sharded sanitizer_common SanitizerTest ""

zorg/buildbot/builders/sanitizers/buildbot_bisect_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ HERE="$(cd $(dirname $0) && pwd)"
1111

1212
BUILDBOT_REVISION=origin/main buildbot_update
1313

14-
echo @@@BUILD_STEP bisecting ${BUILDBOT_REVISION}@@@
14+
build_step "bisecting ${BUILDBOT_REVISION}"
1515

1616
# Try to get them out from the bisect string in BUILDBOT_REVISION first.
1717
GOOD="${BUILDBOT_REVISION/:*/}"
@@ -34,7 +34,7 @@ cd "${LLVM}/.."
3434
git bisect run bash -c "cd $ROOT && $*"
3535
fi
3636

37-
echo @@@BUILD_STEP bisect result@@@
37+
build_step "bisect result"
3838
git bisect log
3939
) || true
4040

zorg/buildbot/builders/sanitizers/buildbot_cmake.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function build {
5959
BUILD_DIR="build_${1}"
6060
fi
6161

62-
echo "@@@BUILD_STEP build compiler-rt ${1}@@@"
62+
build_step "build compiler-rt ${1}"
6363
[[ ! -f "${BUILD_DIR}/delete_next_time" ]] || rm -rf "${BUILD_DIR}"
6464
mkdir -p ${BUILD_DIR}
6565

@@ -76,7 +76,7 @@ function build {
7676
function build_and_test {
7777
build "${1}" "${2}"
7878

79-
echo "@@@BUILD_STEP test compiler-rt ${1}@@@"
79+
build_step "test compiler-rt ${1}"
8080
ninja -C ${BUILD_DIR} check-compiler-rt || build_failure
8181
}
8282

@@ -98,7 +98,7 @@ build_and_test "default" ""
9898

9999
FRESH_CLANG_PATH=${ROOT}/${BUILD_DIR}/bin
100100

101-
echo @@@BUILD_STEP build standalone compiler-rt@@@
101+
build_step "build standalone compiler-rt"
102102
mkdir -p compiler_rt_build
103103
# Standalone build as in https://compiler-rt.llvm.org/
104104
cmake -B compiler_rt_build -GNinja \
@@ -110,12 +110,12 @@ cmake -B compiler_rt_build -GNinja \
110110
$LLVM/../compiler-rt || build_failure
111111
ninja -C compiler_rt_build || build_failure
112112

113-
echo @@@BUILD_STEP test standalone compiler-rt@@@
113+
build_step "test standalone compiler-rt"
114114
ninja -C compiler_rt_build check-all || build_failure
115115

116116
if [ "$CHECK_TSAN" == "1" ]; then
117117
# FIXME: Convert to a LIT test.
118-
echo @@@BUILD_STEP tsan analyze@@@
118+
build_step "tsan analyze"
119119
BIN=tsan_bin
120120
echo "int main() {return 0;}" | ${FRESH_CLANG_PATH}/clang -x c++ - -fsanitize=thread -O2 -o ${BIN}
121121
$LLVM/../compiler-rt/lib/tsan/check_analyze.sh ${BIN} || build_failure

zorg/buildbot/builders/sanitizers/buildbot_fast.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ HERE="$(cd $(dirname $0) && pwd)"
55

66
# TODO: find a better way to disable cleanup.
77
function cleanup() {
8-
echo @@@BUILD_STEP cleanup@@@
8+
build_step "cleanup"
99
# Workaround the case when a new unittest was reverted, but incremental build continues to execute the leftover binary.
1010
find -executable -type f -wholename *unittests* -delete
1111
du -hs * | sort -h

zorg/buildbot/builders/sanitizers/buildbot_functions.sh

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ fi
2424

2525
SANITIZER_LOG_DIR=$ROOT/sanitizer_logs
2626

27+
function build_step() {
28+
echo "@@@BUILD_STEP ""$@""@@"
29+
}
30+
2731
function include_config() {
2832
local P=.
2933
while true ; do
@@ -39,7 +43,7 @@ function include_config() {
3943

4044
include_config
4145

42-
echo @@@BUILD_STEP Info@@@
46+
build_step "Info"
4347
(
4448
set +e
4549
date
@@ -66,7 +70,7 @@ echo @@@BUILD_STEP Info@@@
6670
hostname -f
6771
)
6872

69-
echo @@@BUILD_STEP Prepare@@@
73+
build_step "Prepare"
7074

7175
export LIT_OPTS="--time-tests"
7276
# --timeout requires psutil missing on some bots.
@@ -89,7 +93,7 @@ function rm_dirs {
8993

9094
function cleanup() {
9195
[[ -v BUILDBOT_BUILDERNAME ]] || return 0
92-
echo @@@BUILD_STEP cleanup@@@
96+
build_step "cleanup"
9397
rm_dirs llvm_build2_* llvm_build_* libcxx_build_* libcxx_install_* compiler_rt_build* symbolizer_build* "$@"
9498
if ccache -s >/dev/null ; then
9599
rm_dirs llvm_build64
@@ -101,7 +105,7 @@ function cleanup() {
101105

102106
function clobber {
103107
if [[ "$BUILDBOT_CLOBBER" != "" ]]; then
104-
echo @@@BUILD_STEP clobber@@@
108+
build_step "clobber"
105109
if [[ ! -v BUILDBOT_BUILDERNAME ]]; then
106110
echo "Clobbering is supported on buildbot only!"
107111
exit 1
@@ -119,7 +123,7 @@ BUILDBOT_MONO_REPO_PATH=${BUILDBOT_MONO_REPO_PATH:-}
119123

120124
function buildbot_update {
121125
if [[ "${BUILDBOT_BISECT_MODE:-}" == "1" ]]; then
122-
echo "@@@BUILD_STEP bisect status@@@"
126+
build_step "bisect status"
123127
(
124128
cd llvm-project
125129
git bisect visualize --oneline
@@ -129,7 +133,7 @@ function buildbot_update {
129133
LLVM=$ROOT/llvm-project/llvm
130134
return 0
131135
fi
132-
echo "@@@BUILD_STEP update $BUILDBOT_REVISION@@@"
136+
build_step "update $BUILDBOT_REVISION"
133137
if [[ -d "$BUILDBOT_MONO_REPO_PATH" ]]; then
134138
LLVM=$BUILDBOT_MONO_REPO_PATH/llvm
135139
else
@@ -163,7 +167,7 @@ function buildbot_update {
163167

164168
function print_sanitizer_logs() {
165169
if compgen -G "${SANITIZER_LOG_DIR}"/* ; then
166-
echo @@@BUILD_STEP sanitizer logs@@@
170+
build_step "sanitizer logs"
167171
head -n -1 "${SANITIZER_LOG_DIR}"/*
168172
buildbot_build && rm -rf "${SANITIZER_LOG_DIR}"/*
169173
build_warning
@@ -207,7 +211,7 @@ function build_stage1_clang_impl {
207211
}
208212

209213
function build_stage1_clang {
210-
echo @@@BUILD_STEP stage1 build all@@@
214+
build_step "stage1 build all"
211215
common_stage1_variables
212216
build_stage1_clang_impl
213217
}
@@ -218,7 +222,7 @@ function download_clang_from_chromium {
218222
curl -s https://raw.githubusercontent.com/chromium/chromium/main/tools/clang/scripts/update.py \
219223
| python3 - --output-dir=${STAGE1_DIR}
220224

221-
echo @@@BUILD_STEP using pre-built stage1 clang at $(cat ${STAGE1_DIR}/cr_build_revision)@@@
225+
build_step "using pre-built stage1 clang at $(cat ${STAGE1_DIR}/cr_build_revision)"
222226
}
223227

224228
function build_clang_at_release_tag {
@@ -235,12 +239,12 @@ function build_clang_at_release_tag {
235239
if [ -r ${STAGE1_DIR}/host_clang_revision ] && \
236240
[ "$(cat ${STAGE1_DIR}/host_clang_revision)" == $host_clang_revision ]
237241
then
238-
echo "@@@BUILD_STEP using pre-built stage1 clang at r${host_clang_revision}@@@"
242+
build_step "using pre-built stage1 clang at r${host_clang_revision}"
239243
else
240244
SKIP_OLD=0 BUILDBOT_MONO_REPO_PATH="" BUILDBOT_REVISION="${host_clang_revision}" buildbot_update
241245

242246
rm -rf ${STAGE1_DIR}
243-
echo @@@BUILD_STEP build stage1 clang at $host_clang_revision@@@
247+
build_step "build stage1 clang at $host_clang_revision"
244248
# PGO, can improve build time by 10%. However bots spend most of the time
245249
# running tests and compilation mostly incremental or CCCACH-ed.
246250
build_stage1_clang_impl && \
@@ -258,7 +262,7 @@ function common_stage2_variables {
258262

259263
function build_stage2 {
260264
local sanitizer_name=$1
261-
echo @@@BUILD_STEP stage2/$sanitizer_name build libcxx@@@
265+
build_step "stage2/$sanitizer_name build libcxx"
262266

263267
local libcxx_build_dir=libcxx_build_${sanitizer_name}
264268
local libcxx_install_dir=libcxx_install_${sanitizer_name}
@@ -348,7 +352,7 @@ function build_stage2 {
348352
local sanitizer_ldflags="-Wl,--rpath=${libcxx_runtime_path} -L${libcxx_runtime_path}"
349353
local sanitizer_cflags="-nostdinc++ -isystem ${ROOT}/${libcxx_install_dir}/include -isystem ${ROOT}/${libcxx_install_dir}/include/c++/v1 $fsanitize_flag"
350354

351-
echo @@@BUILD_STEP stage2/$sanitizer_name build@@@
355+
build_step "stage2/$sanitizer_name build"
352356

353357
# See http://llvm.org/bugs/show_bug.cgi?id=19071, http://www.cmake.org/Bug/view.php?id=15264
354358
sanitizer_cflags+=" $sanitizer_ldflags -w"
@@ -434,7 +438,7 @@ function check_stage2 {
434438
if [[ "${STAGE2_SKIP_TEST_CXX:-}" != "1" ]] ; then
435439
(
436440
LIT_OPTS+=" --timeout=1500"
437-
echo @@@BUILD_STEP stage2/$sanitizer_name check-cxx@@@
441+
build_step "stage2/$sanitizer_name check-cxx"
438442
# Very slow.
439443
export LIT_FILTER_OUT="std/utilities/format/format.functions/format.locale.runtime_format.pass.cpp"
440444
LIT_FILTER_OUT+="|std/utilities/format/format.functions/format.runtime_format.pass.cpp"
@@ -466,7 +470,7 @@ function check_stage2 {
466470
)
467471
fi
468472

469-
echo @@@BUILD_STEP stage2/$sanitizer_name check@@@
473+
build_step "stage2/$sanitizer_name check"
470474
run_ninja -C ${STAGE2_DIR} check-all
471475
}
472476

@@ -496,7 +500,7 @@ function check_stage2_asan_ubsan {
496500

497501
function build_stage3 {
498502
local sanitizer_name=$1
499-
echo @@@BUILD_STEP build stage3/$sanitizer_name build@@@
503+
build_step "build stage3/$sanitizer_name build"
500504

501505
local build_dir=llvm_build2_${sanitizer_name}
502506

@@ -547,7 +551,7 @@ function build_stage3_ubsan {
547551

548552
function check_stage3 {
549553
local sanitizer_name=$1
550-
echo @@@BUILD_STEP stage3/$sanitizer_name check@@@
554+
build_step "stage3/$sanitizer_name check"
551555

552556
local build_dir=llvm_build2_${sanitizer_name}
553557

zorg/buildbot/builders/sanitizers/buildbot_fuzzer.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ build_stage1_clang
2424
# export ASAN_SYMBOLIZER_PATH="${llvm_symbolizer_path}"
2525
export PATH="$(readlink -f ${STAGE1_DIR}/bin):$PATH"
2626

27-
echo @@@BUILD_STEP get fuzzer-test-suite @@@
27+
build_step "get fuzzer-test-suite "
2828
[ ! -e fuzzer-test-suite ] && git clone https://github.com/google/fuzzer-test-suite.git
2929
(cd fuzzer-test-suite && git pull)
3030

3131
RunFuzzerTest() {
32-
echo @@@BUILD_STEP test "$1" fuzzer@@@
32+
build_step "test "$1" fuzzer"
3333
ln -sf $LIBFUZZER .
3434
export FUZZING_ENGINE=fsanitize_fuzzer
3535
`pwd`/fuzzer-test-suite/build-and-test.sh "$1"

0 commit comments

Comments
 (0)