4
4
5
5
ulimit -Ss 12288
6
6
7
- ROOT=` pwd`
7
+ ROOT=$( pwd)
8
8
LLVM=$ROOT /llvm-project/llvm
9
9
10
10
BUILDBOT_CLOBBER=" ${BUILDBOT_CLOBBER:- } "
25
25
SANITIZER_LOG_DIR=$ROOT /sanitizer_logs
26
26
27
27
function build_step() {
28
- echo " @@@BUILD_STEP " " $@ " " @@@"
29
- CURRENT_STEP=" $@ "
28
+ echo " @@@BUILD_STEP ${1} @@@"
29
+ CURRENT_STEP=" ${1} "
30
30
}
31
31
32
32
function include_config() {
33
33
local P=.
34
34
while true ; do
35
35
local F=${P} /sanitizer_buildbot_config
36
36
if [[ -f ${F} ]] ; then
37
+ # shellcheck source=/dev/null
37
38
. ${F}
38
39
break
39
40
fi
@@ -100,7 +101,7 @@ function cleanup() {
100
101
rm_dirs llvm_build64
101
102
fi
102
103
# Workaround the case when a new unittest was reverted, but incremental build continues to execute the leftover binary.
103
- find -path ./llvm-project -prune -o -executable -type f -path ' *unittests*' -print -exec rm -f {} \;
104
+ find . -path ./llvm-project -prune -o -executable -type f -path ' *unittests*' -print -exec rm -f {} \;
104
105
du -hs ./* | sort -h
105
106
}
106
107
@@ -112,7 +113,7 @@ function clobber {
112
113
exit 1
113
114
fi
114
115
# Keep sources in ./llvm-project and ./llvm_build0 for faster builds.
115
- find -maxdepth 1 -mindepth 1 -path ./llvm-project -prune -o -path ./llvm_build0 -prune -o -print -exec rm -rf {} \;
116
+ find . -maxdepth 1 -mindepth 1 -path ./llvm-project -prune -o -path ./llvm_build0 -prune -o -print -exec rm -rf {} \;
116
117
du -hs ./* | sort -h
117
118
return 0
118
119
else
@@ -139,7 +140,6 @@ function buildbot_update {
139
140
LLVM=$BUILDBOT_MONO_REPO_PATH /llvm
140
141
else
141
142
(
142
- local DEPTH=100
143
143
[[ -d llvm-project ]] || (
144
144
mkdir -p llvm-project
145
145
cd llvm-project
@@ -170,7 +170,8 @@ function print_sanitizer_logs() {
170
170
if compgen -G " ${SANITIZER_LOG_DIR} " /* ; then
171
171
build_step " sanitizer logs: ${CURRENT_STEP} "
172
172
head -n -1 " ${SANITIZER_LOG_DIR} " /*
173
- buildbot_build && rm -rf " ${SANITIZER_LOG_DIR} " /*
173
+ buildbot_build && rm -rf " ${SANITIZER_LOG_DIR} "
174
+ mkdir -p " ${SANITIZER_LOG_DIR} "
174
175
build_warning
175
176
fi
176
177
}
@@ -179,11 +180,11 @@ function print_sanitizer_logs() {
179
180
function run_ninja() {
180
181
env
181
182
local ec=0
182
- /usr/bin/time -o ${ROOT} /time.txt -- ninja " $@ " || ec=$?
183
+ /usr/bin/time -o " ${ROOT} /time.txt" -- ninja " $@ " || ec=$?
183
184
buildbot_build || print_sanitizer_logs
184
185
if [[ $ec -ne 0 ]] ; then
185
186
build_failure
186
- rm -f ${ROOT} /time.txt
187
+ rm -f " ${ROOT} /time.txt"
187
188
fi
188
189
print_sanitizer_logs
189
190
}
@@ -198,7 +199,7 @@ function common_stage1_variables {
198
199
199
200
function build_stage1_clang_impl {
200
201
[[ ! -f " ${STAGE1_DIR} /delete_next_time" ]] || rm -rf " ${STAGE1_DIR} "
201
- mkdir -p ${STAGE1_DIR}
202
+ mkdir -p " ${STAGE1_DIR} "
202
203
local cmake_stage1_options=" ${CMAKE_COMMON_OPTIONS} "
203
204
cmake_stage1_options+=" -DLLVM_ENABLE_PROJECTS='clang;lld'"
204
205
cmake_stage1_options+=" -DLLVM_ENABLE_RUNTIMES='compiler-rt;libunwind;libcxx;libcxxabi'"
@@ -229,16 +230,17 @@ function download_clang_from_chromium {
229
230
function build_clang_at_release_tag {
230
231
common_stage1_variables
231
232
232
- local host_clang_revision=llvmorg-$(
233
+ local host_clang_revision
234
+ host_clang_revision=llvmorg-$(
233
235
git ls-remote --tags https://github.com/llvm/llvm-project.git | \
234
236
grep -oE " refs/tags/llvmorg-[0-9.]+$" | \
235
237
grep -Eo " [0-9.]+" | \
236
238
sort -n | \
237
239
tail -n1
238
240
)
239
241
240
- if [ -r ${STAGE1_DIR} /host_clang_revision ] && \
241
- [ " $( cat ${STAGE1_DIR} /host_clang_revision) " == $host_clang_revision ]
242
+ if [ -r " ${STAGE1_DIR} /host_clang_revision" ] && \
243
+ [ " $( cat " ${STAGE1_DIR} /host_clang_revision" ) " == " $host_clang_revision " ]
242
244
then
243
245
build_step " using pre-built stage1 clang at r${host_clang_revision} "
244
246
else
@@ -249,7 +251,7 @@ function build_clang_at_release_tag {
249
251
# PGO, can improve build time by 10%. However bots spend most of the time
250
252
# running tests and compilation mostly incremental or CCCACH-ed.
251
253
build_stage1_clang_impl && \
252
- ( echo $host_clang_revision > ${STAGE1_DIR} /host_clang_revision )
254
+ ( echo " $host_clang_revision " > " ${STAGE1_DIR} /host_clang_revision" )
253
255
fi
254
256
}
255
257
@@ -334,8 +336,8 @@ function build_stage2 {
334
336
exit 1
335
337
fi
336
338
337
- mkdir -p ${libcxx_build_dir}
338
- cmake -B ${libcxx_build_dir} \
339
+ mkdir -p " ${libcxx_build_dir} "
340
+ cmake -B " ${libcxx_build_dir} " \
339
341
${cmake_stage2_common_options} \
340
342
${cmake_options} \
341
343
-DCMAKE_INSTALL_PREFIX=" ${ROOT} /${libcxx_install_dir} " \
@@ -345,14 +347,16 @@ function build_stage2 {
345
347
-DLLVM_USE_SANITIZER=${llvm_use_sanitizer} \
346
348
-DCMAKE_C_FLAGS=" ${fsanitize_flag} ${cmake_libcxx_cflags} ${fno_sanitize_flag} " \
347
349
-DCMAKE_CXX_FLAGS=" ${fsanitize_flag} ${cmake_libcxx_cflags} ${fno_sanitize_flag} " \
348
- $LLVM /../runtimes || build_failure
350
+ " $LLVM /../runtimes" || build_failure
349
351
350
- run_ninja -C ${libcxx_build_dir}
351
- run_ninja -C ${libcxx_build_dir} install
352
+ run_ninja -C " ${libcxx_build_dir} "
353
+ run_ninja -C " ${libcxx_build_dir} " install
352
354
353
- local libcxx_so_path=" $( find " ${ROOT} /${libcxx_install_dir} " -name libc++.so) "
355
+ local libcxx_so_path
356
+ libcxx_so_path=" $( find " ${ROOT} /${libcxx_install_dir} " -name libc++.so) "
354
357
test -f " ${libcxx_so_path} " || build_failure
355
- local libcxx_runtime_path=$( dirname " ${libcxx_so_path} " )
358
+ local libcxx_runtime_path
359
+ libcxx_runtime_path=$( dirname " ${libcxx_so_path} " )
356
360
357
361
local sanitizer_ldflags=" -Wl,--rpath=${libcxx_runtime_path} -L${libcxx_runtime_path} "
358
362
local sanitizer_cflags=" -nostdinc++ -isystem ${ROOT} /${libcxx_install_dir} /include -isystem ${ROOT} /${libcxx_install_dir} /include/c++/v1 $fsanitize_flag "
@@ -362,26 +366,26 @@ function build_stage2 {
362
366
# See http://llvm.org/bugs/show_bug.cgi?id=19071, http://www.cmake.org/Bug/view.php?id=15264
363
367
sanitizer_cflags+=" $sanitizer_ldflags -w"
364
368
365
- mkdir -p ${build_dir}
369
+ mkdir -p " ${build_dir} "
366
370
local cmake_stage2_clang_options=" -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra;mlir'"
367
371
if [[ " $( arch) " == " aarch64" ]] ; then
368
372
# FIXME: clangd tests fail.
369
373
cmake_stage2_clang_options=" -DLLVM_ENABLE_PROJECTS='clang;lld;mlir'"
370
374
fi
371
- cmake -B ${build_dir} \
375
+ cmake -B " ${build_dir} " \
372
376
${cmake_stage2_common_options} \
373
377
${cmake_stage2_clang_options} \
374
378
-DLLVM_USE_SANITIZER=${llvm_use_sanitizer} \
375
379
-DLLVM_ENABLE_LIBCXX=ON \
376
380
-DCMAKE_C_FLAGS=" ${sanitizer_cflags} " \
377
381
-DCMAKE_CXX_FLAGS=" ${sanitizer_cflags} " \
378
382
-DCMAKE_EXE_LINKER_FLAGS=" ${sanitizer_ldflags} " \
379
- $LLVM || {
383
+ " $LLVM " || {
380
384
build_failure
381
385
# No stats on failure.
382
386
return 0
383
387
}
384
- run_ninja -C ${build_dir}
388
+ run_ninja -C " ${build_dir} "
385
389
386
390
upload_stats stage2
387
391
ccache -s || true
@@ -471,12 +475,12 @@ function check_stage2 {
471
475
LIT_FILTER_OUT+=" |ostream.formatted.print/vprint_nonunicode.pass.cpp"
472
476
LIT_FILTER_OUT+=" |ostream.formatted.print/vprint_unicode.pass.cpp"
473
477
fi
474
- run_ninja -C libcxx_build_${sanitizer_name} check-runtimes
478
+ run_ninja -C " libcxx_build_${sanitizer_name} " check-runtimes
475
479
)
476
480
fi
477
481
478
482
build_step " stage2/$sanitizer_name check"
479
- run_ninja -C ${STAGE2_DIR} check-all
483
+ run_ninja -C " ${STAGE2_DIR} " check-all
480
484
}
481
485
482
486
function check_stage2_msan {
@@ -504,33 +508,36 @@ function check_stage2_asan_ubsan {
504
508
}
505
509
506
510
function build_stage3 {
507
- local sanitizer_name=$1
511
+ local sanitizer_name
512
+ sanitizer_name=" ${1} "
508
513
build_step " build stage3/$sanitizer_name build"
509
514
510
- local build_dir=llvm_build2_${sanitizer_name}
515
+ local build_dir
516
+ build_dir=" llvm_build2_${sanitizer_name} "
511
517
512
- local clang_path=$ROOT /${STAGE2_DIR} /bin
518
+ local clang_path
519
+ clang_path=" ${ROOT} /${STAGE2_DIR} /bin"
513
520
local sanitizer_cflags=
514
- mkdir -p ${build_dir}
521
+ mkdir -p " ${build_dir} "
515
522
local stage3_projects=' clang;lld;clang-tools-extra'
516
523
if [[ " $( arch) " == " aarch64" ]] ; then
517
524
# FIXME: clangd tests fail.
518
525
stage3_projects=' clang;lld'
519
526
fi
520
527
# -DLLVM_CCACHE_BUILD=OFF to track real build time.
521
- cmake -B ${build_dir} \
528
+ cmake -B " ${build_dir} " \
522
529
${CMAKE_COMMON_OPTIONS} \
523
530
-DLLVM_ENABLE_PROJECTS=" ${stage3_projects} " \
524
- -DCMAKE_C_COMPILER=${clang_path} /clang \
525
- -DCMAKE_CXX_COMPILER=${clang_path} /clang++ \
531
+ -DCMAKE_C_COMPILER=" ${clang_path} /clang" \
532
+ -DCMAKE_CXX_COMPILER=" ${clang_path} /clang++" \
526
533
-DCMAKE_CXX_FLAGS=" ${sanitizer_cflags} " \
527
534
-DLLVM_CCACHE_BUILD=OFF \
528
- $ LLVM || {
535
+ " ${ LLVM} " || {
529
536
build_failure
530
537
# No stats on failure.
531
538
return 0
532
539
}
533
- run_ninja -C ${build_dir}
540
+ run_ninja -C " ${build_dir} "
534
541
upload_stats stage3
535
542
}
536
543
@@ -560,7 +567,7 @@ function check_stage3 {
560
567
561
568
local build_dir=llvm_build2_${sanitizer_name}
562
569
563
- run_ninja -C ${build_dir} check-all
570
+ run_ninja -C " ${build_dir} " check-all
564
571
}
565
572
566
573
function check_stage3_msan {
@@ -594,7 +601,7 @@ function build_failure() {
594
601
echo
595
602
596
603
# Repeat, server sometimes ignores failures or warnings.
597
- for i in 0 1 2 ; do
604
+ for _ in 0 1 2 ; do
598
605
echo
599
606
echo " @@@STEP_FAILURE@@@"
600
607
sleep 5
@@ -605,7 +612,7 @@ function build_failure() {
605
612
606
613
function build_exception() {
607
614
# Repeat, server sometimes ignores failures or warnings.
608
- for i in 0 1 2 ; do
615
+ for _ in 0 1 2 ; do
609
616
echo
610
617
echo " @@@STEP_EXCEPTION@@@"
611
618
sleep 5
@@ -616,7 +623,7 @@ function build_exception() {
616
623
617
624
function build_warning() {
618
625
# Repeat, server sometimes ignores failures or warnings.
619
- for i in 0 1 2 ; do
626
+ for _ in 0 1 2 ; do
620
627
echo
621
628
echo " @@@STEP_WARNINGS@@@"
622
629
sleep 5
0 commit comments