gitlab-ci: Use separate docker images for cross builds
authorMichel Dänzer <mdaenzer@redhat.com>
Mon, 1 Jun 2020 17:08:30 +0000 (19:08 +0200)
committerEric Anholt <eric@anholt.net>
Tue, 2 Jun 2020 17:14:16 +0000 (10:14 -0700)
Using x86_build-base as a separate base layer as well for storage &
network bandwidth efficiency.

Using separate images allows dropping the workarounds from the cross
build job scripts.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5296>

.gitlab-ci.yml
.gitlab-ci/container/cross_build.sh [new file with mode: 0644]
.gitlab-ci/container/i386_build.sh [new file with mode: 0644]
.gitlab-ci/container/ppc64el_build.sh [new file with mode: 0644]
.gitlab-ci/container/s390x_build.sh [new file with mode: 0644]
.gitlab-ci/container/x86_build-base.sh
.gitlab-ci/container/x86_build.sh

index cf6b386f94fbb14185ec0dce88223b6ce19f9710..31c9bd7d4a9debce4b46f095a2d0458144a4f389 100644 (file)
@@ -137,7 +137,7 @@ x86_build-base:
     - .fdo.container-build@debian
     - .container
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_build-base "2020-06-01"
+    FDO_DISTRIBUTION_TAG: &x86_build-base "2020-06-02"
 
 .use-x86_build-base:
   extends:
@@ -155,7 +155,7 @@ x86_build:
   extends:
     - .use-x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_build "2020-06-01"
+    FDO_DISTRIBUTION_TAG: &x86_build "2020-06-02"
 
 .use-x86_build:
   variables:
@@ -165,6 +165,51 @@ x86_build:
     - x86_build-base
     - x86_build
 
+# Debian 10 based i386 cross-build image
+i386_build:
+  extends:
+    - .use-x86_build-base
+  variables:
+    FDO_DISTRIBUTION_TAG: &i386_build "2020-06-02"
+
+.use-i386_build:
+  variables:
+    TAG: *i386_build
+  image: "$CI_REGISTRY_IMAGE/debian/i386_build:$TAG"
+  needs:
+    - x86_build-base
+    - i386_build
+
+# Debian 10 based ppc64el cross-build image
+ppc64el_build:
+  extends:
+    - .use-x86_build-base
+  variables:
+    FDO_DISTRIBUTION_TAG: &ppc64el_build "2020-06-02"
+
+.use-ppc64el_build:
+  variables:
+    TAG: *ppc64el_build
+  image: "$CI_REGISTRY_IMAGE/debian/ppc64el_build:$TAG"
+  needs:
+    - x86_build-base
+    - ppc64el_build
+
+# Debian 10 based s390x cross-build image
+s390x_build:
+  extends:
+    - .use-x86_build-base
+  variables:
+    FDO_DISTRIBUTION_TAG: &s390x_build "2020-06-02"
+
+.use-s390x_build:
+  variables:
+    TAG: *s390x_build
+  image: "$CI_REGISTRY_IMAGE/debian/s390x_build:$TAG"
+  needs:
+    - x86_build-base
+    - s390x_build
+
 # Debian 10 based x86 test image base
 x86_test-base:
   extends: x86_build-base
@@ -564,7 +609,9 @@ meson-vulkan:
       -D werror=true
 
 meson-i386:
-  extends: .meson-cross
+  extends:
+    - .meson-cross
+    - .use-i386_build
   variables:
     CROSS: i386
     VULKAN_DRIVERS: intel,amd
@@ -572,13 +619,11 @@ meson-i386:
     EXTRA_OPTION: >
       -D vulkan-overlay-layer=true
       -D werror=true
-  script:
-    - dpkg -i /var/cache/apt/archives/$CROSS/*.deb
-    - .gitlab-ci/meson-build.sh
 
 meson-s390x:
   extends:
     - .meson-cross
+    - .use-s390x_build
   tags:
     - kvm
   variables:
@@ -586,17 +631,11 @@ meson-s390x:
     EXTRA_OPTION: >
       -D werror=true
     GALLIUM_DRIVERS: "swrast"
-  script:
-    # For unknown reasons "too many" installed i386 libraries cause qemu to
-    # crash while executing llvm-config for s390x.
-    - apt-get purge -y wine32-development
-    - apt-get autoremove -y --purge
-    - dpkg -i /var/cache/apt/archives/$CROSS/*.deb
-    - .gitlab-ci/meson-build.sh
 
 meson-ppc64el:
   extends:
     - meson-s390x
+    - .use-ppc64el_build
   variables:
     CROSS: ppc64el
     EXTRA_OPTION: ""
diff --git a/.gitlab-ci/container/cross_build.sh b/.gitlab-ci/container/cross_build.sh
new file mode 100644 (file)
index 0000000..58f449f
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+set -e
+set -o xtrace
+
+export DEBIAN_FRONTEND=noninteractive
+
+# Ephemeral packages (installed for this script and removed again at the end)
+STABLE_EPHEMERAL=" \
+        libpciaccess-dev:$arch \
+        wget \
+        "
+
+dpkg --add-architecture $arch
+apt-get update
+
+apt-get install -y --no-remove \
+        $STABLE_EPHEMERAL \
+        crossbuild-essential-$arch \
+        libelf-dev:$arch \
+        libexpat1-dev:$arch \
+        libffi-dev:$arch \
+        libstdc++6:$arch \
+        libtinfo-dev:$arch
+
+apt-get install -y --no-remove -t buster-backports \
+        llvm-8-dev:$arch
+
+. .gitlab-ci/create-cross-file.sh $arch
+
+
+. .gitlab-ci/container/container_pre_build.sh
+
+
+# dependencies where we want a specific version
+export LIBDRM_VERSION=libdrm-2.4.100
+
+wget https://dri.freedesktop.org/libdrm/$LIBDRM_VERSION.tar.bz2
+tar -xvf $LIBDRM_VERSION.tar.bz2 && rm $LIBDRM_VERSION.tar.bz2
+cd $LIBDRM_VERSION
+meson --cross-file=/cross_file-${arch}.txt build -D libdir=lib/$(dpkg-architecture -A $arch -qDEB_TARGET_MULTIARCH)
+ninja -C build install
+cd ..
+rm -rf $LIBDRM_VERSION
+
+
+apt-get purge -y \
+        $STABLE_EPHEMERAL
+
+. .gitlab-ci/container/container_post_build.sh
diff --git a/.gitlab-ci/container/i386_build.sh b/.gitlab-ci/container/i386_build.sh
new file mode 100644 (file)
index 0000000..404fe9c
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+arch=i386
+
+. .gitlab-ci/container/cross_build.sh
diff --git a/.gitlab-ci/container/ppc64el_build.sh b/.gitlab-ci/container/ppc64el_build.sh
new file mode 100644 (file)
index 0000000..3519192
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+arch=ppc64el
+
+. .gitlab-ci/container/cross_build.sh
+
+apt-get install -y --no-remove \
+        libvulkan-dev:$arch
diff --git a/.gitlab-ci/container/s390x_build.sh b/.gitlab-ci/container/s390x_build.sh
new file mode 100644 (file)
index 0000000..38ca850
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+arch=s390x
+
+. .gitlab-ci/container/cross_build.sh
index dd698fc74cd6a1960f5ee7d576c163dc095eea42..2350aca8843383d3aeec08905824382b65f1cdbc 100644 (file)
@@ -5,11 +5,6 @@ set -o xtrace
 
 export DEBIAN_FRONTEND=noninteractive
 
-CROSS_ARCHITECTURES="i386 ppc64el s390x"
-for arch in $CROSS_ARCHITECTURES; do
-    dpkg --add-architecture $arch
-done
-
 apt-get install -y \
         ca-certificates \
         gnupg \
@@ -30,6 +25,7 @@ apt-get install -y --no-remove \
         bison \
         ccache \
         clang-9 \
+        dpkg-cross \
         flex \
         g++ \
         g++-mingw-w64-x86-64 \
@@ -37,19 +33,16 @@ apt-get install -y --no-remove \
         gettext \
         libclang-9-dev \
         libclc-dev \
-        libdrm-dev:s390x \
         libelf-dev \
         libepoxy-dev \
         libexpat1-dev \
         libgtk-3-dev \
         libomxil-bellagio-dev \
         libpciaccess-dev \
-        libpciaccess-dev:i386 \
         libunwind-dev \
         libva-dev \
         libvdpau-dev \
         libvulkan-dev \
-        libvulkan-dev:ppc64el \
         libx11-dev \
         libx11-xcb-dev \
         libxdamage-dev \
@@ -69,8 +62,6 @@ apt-get install -y --no-remove \
         python3-requests \
         qemu-user \
         scons \
-        wine-development \
-        wine32-development \
         wine64-development \
         x11proto-dri2-dev \
         x11proto-gl-dev \
@@ -83,36 +74,6 @@ apt-get install -y --no-remove -t buster-backports \
         libllvm8 \
         meson
 
-# Cross-build Mesa deps
-for arch in $CROSS_ARCHITECTURES; do
-    apt-get install -y --no-remove \
-            crossbuild-essential-${arch} \
-            libelf-dev:${arch} \
-            libexpat1-dev:${arch} \
-            libffi-dev:${arch} \
-            libstdc++6:${arch} \
-            libtinfo-dev:${arch}
-
-    apt-get install -y --no-remove -t buster-backports \
-            libllvm8:${arch}
-
-    mkdir /var/cache/apt/archives/${arch}
-    # Download llvm-* packages, but don't install them yet, since they can
-    # only be installed for one architecture at a time
-    apt-get install -o Dir::Cache::archives=/var/cache/apt/archives/$arch --download-only \
-            -y --no-remove -t buster-backports \
-            llvm-8-dev:${arch}
-done
-
-apt-get install -y --no-remove -t buster-backports \
-        llvm-8-dev
-
-
-# Generate cross build files for Meson
-for arch in $CROSS_ARCHITECTURES; do
-    . .gitlab-ci/create-cross-file.sh $arch
-done
-
 
 # for the vulkan overlay layer
 wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
index f286748939ed8645b7cdb8d44b58d34af9ac0634..562bde8a6b92f5c38df6e3bdd8458403a926ff1d 100644 (file)
@@ -21,8 +21,17 @@ STABLE_EPHEMERAL=" \
       wget \
       "
 
+# We need multiarch for Wine
+dpkg --add-architecture i386
+apt-get update
+
 apt-get install -y --no-remove \
-      $STABLE_EPHEMERAL
+      $STABLE_EPHEMERAL \
+      wine-development \
+      wine32-development
+
+apt-get install -y --no-remove -t buster-backports \
+      llvm-8-dev
 
 
 . .gitlab-ci/container/container_pre_build.sh
@@ -70,8 +79,6 @@ wget https://dri.freedesktop.org/libdrm/$LIBDRM_VERSION.tar.bz2
 tar -xvf $LIBDRM_VERSION.tar.bz2 && rm $LIBDRM_VERSION.tar.bz2
 cd $LIBDRM_VERSION
 meson build -D vc4=true -D freedreno=true -D etnaviv=true -D libdir=lib/x86_64-linux-gnu; ninja -C build install
-rm -rf build; meson --cross-file=/cross_file-ppc64el.txt build -D libdir=lib/powerpc64le-linux-gnu; ninja -C build install
-rm -rf build; meson --cross-file=/cross_file-i386.txt build -D libdir=lib/i386-linux-gnu; ninja -C build install
 cd ..
 rm -rf $LIBDRM_VERSION