1
0
mirror of https://github.com/skeeto/w64devkit.git synced 2026-10-23 06:08:56 +03:00

Manage patch queues with quilt series files

Move each component's patches from flat, prefixed file names into a
per-component directory with a quilt series file, dropping the number
prefixes: application order is now stated by series rather than
enforced by lexicographic glob expansion. Outside the build, a queue
is managed by our own quilt against an unpacked tarball from source/
with QUILT_PATCHES=/path/to/src/<component>. The shipped kit carries
the same layout under $W64DEVKIT_HOME/src, consumable by the bundled
quilt.exe the same way.

Inside the build, apply queues with Debian's original quilt rather
than a native build of src/quilt.cpp, whose amalgamation is
Windows-only. This keeps battle-tested GNU patch as the engine, and
makes every image build a conformance check: series semantics mean
whatever the reference implementation says, and a queue our clone
manages must be accepted by original quilt. The .pc state is removed
after each push because source trees are never popped, and a stale
.pc from one queue blocks pushing a second queue onto the same tree,
which happens twice: gcc then crossgcc, mingw then gendef.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Christopher Wellons
2026-08-30 17:17:19 -04:00
parent 54c7887e6d
commit 5179007b22
53 changed files with 96 additions and 29 deletions

View File

@@ -8,7 +8,7 @@ ENV PREFIX=$PREFIX
RUN apt-get update && apt-get install --yes --no-install-recommends \
build-essential cmake libgmp-dev libmpc-dev libmpfr-dev m4 p7zip-full \
python3 scons
python3 quilt scons
COPY src/w64devkit.ico src/alias.c $PREFIX/src/
@@ -237,10 +237,15 @@ ENV ARCH=i686-w64-mingw32 \
FROM variant-${VARIANT} AS cross
WORKDIR /dl/binutils
COPY src/binutils-*.patch $PREFIX/src/
COPY src/binutils/ $PREFIX/src/binutils/
# Patch queues are applied with quilt, ordered by each queue's series
# file. The .pc/ state is removed after each push: source trees are
# never popped, and a stale .pc would block pushing a second queue
# onto the same tree later (gcc then crossgcc, mingw then gendef).
RUN sed -ri 's/(static bool insert_timestamp = )/\1!/' ld/emultempl/pe*.em \
&& sed -ri 's/(int pe_enable_stdcall_fixup = )/\1!!/' ld/emultempl/pe*.em \
&& cat $PREFIX/src/binutils-*.patch | patch -p1
&& QUILT_PATCHES=$PREFIX/src/binutils quilt push -a \
&& rm -rf .pc
WORKDIR /x-binutils
RUN /dl/binutils/configure \
--prefix=/bootstrap \
@@ -256,8 +261,10 @@ RUN /dl/binutils/configure \
# https://sourceforge.net/p/mingw-w64/bugs/821/
RUN sed -i /OpenThreadToken/d /dl/mingw/mingw-w64-crt/lib32/kernel32.def
COPY src/mingw-*.patch $PREFIX/src/
RUN cat $PREFIX/src/mingw-*.patch | patch -d/dl/mingw -p1
COPY src/mingw/ $PREFIX/src/mingw/
RUN cd /dl/mingw \
&& QUILT_PATCHES=$PREFIX/src/mingw quilt push -a \
&& rm -rf .pc
WORKDIR /x-mingw-headers
RUN printf '#include <crtdefs.h>\n#if __has_include_next(<stddef.h>)\n#include_next <stddef.h>\n#endif\n' \
@@ -273,8 +280,10 @@ WORKDIR /bootstrap
RUN ln -s /bootstrap mingw
WORKDIR /x-gcc
COPY src/gcc-*.patch $PREFIX/src/
RUN cat $PREFIX/src/gcc-*.patch | patch -d/dl/gcc -p1 \
COPY src/gcc/ $PREFIX/src/gcc/
RUN (cd /dl/gcc \
&& QUILT_PATCHES=$PREFIX/src/gcc quilt push -a \
&& rm -rf .pc) \
&& /dl/gcc/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
@@ -497,8 +506,10 @@ RUN if [ "$GCC_MULTILIB" = enable ]; then \
fi
WORKDIR /gcc
COPY src/crossgcc-*.patch $PREFIX/src/
RUN cat $PREFIX/src/crossgcc-*.patch | patch -d/dl/gcc -p1 \
COPY src/crossgcc/ $PREFIX/src/crossgcc/
RUN (cd /dl/gcc \
&& QUILT_PATCHES=$PREFIX/src/crossgcc quilt push -a \
&& rm -rf .pc) \
&& /dl/gcc/configure \
--prefix=$PREFIX \
--with-sysroot=$PREFIX \
@@ -608,8 +619,10 @@ RUN if [ "$GCC_MULTILIB" = enable ]; then \
FROM cross AS build-gendef
WORKDIR /mingw-tools/gendef
COPY src/gendef-*.patch $PREFIX/src/
RUN cat $PREFIX/src/gendef-*.patch | patch -d/dl/mingw -p1 \
COPY src/gendef/ $PREFIX/src/gendef/
RUN (cd /dl/mingw \
&& QUILT_PATCHES=$PREFIX/src/gendef quilt push -a \
&& rm -rf .pc) \
&& /dl/mingw/mingw-w64-tools/gendef/configure \
--host=$ARCH \
CFLAGS="-O2" \
@@ -678,8 +691,10 @@ RUN /dl/libiconv/configure \
&& make install
WORKDIR /gdb
COPY src/gdb-*.patch $PREFIX/src/
RUN cat $PREFIX/src/gdb-*.patch | patch -d/dl/gdb -p1 \
COPY src/gdb/ $PREFIX/src/gdb/
RUN (cd /dl/gdb \
&& QUILT_PATCHES=$PREFIX/src/gdb quilt push -a \
&& rm -rf .pc) \
&& sed -i 's/quiet = 0/quiet = 1/' /dl/gdb/gdb/main.c \
&& /dl/gdb/configure \
--host=$ARCH \
@@ -695,8 +710,10 @@ FROM cross AS build-make
COPY --from=dl-make /dl/ /dl/
WORKDIR /make
COPY src/make-*.patch $PREFIX/src/
RUN cat $PREFIX/src/make-*.patch | patch -d/dl/make -p1 \
COPY src/make/ $PREFIX/src/make/
RUN (cd /dl/make \
&& QUILT_PATCHES=$PREFIX/src/make quilt push -a \
&& rm -rf .pc) \
&& /dl/make/configure \
--host=$ARCH \
--disable-nls \
@@ -714,8 +731,10 @@ FROM cross AS build-busybox
COPY --from=dl-busybox /dl/ /dl/
WORKDIR /dl/busybox
COPY src/busybox-* $PREFIX/src/
RUN cat $PREFIX/src/busybox-*.patch | patch -p1 \
COPY src/busybox/ $PREFIX/src/busybox/
COPY src/busybox-alias.c $PREFIX/src/
RUN QUILT_PATCHES=$PREFIX/src/busybox quilt push -a \
&& rm -rf .pc \
&& make $BUSYBOX_CONFIG \
&& sed -ri 's/^(CONFIG_AR)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_ASCII)=y/\1=n/' .config \
@@ -764,8 +783,10 @@ FROM cross AS build-vim
COPY --from=dl-vim /dl/ /dl/
WORKDIR /dl/vim
COPY src/rexxd.c src/vim-*.patch $PREFIX/src/
RUN cat $PREFIX/src/vim-*.patch | patch -p1 \
COPY src/rexxd.c $PREFIX/src/
COPY src/vim/ $PREFIX/src/vim/
RUN QUILT_PATCHES=$PREFIX/src/vim quilt push -a \
&& rm -rf .pc \
&& ARCH= make -C src -j$(nproc) -f Make_ming.mak CC="$ARCH-gcc -std=gnu17" \
OPTIMIZE=SPEED STATIC_STDCPLUS=yes HAS_GCC_EH=no \
UNDER_CYGWIN=yes CROSS=yes CROSS_COMPILE=$ARCH- \
@@ -791,8 +812,9 @@ FROM cross AS build-ctags
COPY --from=dl-ctags /dl/ /dl/
WORKDIR /dl/ctags
COPY src/ctags-*.patch $PREFIX/src/
RUN cat $PREFIX/src/ctags-*.patch | patch -p1 \
COPY src/ctags/ $PREFIX/src/ctags/
RUN QUILT_PATCHES=$PREFIX/src/ctags quilt push -a \
&& rm -rf .pc \
&& sed -i /RT_MANIFEST/d win32/ctags.rc \
&& make -j$(nproc) -f mk_mingw.mak CC=gcc packcc.exe \
&& make -j$(nproc) -f mk_mingw.mak \
@@ -821,8 +843,10 @@ RUN make -j$(nproc) -C programs zstd \
FROM cross AS build-ccache
COPY --from=dl-ccache /dl/ /dl/
COPY --from=build-zstd /deps/ /deps/
COPY src/ccache-*.patch $PREFIX/src/
RUN cat $PREFIX/src/ccache-*.patch | patch -d/dl/ccache -p1
COPY src/ccache/ $PREFIX/src/ccache/
RUN cd /dl/ccache \
&& QUILT_PATCHES=$PREFIX/src/ccache quilt push -a \
&& rm -rf .pc
WORKDIR /dl/xxhash
RUN make -j$(nproc) CC=$ARCH-gcc AR=$ARCH-ar CFLAGS="-O2" libxxhash.a \
@@ -870,10 +894,12 @@ RUN $ARCH-gcc -DEXE=ccache.exe -DCMD=gcc \
FROM cross AS build-ninja
COPY --from=dl-ninja /dl/ /dl/
COPY src/ninja-*.patch $PREFIX/src/
COPY src/ninja/ $PREFIX/src/ninja/
WORKDIR /ninja
RUN cat $PREFIX/src/ninja-*.patch | patch -d/dl/ninja -p1 \
RUN (cd /dl/ninja \
&& QUILT_PATCHES=$PREFIX/src/ninja quilt push -a \
&& rm -rf .pc) \
&& cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_CXX_COMPILER=$ARCH-g++ \
@@ -904,8 +930,10 @@ COPY --from=build-pdcurses /deps/lib/libcurses.a /deps/lib/
COPY --from=build-pdcurses /deps/include/curses.h /deps/include/
WORKDIR /cmake
COPY src/cmake-*.patch $PREFIX/src/
RUN cat $PREFIX/src/cmake-*.patch | patch -d/dl/cmake -p1 \
COPY src/cmake/ $PREFIX/src/cmake/
RUN (cd /dl/cmake \
&& QUILT_PATCHES=$PREFIX/src/cmake quilt push -a \
&& rm -rf .pc) \
&& cmake -DCMAKE_C_FLAGS="$CMAKE_WINNT_C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CMAKE_WINNT_CXX_FLAGS" \
-DCMAKE_BUILD_TYPE=Release \
@@ -965,12 +993,13 @@ RUN cmake -B /aas-sign-build-w32 -S /dl/aas-sign \
FROM cross AS build-nsis
COPY --from=dl-nsis /dl/nsis /dl/nsis
COPY src/nsis-*.patch $PREFIX/src/
COPY src/nsis/ $PREFIX/src/nsis/
WORKDIR /dl/nsis
# Source/build.cpp ships with CRLF line endings; everything else in
# the tree is LF. Strip the carriage returns so our LF patch applies.
RUN sed -i 's/\r$//' Source/build.cpp \
&& cat $PREFIX/src/nsis-*.patch | patch -p1 \
&& QUILT_PATCHES=$PREFIX/src/nsis quilt push -a \
&& rm -rf .pc \
&& scons -j$(nproc) \
XGCC_W32_PREFIX=$ARCH- \
TARGET_ARCH=$NSIS_ARCH \

5
src/binutils/series Normal file
View File

@@ -0,0 +1,5 @@
dlltool-zero-ordinals.patch
exclude-sysroot.patch
windmc-bom.patch
windmc-carry-severity-facility.patch
windmc-per-facility-ids.patch

6
src/busybox/series Normal file
View File

@@ -0,0 +1,6 @@
disable-beep.patch
disable-empty-complete.patch
default-noiconify.patch
system-profile.patch
zstd.patch
mkdtemp.patch

2
src/ccache/series Normal file
View File

@@ -0,0 +1,2 @@
handle-diagnostic-colors.patch
write-unicode-diagnostics.patch

1
src/cmake/series Normal file
View File

@@ -0,0 +1 @@
force-ninja.patch

5
src/crossgcc/series Normal file
View File

@@ -0,0 +1,5 @@
Os-no-declone-ctor-dtor.patch
driver-self-locate.patch
i686-dumpmachine.patch
libgomp-gfortran-path.patch
relocatable.patch

3
src/ctags/series Normal file
View File

@@ -0,0 +1,3 @@
fix-trailing-slash.patch
qml.patch
silence-warnings.patch

4
src/gcc/series Normal file
View File

@@ -0,0 +1,4 @@
avx-misaligned.patch
dynamic-load-tzdb.patch
libgfortran-mapview.patch
trap-terminate.patch

2
src/gdb/series Normal file
View File

@@ -0,0 +1,2 @@
alternate-main.patch
confirm-off.patch

1
src/gendef/series Normal file
View File

@@ -0,0 +1 @@
silent.patch

2
src/make/series Normal file
View File

@@ -0,0 +1,2 @@
force-slow.patch
shell-space.patch

2
src/mingw/series Normal file
View File

@@ -0,0 +1,2 @@
default-win32-winnt.patch
imp-strtof_l.patch

1
src/ninja/series Normal file
View File

@@ -0,0 +1 @@
fix-recovery.patch

2
src/nsis/series Normal file
View File

@@ -0,0 +1,2 @@
cross-makensis.patch
no-ansi.patch

2
src/vim/series Normal file
View File

@@ -0,0 +1,2 @@
guifont.patch
qml.patch