summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonggang Luo <luoyonggang@gmail.com>2022-05-05 19:44:02 +0800
committerMarge Bot <emma+marge@anholt.net>2022-06-23 09:27:06 +0000
commitbbfd6dfe2ef901979590ca440d91c86c937e64c2 (patch)
tree47ee797f4ceeaa577ebda91da0a89b1e9eae1ec1
parent20a236c75579e0c5563fc9ae65739cc214b7ea2f (diff)
ci: Prepare the container for building all mesa components with mingw under linux
`x86_build-base-wine.sh` are usd to install wine and xvfb `x86_build-mingw-patch.sh` are used to pull packages from msys2 that can be directly used. `x86_build-mingw-source-deps.sh` are used to building llvm, libclc, clang, spirv-tools and directx-headers from source xvfb are used to enable wgl tests on debian Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Jesse Natalie <jenatali@microsoft.com> Acked-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16084>
-rw-r--r--.gitlab-ci/container/debian/x86_build-base-wine.sh19
-rw-r--r--.gitlab-ci/container/debian/x86_build-base.sh6
-rw-r--r--.gitlab-ci/container/debian/x86_build-mingw-patch.sh74
-rw-r--r--.gitlab-ci/container/debian/x86_build-mingw-source-deps.sh100
-rw-r--r--.gitlab-ci/container/debian/x86_build-mingw.sh13
-rw-r--r--.gitlab-ci/container/debian/x86_build.sh21
-rw-r--r--.gitlab-ci/container/debian/x86_mingw-toolchain.cmake8
-rwxr-xr-x.gitlab-ci/meson/build.sh2
-rw-r--r--.gitlab-ci/x86_64-w64-mingw327
9 files changed, 225 insertions, 25 deletions
diff --git a/.gitlab-ci/container/debian/x86_build-base-wine.sh b/.gitlab-ci/container/debian/x86_build-base-wine.sh
new file mode 100644
index 00000000000..dec8f790cf4
--- /dev/null
+++ b/.gitlab-ci/container/debian/x86_build-base-wine.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+set -o xtrace
+
+# Installing wine, need this for testing mingw or nine
+
+# We need multiarch for Wine
+dpkg --add-architecture i386
+apt-get update
+apt-get install -y --no-remove \
+ wine \
+ wine32 \
+ wine64 \
+ xvfb
+
+# Used to initialize the Wine environment to reduce build time
+wine64 whoami.exe
+
diff --git a/.gitlab-ci/container/debian/x86_build-base.sh b/.gitlab-ci/container/debian/x86_build-base.sh
index 85a6a6f0002..0a56d479bf2 100644
--- a/.gitlab-ci/container/debian/x86_build-base.sh
+++ b/.gitlab-ci/container/debian/x86_build-base.sh
@@ -25,7 +25,7 @@ apt-get install -y --no-remove \
dpkg-cross \
flex \
g++ \
- g++-mingw-w64-x86-64 \
+ cmake \
gcc \
git \
glslang-tools \
@@ -54,7 +54,6 @@ apt-get install -y --no-remove \
libxshmfence-dev \
libxvmc-dev \
libxxf86vm-dev \
- libz-mingw-w64-dev \
make \
meson \
pkg-config \
@@ -64,7 +63,6 @@ apt-get install -y --no-remove \
qemu-user \
valgrind \
wget \
- wine64 \
x11proto-dri2-dev \
x11proto-gl-dev \
x11proto-randr-dev \
@@ -74,6 +72,8 @@ apt-get install -y --no-remove \
# Needed for ci-fairy, this revision is able to upload files to MinIO
pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates@34f4ade99434043f88e164933f570301fd18b125
+. .gitlab-ci/container/debian/x86_build-base-wine.sh
+
############### Uninstall ephemeral packages
apt-get purge -y $STABLE_EPHEMERAL
diff --git a/.gitlab-ci/container/debian/x86_build-mingw-patch.sh b/.gitlab-ci/container/debian/x86_build-mingw-patch.sh
new file mode 100644
index 00000000000..6dbb743f913
--- /dev/null
+++ b/.gitlab-ci/container/debian/x86_build-mingw-patch.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+# Pull packages from msys2 repository that can be directly used.
+# We can use https://packages.msys2.org/ to retrieve the newest package
+mkdir ~/tmp
+pushd ~/tmp
+MINGW_PACKET_LIST="
+mingw-w64-x86_64-headers-git-10.0.0.r14.ga08c638f8-1-any.pkg.tar.zst
+mingw-w64-x86_64-vulkan-loader-1.3.211-1-any.pkg.tar.zst
+mingw-w64-x86_64-libelf-0.8.13-6-any.pkg.tar.zst
+mingw-w64-x86_64-zlib-1.2.12-1-any.pkg.tar.zst
+mingw-w64-x86_64-zstd-1.5.2-2-any.pkg.tar.zst
+"
+
+for i in $MINGW_PACKET_LIST
+do
+ wget -q --tries=3 https://mirror.msys2.org/mingw/mingw64/$i
+ tar xf $i --strip-components=1 -C /usr/x86_64-w64-mingw32/
+done
+popd
+rm -rf ~/tmp
+
+mkdir -p /usr/x86_64-w64-mingw32/bin
+
+# The output of `wine64 llvm-config --system-libs --cxxflags mcdisassembler`
+# containes absolute path like '-IZ:'
+# The sed is used to replace `-IZ:/usr/x86_64-w64-mingw32/include`
+# to `-I/usr/x86_64-w64-mingw32/include`
+
+# Debian's pkg-config wrapers for mingw are broken, and there's no sign that
+# they're going to be fixed, so we'll just have to fix it ourselves
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
+cat >/usr/x86_64-w64-mingw32/bin/pkg-config <<EOF
+#!/bin/sh
+
+PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig:/usr/x86_64-w64-mingw32/share/pkgconfig pkg-config \$@
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/pkg-config
+
+cat >/usr/x86_64-w64-mingw32/bin/llvm-config <<EOF
+#!/bin/sh
+wine64 llvm-config \$@ | sed -e "s,Z:/,/,gi"
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/llvm-config
+
+cat >/usr/x86_64-w64-mingw32/bin/clang <<EOF
+#!/bin/sh
+wine64 clang \$@
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/clang
+
+cat >/usr/x86_64-w64-mingw32/bin/llvm-as <<EOF
+#!/bin/sh
+wine64 llvm-as \$@
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/llvm-as
+
+cat >/usr/x86_64-w64-mingw32/bin/llvm-link <<EOF
+#!/bin/sh
+wine64 llvm-link \$@
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/llvm-link
+
+cat >/usr/x86_64-w64-mingw32/bin/opt <<EOF
+#!/bin/sh
+wine64 opt \$@
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/opt
+
+cat >/usr/x86_64-w64-mingw32/bin/llvm-spirv <<EOF
+#!/bin/sh
+wine64 llvm-spirv \$@
+EOF
+chmod +x /usr/x86_64-w64-mingw32/bin/llvm-spirv
diff --git a/.gitlab-ci/container/debian/x86_build-mingw-source-deps.sh b/.gitlab-ci/container/debian/x86_build-mingw-source-deps.sh
new file mode 100644
index 00000000000..0fee1723da6
--- /dev/null
+++ b/.gitlab-ci/container/debian/x86_build-mingw-source-deps.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+wd=$PWD
+CMAKE_TOOLCHAIN_MINGW_PATH=$wd/.gitlab-ci/container/debian/x86_mingw-toolchain.cmake
+mkdir -p ~/tmp
+pushd ~/tmp
+
+# Building DirectX-Headers
+git clone https://github.com/microsoft/DirectX-Headers -b mesa-mingw --depth 1
+mkdir -p DirectX-Headers/build
+pushd DirectX-Headers/build
+meson .. \
+--backend=ninja \
+--buildtype=release -Dbuild-test=false \
+-Dprefix=/usr/x86_64-w64-mingw32/ \
+--cross-file=$wd/.gitlab-ci/x86_64-w64-mingw32
+
+ninja install
+popd
+
+export VULKAN_SDK_VERSION=1.3.211.0
+
+# Building SPIRV Tools
+git clone -b sdk-$VULKAN_SDK_VERSION --depth=1 \
+https://github.com/KhronosGroup/SPIRV-Tools SPIRV-Tools
+
+git clone -b sdk-$VULKAN_SDK_VERSION --depth=1 \
+https://github.com/KhronosGroup/SPIRV-Headers SPIRV-Tools/external/SPIRV-Headers
+
+mkdir -p SPIRV-Tools/build
+pushd SPIRV-Tools/build
+cmake .. \
+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_MINGW_PATH \
+-DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32/ \
+-GNinja -DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_CROSSCOMPILING=1 \
+-DCMAKE_POLICY_DEFAULT_CMP0091=NEW
+
+ninja install
+popd
+
+# Building LLVM
+git clone -b release/14.x --depth=1 \
+https://github.com/llvm/llvm-project llvm-project
+
+git clone -b v14.0.0 --depth=1 \
+https://github.com/KhronosGroup/SPIRV-LLVM-Translator llvm-project/llvm/projects/SPIRV-LLVM-Translator
+
+mkdir llvm-project/build
+pushd llvm-project/build
+cmake ../llvm \
+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_MINGW_PATH \
+-DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32/ \
+-GNinja -DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_CROSSCOMPILING=1 \
+-DLLVM_ENABLE_RTTI=ON \
+-DCROSS_TOOLCHAIN_FLAGS_NATIVE=-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=$PWD/../../SPIRV-Tools/external/SPIRV-Headers \
+-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=$PWD/../../SPIRV-Tools/external/SPIRV-Headers \
+-DLLVM_ENABLE_PROJECTS="clang;lld" \
+-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \
+-DLLVM_OPTIMIZED_TABLEGEN=TRUE \
+-DLLVM_ENABLE_ASSERTIONS=TRUE \
+-DLLVM_INCLUDE_UTILS=OFF \
+-DLLVM_INCLUDE_RUNTIMES=OFF \
+-DLLVM_INCLUDE_TESTS=OFF \
+-DLLVM_INCLUDE_EXAMPLES=OFF \
+-DLLVM_INCLUDE_GO_TESTS=OFF \
+-DLLVM_INCLUDE_BENCHMARKS=OFF \
+-DLLVM_BUILD_LLVM_C_DYLIB=OFF \
+-DLLVM_ENABLE_DIA_SDK=OFF \
+-DCLANG_BUILD_TOOLS=ON \
+-DLLVM_SPIRV_INCLUDE_TESTS=OFF
+
+ninja install
+popd
+
+# Building libclc
+mkdir llvm-project/build-libclc
+pushd llvm-project/build-libclc
+cmake ../libclc \
+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_MINGW_PATH \
+-DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32/ \
+-GNinja -DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_CROSSCOMPILING=1 \
+-DCMAKE_POLICY_DEFAULT_CMP0091=NEW \
+-DCMAKE_CXX_FLAGS="-m64" \
+-DLLVM_CONFIG="/usr/x86_64-w64-mingw32/bin/llvm-config" \
+-DLLVM_CLANG="/usr/x86_64-w64-mingw32/bin/clang" \
+-DLLVM_AS="/usr/x86_64-w64-mingw32/bin/llvm-as" \
+-DLLVM_LINK="/usr/x86_64-w64-mingw32/bin/llvm-link" \
+-DLLVM_OPT="/usr/x86_64-w64-mingw32/bin/opt" \
+-DLLVM_SPIRV="/usr/x86_64-w64-mingw32/bin/llvm-spirv" \
+-DLIBCLC_TARGETS_TO_BUILD="spirv-mesa3d-;spirv64-mesa3d-"
+
+ninja install
+popd
+
+popd # ~/tmp
+
+# Cleanup ~/tmp
+rm -rf ~/tmp
diff --git a/.gitlab-ci/container/debian/x86_build-mingw.sh b/.gitlab-ci/container/debian/x86_build-mingw.sh
new file mode 100644
index 00000000000..34630e45a46
--- /dev/null
+++ b/.gitlab-ci/container/debian/x86_build-mingw.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -e
+set -o xtrace
+
+apt-get update
+apt-get install -y --no-remove \
+ zstd \
+ g++-mingw-w64-i686 \
+ g++-mingw-w64-x86-64
+
+. .gitlab-ci/container/debian/x86_build-mingw-patch.sh
+. .gitlab-ci/container/debian/x86_build-mingw-source-deps.sh
diff --git a/.gitlab-ci/container/debian/x86_build.sh b/.gitlab-ci/container/debian/x86_build.sh
index 8fa9f083a4d..e2695564ea5 100644
--- a/.gitlab-ci/container/debian/x86_build.sh
+++ b/.gitlab-ci/container/debian/x86_build.sh
@@ -15,15 +15,12 @@ STABLE_EPHEMERAL=" \
python3-pip \
"
-# We need multiarch for Wine
-dpkg --add-architecture i386
apt-get update
apt-get install -y --no-remove \
$STABLE_EPHEMERAL \
check \
clang \
- cmake \
libasan6 \
libarchive-dev \
libclang-cpp11-dev \
@@ -49,25 +46,11 @@ apt-get install -y --no-remove \
procps \
spirv-tools \
strace \
- time \
- wine \
- wine32
+ time
. .gitlab-ci/container/container_pre_build.sh
-
-# Debian's pkg-config wrapers for mingw are broken, and there's no sign that
-# they're going to be fixed, so we'll just have to fix it ourselves
-# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
-cat >/usr/local/bin/x86_64-w64-mingw32-pkg-config <<EOF
-#!/bin/sh
-
-PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig pkg-config \$@
-EOF
-chmod +x /usr/local/bin/x86_64-w64-mingw32-pkg-config
-
-
# dependencies where we want a specific version
export XORG_RELEASES=https://xorg.freedesktop.org/releases/individual
@@ -89,7 +72,7 @@ cd shader-db
make
popd
-git clone https://github.com/microsoft/DirectX-Headers -b v1.602.0-r1 --depth 1
+git clone https://github.com/microsoft/DirectX-Headers -b mesa-mingw --depth 1
mkdir -p DirectX-Headers/build
pushd DirectX-Headers/build
meson .. --backend=ninja --buildtype=release -Dbuild-test=false
diff --git a/.gitlab-ci/container/debian/x86_mingw-toolchain.cmake b/.gitlab-ci/container/debian/x86_mingw-toolchain.cmake
new file mode 100644
index 00000000000..70da12d3844
--- /dev/null
+++ b/.gitlab-ci/container/debian/x86_mingw-toolchain.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_SYSTEM_NAME Windows)
+set(CMAKE_SYSTEM_PROCESSOR x86_64)
+
+set(CMAKE_SYSROOT /usr/x86_64-w64-mingw32/)
+set(ENV{PKG_CONFIG} /usr/x86_64-w64-mingw32/bin/pkg-config)
+
+set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix)
+set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix)
diff --git a/.gitlab-ci/meson/build.sh b/.gitlab-ci/meson/build.sh
index 43255b89e31..2d22df886f1 100755
--- a/.gitlab-ci/meson/build.sh
+++ b/.gitlab-ci/meson/build.sh
@@ -48,6 +48,8 @@ case $CI_JOB_NAME in
if test -f /usr/bin/time; then
MESON_TEST_ARGS+=--wrapper=$PWD/.gitlab-ci/meson/time.sh
fi
+ Xvfb :0 -screen 0 1024x768x16 &
+ export DISPLAY=:0.0
;;
*)
if test -f /usr/bin/time -a -f /usr/bin/strace; then
diff --git a/.gitlab-ci/x86_64-w64-mingw32 b/.gitlab-ci/x86_64-w64-mingw32
index 4db606e2bf7..e17ddf47681 100644
--- a/.gitlab-ci/x86_64-w64-mingw32
+++ b/.gitlab-ci/x86_64-w64-mingw32
@@ -1,9 +1,10 @@
[binaries]
-c = ['ccache', 'x86_64-w64-mingw32-gcc']
-cpp = ['ccache', 'x86_64-w64-mingw32-g++']
+c = ['ccache', 'x86_64-w64-mingw32-gcc-posix']
+cpp = ['ccache', 'x86_64-w64-mingw32-g++-posix']
ar = 'x86_64-w64-mingw32-ar'
strip = 'x86_64-w64-mingw32-strip'
-pkgconfig = '/usr/local/bin/x86_64-w64-mingw32-pkg-config'
+pkgconfig = '/usr/x86_64-w64-mingw32/bin/pkg-config'
+llvm-config = '/usr/x86_64-w64-mingw32/bin/llvm-config'
windres = 'x86_64-w64-mingw32-windres'
exe_wrapper = ['wine64']