ci: Use regular Debian as base Windows for ARM

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 <m.pikula@partner.samsung.com>
This commit is contained in:
Marek Pikuła
2024-10-14 15:07:21 +02:00
parent badcc1390b
commit a2afb80bdb
6 changed files with 52 additions and 23 deletions

View File

@@ -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

View File

@@ -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}

View File

@@ -1,3 +0,0 @@
DOCKER_PLATFORM=linux/amd64
BASE_IMAGE=docker.io/linaro/wine-arm64
BASE_IMAGE_TAG=latest

View File

@@ -0,0 +1 @@
linux-arm64-v8.env

View File

@@ -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}

View File

@@ -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}

View File

@@ -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'