gitlab-ci: Test against LLVM / clang 9 on x86
[mesa.git] / .gitlab-ci / container / x86_build.sh
1 #!/bin/bash
2
3 set -e
4 set -o xtrace
5
6 export DEBIAN_FRONTEND=noninteractive
7
8 CROSS_ARCHITECTURES="i386"
9 for arch in $CROSS_ARCHITECTURES; do
10 dpkg --add-architecture $arch
11 done
12
13 apt-get install -y \
14 ca-certificates \
15 gnupg \
16 unzip \
17 wget
18
19 # Upstream LLVM package repository
20 apt-key add .gitlab-ci/container/llvm-snapshot.gpg.key
21 echo "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >/etc/apt/sources.list.d/llvm9.list
22
23 sed -i -e 's/http:\/\/deb/https:\/\/deb/g' /etc/apt/sources.list
24 echo 'deb https://deb.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/backports.list
25
26 apt-get update
27
28 # Use newer packages from backports by default
29 cat >/etc/apt/preferences <<EOF
30 Package: *
31 Pin: release a=buster-backports
32 Pin-Priority: 500
33 EOF
34
35 apt-get dist-upgrade -y
36
37 apt-get install -y --no-remove \
38 autoconf \
39 automake \
40 autotools-dev \
41 bison \
42 clang-9 \
43 cmake \
44 flex \
45 g++ \
46 gcc \
47 gettext \
48 git \
49 libclang-6.0-dev \
50 libclang-7-dev \
51 libclang-8-dev \
52 libclang-9-dev \
53 libclc-dev \
54 libelf-dev \
55 libepoxy-dev \
56 libexpat1-dev \
57 libgbm-dev \
58 libgtk-3-dev \
59 libomxil-bellagio-dev \
60 libpciaccess-dev \
61 libtool \
62 libunwind-dev \
63 libva-dev \
64 libvdpau-dev \
65 libvulkan-dev \
66 libx11-dev \
67 libx11-xcb-dev \
68 libxdamage-dev \
69 libxext-dev \
70 libxrandr-dev \
71 libxrender-dev \
72 libxshmfence-dev \
73 libxvmc-dev \
74 libxxf86vm-dev \
75 llvm-6.0-dev \
76 llvm-7-dev \
77 llvm-8-dev \
78 llvm-9-dev \
79 meson \
80 pkg-config \
81 python-mako \
82 python3-mako \
83 scons \
84 x11proto-dri2-dev \
85 x11proto-gl-dev \
86 x11proto-randr-dev \
87 xz-utils \
88 zlib1g-dev
89
90 # Cross-build Mesa deps
91 for arch in $CROSS_ARCHITECTURES; do
92 apt-get install -y --no-remove \
93 crossbuild-essential-${arch} \
94 libdrm-dev:${arch} \
95 libelf-dev:${arch} \
96 libexpat1-dev:${arch}
97 done
98
99 # for 64bit windows cross-builds
100 apt-get install -y --no-remove \
101 libz-mingw-w64-dev \
102 mingw-w64 \
103 wine \
104 wine32 \
105 wine64
106
107 # Debian's pkg-config wrapers for mingw are broken, and there's no sign that
108 # they're going to be fixed, so we'll just have to fix it ourselves
109 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
110 cat >/usr/local/bin/x86_64-w64-mingw32-pkg-config <<EOF
111 #!/bin/sh
112
113 PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig pkg-config \$@
114 EOF
115 chmod +x /usr/local/bin/x86_64-w64-mingw32-pkg-config
116
117 # for the vulkan overlay layer
118 wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
119 unzip glslang-master-linux-Release.zip bin/glslangValidator
120 install -m755 bin/glslangValidator /usr/local/bin/
121 rm bin/glslangValidator glslang-master-linux-Release.zip
122
123
124 # dependencies where we want a specific version
125 export XORG_RELEASES=https://xorg.freedesktop.org/releases/individual
126 export XCB_RELEASES=https://xcb.freedesktop.org/dist
127 export WAYLAND_RELEASES=https://wayland.freedesktop.org/releases
128
129 export XORGMACROS_VERSION=util-macros-1.19.0
130 export LIBDRM_VERSION=libdrm-2.4.100
131 export XCBPROTO_VERSION=xcb-proto-1.13
132 export LIBXCB_VERSION=libxcb-1.13
133 export LIBWAYLAND_VERSION=wayland-1.15.0
134 export WAYLAND_PROTOCOLS_VERSION=wayland-protocols-1.12
135
136 wget $XORG_RELEASES/util/$XORGMACROS_VERSION.tar.bz2
137 tar -xvf $XORGMACROS_VERSION.tar.bz2 && rm $XORGMACROS_VERSION.tar.bz2
138 cd $XORGMACROS_VERSION; ./configure; make install; cd ..
139 rm -rf $XORGMACROS_VERSION
140
141 wget $XCB_RELEASES/$XCBPROTO_VERSION.tar.bz2
142 tar -xvf $XCBPROTO_VERSION.tar.bz2 && rm $XCBPROTO_VERSION.tar.bz2
143 cd $XCBPROTO_VERSION; ./configure; make install; cd ..
144 rm -rf $XCBPROTO_VERSION
145
146 wget $XCB_RELEASES/$LIBXCB_VERSION.tar.bz2
147 tar -xvf $LIBXCB_VERSION.tar.bz2 && rm $LIBXCB_VERSION.tar.bz2
148 cd $LIBXCB_VERSION; ./configure; make install; cd ..
149 rm -rf $LIBXCB_VERSION
150
151 wget https://dri.freedesktop.org/libdrm/$LIBDRM_VERSION.tar.bz2
152 tar -xvf $LIBDRM_VERSION.tar.bz2 && rm $LIBDRM_VERSION.tar.bz2
153 cd $LIBDRM_VERSION; meson build -D vc4=true -D freedreno=true -D etnaviv=true; ninja -j4 -C build install; cd ..
154 rm -rf $LIBDRM_VERSION
155
156 wget $WAYLAND_RELEASES/$LIBWAYLAND_VERSION.tar.xz
157 tar -xvf $LIBWAYLAND_VERSION.tar.xz && rm $LIBWAYLAND_VERSION.tar.xz
158 cd $LIBWAYLAND_VERSION; ./configure --enable-libraries --without-host-scanner --disable-documentation --disable-dtd-validation; make install; cd ..
159 rm -rf $LIBWAYLAND_VERSION
160
161 wget $WAYLAND_RELEASES/$WAYLAND_PROTOCOLS_VERSION.tar.xz
162 tar -xvf $WAYLAND_PROTOCOLS_VERSION.tar.xz && rm $WAYLAND_PROTOCOLS_VERSION.tar.xz
163 cd $WAYLAND_PROTOCOLS_VERSION; ./configure; make install; cd ..
164 rm -rf $WAYLAND_PROTOCOLS_VERSION
165
166
167 # The version of libglvnd-dev in debian is too old
168 # Check this page to see when this local compilation can be dropped in favour of the package:
169 # https://packages.debian.org/libglvnd-dev
170 GLVND_VERSION=1.2.0
171 wget https://gitlab.freedesktop.org/glvnd/libglvnd/-/archive/v$GLVND_VERSION/libglvnd-v$GLVND_VERSION.tar.gz
172 tar -xvf libglvnd-v$GLVND_VERSION.tar.gz && rm libglvnd-v$GLVND_VERSION.tar.gz
173 pushd libglvnd-v$GLVND_VERSION; ./autogen.sh; ./configure; make install; popd
174 rm -rf libglvnd-v$GLVND_VERSION
175
176
177 pushd /usr/local
178 git clone https://gitlab.freedesktop.org/mesa/shader-db.git --depth 1
179 rm -rf shader-db/.git
180 cd shader-db
181 make
182 popd
183
184 # Use ccache to speed up builds
185 apt-get install -y --no-remove ccache
186
187 # We need xmllint to validate the XML files in Mesa
188 apt-get install -y --no-remove libxml2-utils
189
190
191 # Generate cross build files for Meson
192 for arch in $CROSS_ARCHITECTURES; do
193 cross_file="/cross_file-$arch.txt"
194 /usr/share/meson/debcrossgen --arch "$arch" -o "$cross_file"
195 # Explicitly set ccache path for cross compilers
196 sed -i "s|/usr/bin/\([^-]*\)-linux-gnu\([^-]*\)-g|/usr/lib/ccache/\\1-linux-gnu\\2-g|g" "$cross_file"
197 if [ "$arch" = "i386" ]; then
198 # Work around a bug in debcrossgen that should be fixed in the next release
199 sed -i "s|cpu_family = 'i686'|cpu_family = 'x86'|g" "$cross_file"
200 # Don't need wrapper for i386 executables
201 sed -i -e '/\[properties\]/a\' -e "needs_exe_wrapper = False" "$cross_file"
202 fi
203 done
204
205
206 ############### Uninstall the build software
207
208 apt-get purge -y \
209 autoconf \
210 automake \
211 autotools-dev \
212 cmake \
213 git \
214 gnupg \
215 libgbm-dev \
216 libtool \
217 unzip \
218 wget
219
220 apt-get autoremove -y --purge