Skip to content

Commit 74cbe61

Browse files
authored
ci: fix Windows build in release.yml (#16280)
1 parent 9027af7 commit 74cbe61

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

Cross.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ pre-build = [
33
# rust-bindgen dependencies: llvm-dev libclang-dev (>= 10) clang (>= 10)
44
# See: https://github.com/cross-rs/cross/wiki/FAQ#using-clang--bindgen for
55
# recommended clang versions for the given cross and bindgen version.
6-
"apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev libclang-10-dev clang-10",
6+
"apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev libclang-dev clang",
77
]
88

9+
[target.x86_64-pc-windows-gnu]
10+
# Why do we need a custom Dockerfile on Windows:
11+
# 1. `reth-libmdbx` stopped working with MinGW 9.3 that cross image comes with.
12+
# 2. To be able to update the version of MinGW, we need to also update the Ubuntu that the image is based on.
13+
#
14+
# Also see https://github.com/cross-rs/cross/issues/1667
15+
# Inspired by https://github.com/cross-rs/cross/blob/9e2298e17170655342d3248a9c8ac37ef92ba38f/docker/Dockerfile.x86_64-pc-windows-gnu#L51
16+
dockerfile = "./Dockerfile.x86_64-pc-windows-gnu"
17+
918
[build.env]
10-
passthrough = [
11-
"JEMALLOC_SYS_WITH_LG_PAGE",
12-
]
19+
passthrough = ["JEMALLOC_SYS_WITH_LG_PAGE"]

Dockerfile.x86_64-pc-windows-gnu

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
FROM ubuntu:24.04 AS cross-base
2+
ENV DEBIAN_FRONTEND=noninteractive
3+
4+
RUN apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates
5+
6+
RUN git clone https://github.com/cross-rs/cross /cross
7+
WORKDIR /cross/docker
8+
RUN git checkout 9e2298e17170655342d3248a9c8ac37ef92ba38f
9+
10+
RUN cp common.sh lib.sh / && /common.sh
11+
RUN cp cmake.sh / && /cmake.sh
12+
RUN cp xargo.sh / && /xargo.sh
13+
14+
FROM cross-base AS build
15+
16+
RUN apt-get install --assume-yes --no-install-recommends libz-mingw-w64-dev g++-mingw-w64-x86-64 gfortran-mingw-w64-x86-64
17+
18+
RUN dpkg --add-architecture i386 && \
19+
apt-get install --assume-yes --no-install-recommends wget gpg && \
20+
mkdir -pm755 /etc/apt/keyrings && wget -O - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key - && \
21+
wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/noble/winehq-noble.sources && \
22+
apt-get update && apt-get install --assume-yes --install-recommends winehq-stable
23+
24+
# run-detectors are responsible for calling the correct interpreter for exe
25+
# files. For some reason it does not work inside a docker container (it works
26+
# fine in the host). So we replace the usual paths of run-detectors to run wine
27+
# directly. This only affects the guest, we are not messing up with the host.
28+
#
29+
# See /usr/share/doc/binfmt-support/detectors
30+
RUN mkdir -p /usr/lib/binfmt-support/ && \
31+
rm -f /usr/lib/binfmt-support/run-detectors /usr/bin/run-detectors && \
32+
ln -s /usr/bin/wine /usr/lib/binfmt-support/run-detectors && \
33+
ln -s /usr/bin/wine /usr/bin/run-detectors
34+
35+
RUN cp windows-entry.sh /
36+
ENTRYPOINT ["/windows-entry.sh"]
37+
38+
RUN cp toolchain.cmake /opt/toolchain.cmake
39+
40+
# for why we always link with pthread support, see:
41+
# https://github.com/cross-rs/cross/pull/1123#issuecomment-1312287148
42+
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-w64-mingw32-
43+
ENV CROSS_TOOLCHAIN_SUFFIX=-posix
44+
ENV CROSS_SYSROOT=/usr/x86_64-w64-mingw32
45+
ENV CROSS_TARGET_RUNNER="env -u CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER wine"
46+
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \
47+
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
48+
AR_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
49+
CC_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \
50+
CXX_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"g++"$CROSS_TOOLCHAIN_SUFFIX" \
51+
CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu=/opt/toolchain.cmake \
52+
BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
53+
CROSS_CMAKE_SYSTEM_NAME=Windows \
54+
CROSS_CMAKE_SYSTEM_PROCESSOR=AMD64 \
55+
CROSS_CMAKE_CRT=gnu \
56+
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -m64"

0 commit comments

Comments
 (0)