blob: 67277d9ddd688ff7ab4b18df359d64a8a4332ef8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
#!/bin/bash
set -e
if [ x"$1" = x"start.sh" ]; then
cat /start.sh
exit 0
fi
worker_dir=/home/tcwg-buildbot/worker
if [ x"$1" != x"buildkite" ]; then
if [ -f $worker_dir/buildbot.tac ]; then
:
else
sudo -i -u tcwg-buildbot buildbot-worker create-worker $worker_dir "$@"
fi
fi
if [[ $2 == *"latest-gcc"* ]] ; then
install-gcc-latest.sh
cc=gcc-latest
cxx=g++-latest
else
release_num=17.0.6
case "$(uname -m)" in
aarch64)
release_arch=aarch64-linux-gnu
lib_arch=aarch64-unknown-linux-gnu
;;
*)
release_arch=armv7a-linux-gnueabihf
# It is intentional that this is v7l not v7a.
lib_arch=armv7l-unknown-linux-gnueabihf
;;
esac
release_path=/usr/local/clang+llvm-${release_num}-${release_arch}
cc=$release_path/bin/clang
cxx=$release_path/bin/clang++
# Libcxx picolibc build requires these tools.
ln -f -s $release_path/bin/ld.lld /usr/local/bin/ld.lld
ln -f -s $release_path/bin/llvm-as /usr/local/bin/llvm-as
ln -f -s $release_path/bin/llvm-ar /usr/local/bin/llvm-ar
ln -f -s $release_path/bin/llvm-strip /usr/local/bin/llvm-strip
# Starting with clang-11 we need clang's libs in ld.so's search path;
# otherwise we get failure to find libc++.so.
echo "$release_path/lib/$lib_arch" > /etc/ld.so.conf.d/clang.conf
ldconfig
fi
# With default PATH /usr/local/bin/cc and /usr/local/bin/c++ are detected as
# system compilers. No danger in ccaching results of system compiler since
# we always start with a clean cache in a new container.
cat > /usr/local/bin/cc <<EOF
#!/bin/sh
# This sed strips directories after $worker_dir/\$builder_dir; e.g.,
# $worker_dir/clang-aarch64-sve-vls/stage1/llvm becomes
# $worker_dir/clang-aarch64-sve-vls .
basedir=\$(pwd | sed -e "s#\($worker_dir/[^/]\+\)/.*#\1#")
if [ "\$basedir" != "\$(pwd)" ]; then
# We are inside a subdirectory of a buildbot builder directory, e.g.,
# /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1 .
# We set CCACHE_BASEDIR to "merge" ccache entries among different buildbot
# builders, so that multiple bots can share the results of their builds.
export CCACHE_BASEDIR="\$basedir"
fi
EOF
cp /usr/local/bin/cc /usr/local/bin/c++
cat >> /usr/local/bin/cc <<EOF
exec ccache $cc "\$@"
EOF
chmod +x /usr/local/bin/cc
cat >> /usr/local/bin/c++ <<EOF
exec ccache $cxx "\$@"
EOF
chmod +x /usr/local/bin/c++
if [ x"$1" != x"buildkite" ]; then
cat <<EOF | sudo -i -u tcwg-buildbot tee $worker_dir/info/admin
Linaro Toolchain Working Group <linaro-toolchain@lists.linaro.org>
EOF
fi
n_cores=$(nproc --all)
case "$n_cores" in
4)
hw="NVIDIA TK1 ${n_cores}x Cortex-A15"
;;
48)
hw="Fujitsu FX700 ${n_cores}x A64FX"
;;
160)
hw="Ampere Mt. Jade ${n_cores}x Neoverse-N1 provided by Equinix"
;;
*)
hw="${n_cores}x ARMv8"
;;
esac
if [ -f /sys/fs/cgroup/cpu.pressure ] \
|| ! [ -f /sys/fs/cgroup/cpuacct/cpuacct.stat ]; then
# This is for kernel 4.20 and newer, which replaces
# /sys/fs/cgroup/cpuacct/cpuacct.stat with /sys/fs/cgroup/cpu.pressure.
# Branch limit-on-psi gracefully handles absence of cpu.pressure, so
# it's OK to use it for [weird] cases when both cpu.pressure and
# cpuacct.stat are missing.
ninja_bin=/usr/local/bin/ninja.limit-on-psi
else
# This is for older kernels.
ninja_bin=/usr/local/bin/ninja.limit-on-cpu
# See https://github.com/maxim-kuvyrkov/ninja/commit/8fa112c0104d4cfd0bad0eb62e4cec03f7b51e14
# and https://github.com/maxim-kuvyrkov/ninja/commit/c3eb25f42c3ba5a0c57c482ecdd8051167fcbb61
# about this ugliness.
if [ -f /proc/config.gz ]; then
# CONFIG_HZ is set to 1000 on TK1s, which, luckily, provide /proc/config.gz.
zcat /proc/config.gz | grep "^CONFIG_HZ=" | sed -e "s/^CONFIG_HZ=//"
else
# CONFIG_HZ is set to 250 on all other current systems that we use for
# LLVM buildbots (this seems to be the current Ubuntu default).
echo "250"
fi > /etc/ninja_schedstat_hz
fi
case "$2" in
linaro-tk1-*)
# TK1s have CPU hot-plug, so ninja might detect smaller number of cores
# available for parallelism. Explicitly set "default" parallelism.
ninja_bin="$ninja_bin -j$n_cores"
;;
esac
cat > /usr/local/bin/ninja <<EOF
#!/bin/sh
exec $ninja_bin -l-10 "\$@"
EOF
chmod +x /usr/local/bin/ninja
if [ -f /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
mem_limit=$((($(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) + 512*1024*1024) / (1024*1024*1024)))
else
mem_limit=$((($(cat /proc/meminfo | grep MemTotal | sed -e "s/[^0-9]\+\([0-9]\+\)[^0-9]\+/\1/") + 512*1024) / (1024*1024)))
fi
if [ x"$1" != x"buildkite" ]; then
cat <<EOF | sudo -i -u tcwg-buildbot tee $worker_dir/info/host
$hw; RAM ${mem_limit}GB
OS: $(lsb_release -ds)
Kernel: $(uname -rv)
Compiler: $(cc --version | head -n 1)
System Linker: $(ld --version | head -n 1)
C Library: $(ldd --version | head -n 1)
CMake: $(cmake --version | head -n 1)
EOF
fi
# Handle LNT performance bot.
case "$2" in
linaro-tk1-02)
# Borrowed from bmk-scripts.git/perfdatadir2csv.sh
perf_bin="/usr/lib/linux-tools/$(uname -r)/perf"
if ! [ -e "$perf_bin" ]; then
perf_bin="$(find /usr/lib/linux-tools/ -name perf | tail -n 1)"
if ! [ -e "$perf_bin" ]; then
echo "ERROR: Cannot find perf binary"
exit 1
fi
fi
cat > /usr/local/bin/perf <<EOF
#!/bin/sh
exec $perf_bin "\$@"
EOF
chmod +x /usr/local/bin/perf
;;
esac
if [ x"$1" = x"buildkite" ]; then
# Add load testing bots. Trigger these by modifying the Buildkite
# config in a Phabricator review.
if [[ $2 == *"-test" ]]; then
queue="libcxx-builders-linaro-arm-test"
# Production buildkite bots.
else
queue="libcxx-builders-linaro-arm"
fi
exec sudo -i -u tcwg-buildbot buildkite-agent start \
--name $2 \
--token $3 \
--tags "queue=$queue,arch=$(arch)" \
--build-path $worker_dir
else
exec sudo -i -u tcwg-buildbot buildbot-worker restart --nodaemon $worker_dir
fi
|