Skip to content

Commit 9efc2e5

Browse files
ci: Add MSVC builds
This adds MSVC builds built on Linux using wine. This requires some settings of tools and flags because the autotools support for MSVC is naturally somewhat limited. The advantage of this approach is that it is compatible with our existing CI scripts, so there's no need to write a Windows CI script (in PowerShell or similar). If we want to test building and running on Windows native (e.g., as supported by Cirrus CI) we could still do this in the future. Another advantage of this approach is that contributors can simply use the docker image if they need a MSVC installation in a non-Windows environment. This commit also improves the Dockerfile by grouping RUN commands according to Docker docs: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
1 parent 2be6ba0 commit 9efc2e5

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

.cirrus.yml

+36
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,42 @@ task:
263263
- ./ci/cirrus.sh
264264
<< : *CAT_LOGS
265265

266+
task:
267+
<< : *LINUX_CONTAINER
268+
env:
269+
WRAPPER_CMD: wine
270+
WERROR_CFLAGS: -WX
271+
WITH_VALGRIND: no
272+
ECDH: yes
273+
RECOVERY: yes
274+
EXPERIMENTAL: yes
275+
SCHNORRSIG: yes
276+
CTIMETEST: no
277+
# Set non-essential options that affect the CLI messages here.
278+
# (They depend on the user's taste, so we don't want to set them automatically in configure.ac.)
279+
CFLAGS: -nologo -diagnostics:caret
280+
LDFLAGS: -XCClinker -nologo -XCClinker -diagnostics:caret
281+
# Use a MinGW-w64 host to tell ./configure we're building for Windows.
282+
# This will detect some MinGW-w64 tools but then make will need only
283+
# the MSVC tools CC, AR and NM as specified below.
284+
matrix:
285+
- name: "x86_64 (MSVC): Windows (Debian stable, Wine)"
286+
env:
287+
HOST: x86_64-w64-mingw32
288+
CC: /opt/msvc/bin/x64/cl
289+
AR: /opt/msvc/bin/x64/lib
290+
NM: /opt/msvc/bin/x64/dumpbin -symbols -headers
291+
- name: "i686 (MSVC): Windows (Debian stable, Wine)"
292+
env:
293+
HOST: i686-w64-mingw32
294+
CC: /opt/msvc/bin/x86/cl
295+
AR: /opt/msvc/bin/x86/lib
296+
NM: /opt/msvc/bin/x86/dumpbin -symbols -headers
297+
<< : *MERGE_BASE
298+
test_script:
299+
- ./ci/cirrus.sh
300+
<< : *CAT_LOGS
301+
266302
# Sanitizers
267303
task:
268304
<< : *LINUX_CONTAINER

ci/cirrus.sh

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env >> test_env.log
99

1010
$CC -v || true
1111
valgrind --version || true
12+
$WRAPPER_CMD --version || true
1213

1314
./autogen.sh
1415

ci/linux-debian.Dockerfile

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
FROM debian:stable
22

3-
RUN dpkg --add-architecture i386
4-
RUN dpkg --add-architecture s390x
5-
RUN dpkg --add-architecture armhf
6-
RUN dpkg --add-architecture arm64
7-
RUN dpkg --add-architecture ppc64el
8-
RUN apt-get update
3+
RUN dpkg --add-architecture i386 && \
4+
dpkg --add-architecture s390x && \
5+
dpkg --add-architecture armhf && \
6+
dpkg --add-architecture arm64 && \
7+
dpkg --add-architecture ppc64el
98

109
# dkpg-dev: to make pkg-config work in cross-builds
1110
# llvm: for llvm-symbolizer, which is used by clang's UBSan for symbolized stack traces
12-
RUN apt-get install --no-install-recommends --no-upgrade -y \
11+
RUN apt-get update && apt-get install --no-install-recommends -y \
1312
git ca-certificates \
1413
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
1514
gcc clang llvm libc6-dbg \
@@ -19,8 +18,20 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \
1918
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
2019
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 \
2120
gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross libc6-dbg:ppc64el \
22-
wine gcc-mingw-w64-x86-64 \
21+
gcc-mingw-w64-x86-64-win32 wine64 wine \
22+
gcc-mingw-w64-i686-win32 wine32 \
2323
sagemath
2424

25-
# Run a dummy command in wine to make it set up configuration
26-
RUN wine64-stable xcopy || true
25+
WORKDIR /root
26+
# The "wine" package provides a convience wrapper that we need
27+
RUN apt-get update && apt-get install --no-install-recommends -y \
28+
git ca-certificates wine64 wine python3-simplejson python3-six msitools winbind procps && \
29+
git clone https://github.com/mstorsjo/msvc-wine && \
30+
mkdir /opt/msvc && \
31+
python3 msvc-wine/vsdownload.py --accept-license --dest /opt/msvc Microsoft.VisualStudio.Workload.VCTools && \
32+
msvc-wine/install.sh /opt/msvc
33+
34+
# Initialize the wine environment. Wait until the wineserver process has
35+
# exited before closing the session, to avoid corrupting the wine prefix.
36+
RUN wine64 wineboot --init && \
37+
while (ps -A | grep wineserver) > /dev/null; do sleep 1; done

0 commit comments

Comments
 (0)