ci: Switch to using gold as the linker.
[mesa.git] / .gitlab-ci / container / lava_build.sh
1 #!/bin/bash
2
3 set -e
4 set -o xtrace
5
6 check_minio()
7 {
8 MINIO_PATH="minio-packet.freedesktop.org/mesa-lava/$1/${DISTRIBUTION_TAG}/${DEBIAN_ARCH}"
9 if wget -q --method=HEAD "https://${MINIO_PATH}/done"; then
10 exit
11 fi
12 }
13
14 # If remote files are up-to-date, skip rebuilding them
15 check_minio "mesa/mesa"
16 check_minio "${CI_PROJECT_PATH}"
17
18 . .gitlab-ci/container/container_pre_build.sh
19
20 if [[ "$DEBIAN_ARCH" = "arm64" ]]; then
21 GCC_ARCH="aarch64-linux-gnu"
22 KERNEL_ARCH="arm64"
23 DEFCONFIG="arch/arm64/configs/defconfig"
24 DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dtb arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb arch/arm64/boot/dts/qcom/apq8016-sbc.dtb"
25 KERNEL_IMAGE_NAME="Image"
26 elif [[ "$DEBIAN_ARCH" = "armhf" ]]; then
27 GCC_ARCH="arm-linux-gnueabihf"
28 KERNEL_ARCH="arm"
29 DEFCONFIG="arch/arm/configs/multi_v7_defconfig"
30 DEVICE_TREES="arch/arm/boot/dts/rk3288-veyron-jaq.dtb arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dtb"
31 KERNEL_IMAGE_NAME="zImage"
32 . .gitlab-ci/create-cross-file.sh armhf
33 else
34 GCC_ARCH="x86_64-linux-gnu"
35 KERNEL_ARCH="x86_64"
36 DEFCONFIG="arch/x86/configs/x86_64_defconfig"
37 DEVICE_TREES=""
38 KERNEL_IMAGE_NAME="bzImage"
39 fi
40
41 # Determine if we're in a cross build.
42 if [[ -e /cross_file-$DEBIAN_ARCH.txt ]]; then
43 EXTRA_MESON_ARGS="--cross-file /cross_file-$DEBIAN_ARCH.txt"
44 EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=/toolchain-$DEBIAN_ARCH.cmake"
45
46 export ARCH=${KERNEL_ARCH}
47 export CROSS_COMPILE="${GCC_ARCH}-"
48 fi
49
50 apt-get update
51 apt-get install -y automake \
52 git \
53 bc \
54 cmake \
55 wget \
56 debootstrap \
57 libboost-dev \
58 libegl1-mesa-dev \
59 libgbm-dev \
60 libgles2-mesa-dev \
61 libpcre3-dev \
62 libpng-dev \
63 libpython3-dev \
64 libssl-dev \
65 libvulkan-dev \
66 libxcb-keysyms1-dev \
67 python3-dev \
68 python3-distutils \
69 python3-serial \
70 qt5-default \
71 qt5-qmake \
72 qtbase5-dev
73
74
75 if [[ "$DEBIAN_ARCH" = "armhf" ]]; then
76 apt-get install -y libboost-dev:armhf \
77 libegl1-mesa-dev:armhf \
78 libelf-dev:armhf \
79 libgbm-dev:armhf \
80 libgles2-mesa-dev:armhf \
81 libpcre3-dev:armhf \
82 libpng-dev:armhf \
83 libpython3-dev:armhf \
84 libvulkan-dev:armhf \
85 libxcb-keysyms1-dev:armhf \
86 qtbase5-dev:armhf
87 fi
88
89 ############### Build dEQP runner
90 . .gitlab-ci/build-cts-runner.sh
91 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin
92 mv /usr/local/bin/deqp-runner /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/.
93
94
95 ############### Build dEQP
96 STRIP_CMD="${GCC_ARCH}-strip"
97 if [ -n "$INCLUDE_VK_CTS" ]; then
98 DEQP_TARGET=surfaceless . .gitlab-ci/build-deqp-vk.sh
99 else
100 . .gitlab-ci/build-deqp-gl.sh
101 fi
102
103 mv /deqp /lava-files/rootfs-${DEBIAN_ARCH}/.
104
105
106 ############### Build apitrace
107 . .gitlab-ci/build-apitrace.sh
108 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/apitrace
109 mv /apitrace/build /lava-files/rootfs-${DEBIAN_ARCH}/apitrace
110 rm -rf /apitrace
111
112 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/waffle
113 mv /waffle/build /lava-files/rootfs-${DEBIAN_ARCH}/waffle
114 rm -rf /waffle
115
116
117 ############### Build renderdoc
118 EXTRA_CMAKE_ARGS+=" -DENABLE_XCB=false"
119 . .gitlab-ci/build-renderdoc.sh
120 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/renderdoc
121 mv /renderdoc/build /lava-files/rootfs-${DEBIAN_ARCH}/renderdoc
122 rm -rf /renderdoc
123
124
125 ############### Build libdrm
126 EXTRA_MESON_ARGS+=" -D prefix=/libdrm"
127 . .gitlab-ci/build-libdrm.sh
128 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH
129 find /libdrm/ -name lib\*\.so\* | xargs cp -t /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH/.
130 rm -rf /libdrm
131
132
133 ############### Cross-build kernel
134 mkdir -p kernel
135 wget -qO- ${KERNEL_URL} | tar -xz --strip-components=1 -C kernel
136 pushd kernel
137
138 # The kernel doesn't like the gold linker (or the old lld in our debians).
139 # Sneak in some override symlinks during kernel build until we can update
140 # debian (they'll get blown away by the rm of the kernel dir at the end).
141 mkdir -p ld-links
142 for i in /usr/bin/*-ld /usr/bin/ld; do
143 i=`basename $i`
144 ln -sf /usr/bin/$i.bfd ld-links/$i
145 done
146 export PATH=`pwd`/ld-links:$PATH
147
148 ./scripts/kconfig/merge_config.sh ${DEFCONFIG} ../.gitlab-ci/${KERNEL_ARCH}.config
149 make ${KERNEL_IMAGE_NAME}
150 for image in ${KERNEL_IMAGE_NAME}; do
151 cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/.
152 done
153 if [[ -n ${DEVICE_TREES} ]]; then
154 make dtbs
155 cp ${DEVICE_TREES} /lava-files/.
156 fi
157
158 if [[ ${DEBIAN_ARCH} = "arm64" ]] && which mkimage > /dev/null; then
159 make Image.lzma
160 mkimage \
161 -f auto \
162 -A arm \
163 -O linux \
164 -d arch/arm64/boot/Image.lzma \
165 -C lzma\
166 -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \
167 /lava-files/cheza-kernel
168 fi
169
170 popd
171 rm -rf kernel
172
173 ############### Create rootfs
174 set +e
175 debootstrap \
176 --variant=minbase \
177 --arch=${DEBIAN_ARCH} \
178 --components main,contrib,non-free \
179 buster \
180 /lava-files/rootfs-${DEBIAN_ARCH}/ \
181 http://deb.debian.org/debian
182
183 cat /lava-files/rootfs-${DEBIAN_ARCH}/debootstrap/debootstrap.log
184 set -e
185
186 cp .gitlab-ci/create-rootfs.sh /lava-files/rootfs-${DEBIAN_ARCH}/.
187 cp .gitlab-ci/container/llvm-snapshot.gpg.key /lava-files/rootfs-${DEBIAN_ARCH}/.
188 chroot /lava-files/rootfs-${DEBIAN_ARCH} sh /create-rootfs.sh
189 rm /lava-files/rootfs-${DEBIAN_ARCH}/create-rootfs.sh
190 rm /lava-files/rootfs-${DEBIAN_ARCH}/llvm-snapshot.gpg.key
191 du -ah /lava-files/rootfs-${DEBIAN_ARCH} | sort -h | tail -100
192 pushd /lava-files/rootfs-${DEBIAN_ARCH}
193 tar cvzf /lava-files/lava-rootfs.tgz .
194 popd
195
196 if [ ${DEBIAN_ARCH} = arm64 ]; then
197 # Pull down a specific build of qcomlt/release/qcomlt-5.4 8c79b3d12355
198 # ("Merge tag 'v5.4.23' into release/qcomlt-5.4"), where I used the
199 # .config from
200 # http://snapshots.linaro.org/96boards/dragonboard820c/linaro/debian/457/config-5.4.0-qcomlt-arm64
201 # with the following merged in:
202 #
203 # CONFIG_DRM=y
204 # CONFIG_DRM_MSM=y
205 # CONFIG_ATL1C=y
206 #
207 # Reason: 5.5 has a big stack of oopses and warns on db820c. 4.14-5.4
208 # linaro kernel binaries (see above .config link) have these as modules
209 # and distributed the modules only in the debian system, not the initrd,
210 # so they're very hard to extract (involving simg2img and loopback
211 # mounting). 4.11 is missing d72fea538fe6 ("drm/msm: Fix the check for
212 # the command size") so it can't actually run fredreno. qcomlt-4.14 is
213 # unstable at boot (~10% instaboot rate). The 5.4 qcomlt kernel with msm
214 # built in seems like the easiest way to go.
215 wget https://people.freedesktop.org/~anholt/qcomlt-5.4-msm-build/Image.gz -O Image.gz \
216 -O /lava-files/db820c-kernel
217 wget https://people.freedesktop.org/~anholt/qcomlt-5.4-msm-build/apq8096-db820c.dtb \
218 -O /lava-files/db820c.dtb
219
220 # Make a gzipped copy of the Image for db410c.
221 gzip -k /lava-files/Image
222
223 # Add missing a630 firmware, added to debian packge in apr 2020
224 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/qcom/a630_gmu.bin \
225 -O /lava-files/rootfs-arm64/lib/firmware/qcom/a630_gmu.bin
226 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/qcom/a630_sqe.fw \
227 -O /lava-files/rootfs-arm64/lib/firmware/qcom/a630_sqe.fw
228 fi
229
230 . .gitlab-ci/container/container_post_build.sh
231
232 ############### Upload the files!
233 if [ -n "$UPLOAD_FOR_LAVA" ]; then
234 ci-fairy minio login $CI_JOB_JWT
235 FILES_TO_UPLOAD="lava-rootfs.tgz \
236 $KERNEL_IMAGE_NAME"
237
238 if [[ -n $DEVICE_TREES ]]; then
239 FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)"
240 fi
241
242 for f in $FILES_TO_UPLOAD; do
243 ci-fairy minio cp /lava-files/$f \
244 minio://${MINIO_PATH}/$f
245 done
246
247 touch /lava-files/done
248 ci-fairy minio cp /lava-files/done minio://${MINIO_PATH}/done
249 fi
250