From a2afb80bdb1663e561a205b921fb551a690c99d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Piku=C5=82a?= Date: Mon, 14 Oct 2024 15:07:21 +0200 Subject: [PATCH] ci: Use regular Debian as base Windows for ARM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out it's relatively easy to provide support for Windows on ARM. Unfortunately, it requires building Wine from source, as the version distributed by Debian (both Bookworm and Sid) is buggy for some tests. However, building it isn't overly complicated, and can be replaced with pre-built package once a fixed version lands in Debian Trixie. Besides that, I also fixed the dynamic linking issue and enabled OpenMP as for x86 targets. It has the following advantages: - It greatly decreases the image size, and improves maintainability of the package, as we don't rely on third-party image (from Linaro). - We can build a native image and run it on ARM GitLab runner spreading the load between different runners, and significantly improving the speed of execution (over 12 min down to under a minute). Signed-off-by: Marek PikuĊ‚a --- .gitlab-ci.d/01-docker.yml | 2 +- .gitlab-ci.d/01-docker/Dockerfile | 55 +++++++++++++++---- .../01-docker/target-env/windows-arm64-v8.env | 4 +- .gitlab-ci.d/02-build.yml | 3 +- .gitlab-ci.d/03-test.yml | 3 +- .../meson-cross/windows-arm64-v8-llvm.meson | 8 +-- 6 files changed, 52 insertions(+), 23 deletions(-) mode change 100644 => 120000 .gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env diff --git a/.gitlab-ci.d/01-docker.yml b/.gitlab-ci.d/01-docker.yml index 5e45562..182cf2c 100644 --- a/.gitlab-ci.d/01-docker.yml +++ b/.gitlab-ci.d/01-docker.yml @@ -12,6 +12,7 @@ include: - linux-arm-v5 - linux-arm-v7 - linux-arm64-v8 + - windows-arm64-v8 - local: .gitlab-ci.d/templates/docker.yml inputs: runner_tag: $RUNNER_TAG_DEFAULT @@ -27,4 +28,3 @@ include: - linux-riscv64 - windows-686 - windows-amd64 - - windows-arm64-v8 diff --git a/.gitlab-ci.d/01-docker/Dockerfile b/.gitlab-ci.d/01-docker/Dockerfile index eaeceed..ed29da5 100644 --- a/.gitlab-ci.d/01-docker/Dockerfile +++ b/.gitlab-ci.d/01-docker/Dockerfile @@ -109,13 +109,13 @@ RUN ${APT_UPDATE} \ # Windows base image with a pre-built LLVM MinGW toolchain. FROM base AS windows-llvm-base ARG LLVM_MINGW_RELEASE=20241203 -ARG LLVM_MINGW_VARIANT=llvm-mingw-${LLVM_MINGW_RELEASE}-msvcrt-ubuntu-20.04-x86_64 +ARG LLVM_MINGW_VARIANT=llvm-mingw-${LLVM_MINGW_RELEASE}-ucrt-ubuntu-20.04 RUN ${APT_UPDATE} \ && ${APT_INSTALL} \ procps \ wget \ && ${APT_CLEANUP} \ - && wget https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_RELEASE}/${LLVM_MINGW_VARIANT}.tar.xz \ + && wget https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_RELEASE}/${LLVM_MINGW_VARIANT}-`uname -m`.tar.xz \ -O - | tar -xJ -C /opt \ && mv /opt/llvm* /opt/llvm ENV PATH=/opt/llvm/bin:${PATH} \ @@ -150,11 +150,46 @@ RUN ${APT_UPDATE} \ && ${APT_CLEANUP} \ && ${WINE_BOOT} -# aarch64 image requires linaro/wine-arm64 as a base. -FROM windows-llvm-base AS windows-arm64-v8 -RUN wine-arm64 wineboot --init \ - && while pgrep wineserver > /dev/null; do \ - echo "waiting ..."; \ - sleep 1; \ - done \ - && rm -rf /tmp/wine-* +# Dependencies needed both for Wine build and the final image. +FROM windows-llvm-base AS windows-wine-build-base +RUN ${APT_UPDATE} \ + && ${APT_INSTALL} \ + libfreetype-dev \ + libgnutls28-dev \ + libkrb5-dev \ + libx11-dev \ + libxcomposite-dev \ + libxcursor-dev \ + libxext-dev \ + libxfixes-dev \ + libxi-dev \ + libxrandr-dev \ + libxrender-dev \ + && ${APT_CLEANUP} + +# Wine build intermediate target, not going into the final image. +FROM windows-wine-build-base AS windows-wine-build +RUN ${APT_UPDATE} \ + && ${APT_INSTALL} \ + bison \ + ca-certificates \ + clang \ + flex \ + git \ + lld \ + llvm \ + && ${APT_CLEANUP} +ARG WINE_VERSION=9.22 +RUN git clone https://gitlab.winehq.org/wine/wine.git \ + -b wine-${WINE_VERSION} \ + --depth 1 +RUN cd wine \ + && ./configure --enable-win64 --disable-tests --without-unwind --prefix=/opt/wine \ + && make -j`nproc` \ + && make install + +FROM windows-wine-build-base AS windows-arm64-v8 +COPY --from=windows-wine-build /opt/wine /opt/wine +ENV PATH=/opt/wine/bin:${PATH} \ + WINEPATH=/opt/llvm/aarch64-w64-mingw32/bin +RUN ${WINE_BOOT} diff --git a/.gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env b/.gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env deleted file mode 100644 index 1e1ae33..0000000 --- a/.gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env +++ /dev/null @@ -1,3 +0,0 @@ -DOCKER_PLATFORM=linux/amd64 -BASE_IMAGE=docker.io/linaro/wine-arm64 -BASE_IMAGE_TAG=latest diff --git a/.gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env b/.gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env new file mode 120000 index 0000000..f8f6a23 --- /dev/null +++ b/.gitlab-ci.d/01-docker/target-env/windows-arm64-v8.env @@ -0,0 +1 @@ +linux-arm64-v8.env \ No newline at end of file diff --git a/.gitlab-ci.d/02-build.yml b/.gitlab-ci.d/02-build.yml index 05af1bf..75093f5 100644 --- a/.gitlab-ci.d/02-build.yml +++ b/.gitlab-ci.d/02-build.yml @@ -87,5 +87,6 @@ include: inputs: target: windows-arm64-v8 toolchain: [llvm] # GNU toolchain doesn't seem to support Windows on ARM. - qemu_cpu: max enable_gnu_coverage: false + runner_tag: $RUNNER_TAG_ARM + docker_job: docker:${RUNNER_TAG_ARM} diff --git a/.gitlab-ci.d/03-test.yml b/.gitlab-ci.d/03-test.yml index 0d000f1..8310453 100644 --- a/.gitlab-ci.d/03-test.yml +++ b/.gitlab-ci.d/03-test.yml @@ -122,4 +122,5 @@ include: inputs: target: windows-arm64-v8 toolchain: [llvm] - qemu_cpu: [max] + runner_tag: $RUNNER_TAG_ARM + docker_job: docker:${RUNNER_TAG_ARM} diff --git a/.gitlab-ci.d/meson-cross/windows-arm64-v8-llvm.meson b/.gitlab-ci.d/meson-cross/windows-arm64-v8-llvm.meson index f0d44cb..a984131 100644 --- a/.gitlab-ci.d/meson-cross/windows-arm64-v8-llvm.meson +++ b/.gitlab-ci.d/meson-cross/windows-arm64-v8-llvm.meson @@ -3,13 +3,7 @@ c = 'aarch64-w64-mingw32-clang' ar = 'aarch64-w64-mingw32-llvm-ar' strip = 'aarch64-w64-mingw32-strip' windres = 'aarch64-w64-mingw32-windres' -exe_wrapper = 'wine-arm64' - -[built-in options] -c_link_args = ['-static'] - -[project options] -openmp = 'disabled' +exe_wrapper = 'wine' [host_machine] system = 'windows'