From 94e205d4745a3f141c9c1178f92f979bdf268e56 Mon Sep 17 00:00:00 2001 From: Will Toohey Date: Thu, 5 Mar 2026 20:01:12 +1000 Subject: [PATCH] Building with my own toolchain for realsies --- README.md | 16 +++++++++++----- build.sh | 7 +++++-- build_docker.sh | 12 ++++++++++++ cross-clang-mingw-32.ini | 13 +++++++++++++ ...w64-mingw32.txt => cross-clang-mingw-64.ini | 9 ++++----- cross-i686-w64-mingw32.txt | 14 -------------- docker/Dockerfile | 18 ++++++++++++++++++ playpen.sh | 2 +- 8 files changed, 64 insertions(+), 27 deletions(-) create mode 100644 build_docker.sh create mode 100644 cross-clang-mingw-32.ini rename cross-x86_64-w64-mingw32.txt => cross-clang-mingw-64.ini (54%) delete mode 100644 cross-i686-w64-mingw32.txt create mode 100644 docker/Dockerfile diff --git a/README.md b/README.md index 5cb0c7d..3707be3 100644 --- a/README.md +++ b/README.md @@ -138,12 +138,18 @@ a lot to be desired. There are many vestigal remains of past AVS experiments. Prior to version 3.0, it was built with Visual Studio 2017 with the 141_xp toolchain. However, in VS 2019 16.7, they broke this (it pulls in Vista-only -APIs), so I gave up and moved to mingw-w64. I currently just have that installed -in an Ubuntu install in WSL. If it ever breaks, I'll make a docker or nix image -or something... Feel free to open an issue if you're struggling to build it. +APIs), so I gave up and moved to mingw-w64. -As long as you have Meson and mingw-w64 installed, it should be as simple as -running `build.sh`. +Then, in 3.11, I decided that sticking to mingw gcc-11 (the last version that +easily supported XP) was pain, and made a [custom LLVM toolchain](https://github.com/mon/llvm-mingw-xp) +that supports XP, which lets me use C++23 features going forwards. + +If you want to build and have it support XP, the simplest approach is to run +`./build_docker.sh` on a Linux system, which will use my customised toolchain. + +However, you can also build with any modern clang/gcc with `build.sh`, as long +as you're OK with it only working on Windows 7 and up (and by the time you read +this, probably Windows 10 and up). # Contributing diff --git a/build.sh b/build.sh index 704f574..803d538 100644 --- a/build.sh +++ b/build.sh @@ -4,13 +4,16 @@ set -euxo pipefail rm -rf dist/ +CROSS_32="${CROSS_32:-cross-clang-mingw-32.ini}" +CROSS_64="${CROSS_64:-cross-clang-mingw-64.ini}" + # x86 -meson setup --cross-file cross-i686-w64-mingw32.txt build32 +meson setup --cross-file "$CROSS_32" build32 # without `--tags runtime`, the .a files are also installed meson install -C build32 --destdir ../dist/32bit --tags runtime,doc # x86_64 -meson setup --cross-file cross-x86_64-w64-mingw32.txt build64 +meson setup --cross-file "$CROSS_64" build64 meson install -C build64 --destdir ../dist/64bit --tags runtime,doc # docs diff --git a/build_docker.sh b/build_docker.sh new file mode 100644 index 0000000..7b70a7e --- /dev/null +++ b/build_docker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# highly recommend using podman-docker instead of docker, no "the build folder is owned by root" issues + +set -eu + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" + +docker build --pull "$SCRIPT_DIR/docker" -t layeredfs/deps --platform linux/x86_64 + +docker run -it --rm -v "$SCRIPT_DIR:/work" layeredfs/deps ./build.sh "$@" +docker run -it --rm -v "$SCRIPT_DIR:/work" layeredfs/deps ./test.sh "$@" diff --git a/cross-clang-mingw-32.ini b/cross-clang-mingw-32.ini new file mode 100644 index 0000000..aa3c162 --- /dev/null +++ b/cross-clang-mingw-32.ini @@ -0,0 +1,13 @@ +[binaries] +c = 'i686-w64-mingw32-clang' +cpp = 'i686-w64-mingw32-clang++' +ar = 'i686-w64-mingw32-ar' +windres = 'i686-w64-mingw32-windres' +strip = 'i686-w64-mingw32-strip' +exe_wrapper = 'wine' + +[host_machine] +system = 'windows' +cpu_family = 'x86' +cpu = 'x86' +endian = 'little' diff --git a/cross-x86_64-w64-mingw32.txt b/cross-clang-mingw-64.ini similarity index 54% rename from cross-x86_64-w64-mingw32.txt rename to cross-clang-mingw-64.ini index 560c6e9..0b975e0 100644 --- a/cross-x86_64-w64-mingw32.txt +++ b/cross-clang-mingw-64.ini @@ -1,14 +1,13 @@ [binaries] -c = 'x86_64-w64-mingw32-gcc' -cpp = 'x86_64-w64-mingw32-g++' +c = 'x86_64-w64-mingw32-clang' +cpp = 'x86_64-w64-mingw32-clang++' ar = 'x86_64-w64-mingw32-ar' +windres = 'x86_64-w64-mingw32-windres' strip = 'x86_64-w64-mingw32-strip' +exe_wrapper = 'wine' [host_machine] system = 'windows' cpu_family = 'x86_64' cpu = 'x86_64' endian = 'little' - -[properties] -needs_exe_wrapper = false diff --git a/cross-i686-w64-mingw32.txt b/cross-i686-w64-mingw32.txt deleted file mode 100644 index ba30ca3..0000000 --- a/cross-i686-w64-mingw32.txt +++ /dev/null @@ -1,14 +0,0 @@ -[binaries] -c = 'i686-w64-mingw32-gcc' -cpp = 'i686-w64-mingw32-g++' -ar = 'i686-w64-mingw32-ar' -strip = 'i686-w64-mingw32-strip' - -[host_machine] -system = 'windows' -cpu_family = 'x86' -cpu = 'i686' -endian = 'little' - -[properties] -needs_exe_wrapper = false diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f147d6b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,18 @@ +FROM montymintypie/llvm-mingw-xp:21 + +RUN set -eux; \ + dpkg --add-architecture i386; \ + apt-get update -qq; \ + DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \ + meson jq wine wine32; \ + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/*; + +# Run wineboot just to setup the default WINEPREFIX so we don't do it every +# container run +RUN wine wineboot --init + +ENV CROSS_32=/opt/llvm-mingw/toolchain-files/meson/i686-mingw32-clang.ini +ENV CROSS_64=/opt/llvm-mingw/toolchain-files/meson/x86_64-mingw32-clang.ini + +WORKDIR /work diff --git a/playpen.sh b/playpen.sh index 79440f1..1f93ea5 100644 --- a/playpen.sh +++ b/playpen.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -meson compile -C build64 playpen && ./build64/playpen.exe --layered-verbose "$@" +meson compile -C build64 playpen && wine ./build64/playpen.exe --layered-verbose "$@"