Skip to content

Commit 56d1798

Browse files
committed
cmake: add patch for 32-bit builds
1 parent 0ac51a1 commit 56d1798

File tree

4 files changed

+117
-4
lines changed

4 files changed

+117
-4
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From c55dfbf6568d17643ddc34f5facf25e3a90acdc9 Mon Sep 17 00:00:00 2001
2+
From: Brad King <[email protected]>
3+
Date: Thu, 11 Dec 2025 10:48:00 -0500
4+
Subject: [PATCH] StdIo: Restore compilation on 32-bit MinGW
5+
6+
In commit e419429616 (StdIo: Restore Windows Console I/O modes on
7+
Ctrl-C, 2025-11-26, v4.1.4~4^2) we relied on the compiler to generate a
8+
lambda with an `operator()` for each calling convention. MSVC does
9+
this, but the GNU compiler for MinGW does not seem to.
10+
---
11+
Source/cmStdIoInit.cxx | 18 +++++++++++-------
12+
1 file changed, 11 insertions(+), 7 deletions(-)
13+
14+
diff --git a/Source/cmStdIoInit.cxx b/Source/cmStdIoInit.cxx
15+
index a2fc50db7f3..49f31873bdc 100644
16+
--- a/Source/cmStdIoInit.cxx
17+
+++ b/Source/cmStdIoInit.cxx
18+
@@ -93,19 +93,23 @@ public:
19+
20+
Globals();
21+
22+
+#ifdef _WIN32
23+
+ static BOOL WINAPI CtrlHandler(DWORD /*dwCtrlType*/)
24+
+ {
25+
+ Get().StdErr.Destroy();
26+
+ Get().StdOut.Destroy();
27+
+ Get().StdIn.Destroy();
28+
+ return FALSE;
29+
+ }
30+
+#endif
31+
+
32+
static Globals& Get();
33+
};
34+
35+
#ifdef _WIN32
36+
Globals::Globals()
37+
{
38+
- static auto const ctrlHandler = [](DWORD /*dwCtrlType*/) -> BOOL {
39+
- Get().StdErr.Destroy();
40+
- Get().StdOut.Destroy();
41+
- Get().StdIn.Destroy();
42+
- return FALSE;
43+
- };
44+
- SetConsoleCtrlHandler(ctrlHandler, TRUE);
45+
+ SetConsoleCtrlHandler(CtrlHandler, TRUE);
46+
}
47+
#else
48+
Globals::Globals() = default;
49+
--
50+
GitLab
51+

mingw-w64-cmake-bootstrap/PKGBUILD

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ conflicts=(
2727
provides=("${MINGW_PACKAGE_PREFIX}-cmake=${pkgver}")
2828
source=("https://github.com/Kitware/CMake/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz"
2929
"0003-fix-find-python-on-mingw-aarch64.patch"
30-
"0005-Default-to-ninja-generator.patch")
30+
"0005-Default-to-ninja-generator.patch"
31+
"0100-Restore-compilation-on-32-bit-MinGW.patch")
3132
sha256sums=('414aacfac54ba0e78e64a018720b64ed6bfca14b587047b8b3489f407a14a070'
3233
'557b5cbc05d4d50b3a67a7892391fcaa5cd95c492cdb4338d86305d1f4a3b88a'
33-
'426818278090704d2a12f62ef3dfd94c47b11fa2784bb842989b7f6a09ee7aa2')
34+
'426818278090704d2a12f62ef3dfd94c47b11fa2784bb842989b7f6a09ee7aa2'
35+
'2306d79614a10d51826c33e0dc5bc533ad06ee221a0d72ca9efb0a105574804d')
3436

3537
prepare() {
3638
cd "${_realname}-${pkgver}"
3739

3840
patch -Np1 -i "${srcdir}/0003-fix-find-python-on-mingw-aarch64.patch"
3941
patch -Np1 -i "${srcdir}/0005-Default-to-ninja-generator.patch"
42+
patch -Np1 -i "${srcdir}/0100-Restore-compilation-on-32-bit-MinGW.patch"
4043

4144
find . -name "*.orig" -exec rm -f {} \;
4245
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From c55dfbf6568d17643ddc34f5facf25e3a90acdc9 Mon Sep 17 00:00:00 2001
2+
From: Brad King <[email protected]>
3+
Date: Thu, 11 Dec 2025 10:48:00 -0500
4+
Subject: [PATCH] StdIo: Restore compilation on 32-bit MinGW
5+
6+
In commit e419429616 (StdIo: Restore Windows Console I/O modes on
7+
Ctrl-C, 2025-11-26, v4.1.4~4^2) we relied on the compiler to generate a
8+
lambda with an `operator()` for each calling convention. MSVC does
9+
this, but the GNU compiler for MinGW does not seem to.
10+
---
11+
Source/cmStdIoInit.cxx | 18 +++++++++++-------
12+
1 file changed, 11 insertions(+), 7 deletions(-)
13+
14+
diff --git a/Source/cmStdIoInit.cxx b/Source/cmStdIoInit.cxx
15+
index a2fc50db7f3..49f31873bdc 100644
16+
--- a/Source/cmStdIoInit.cxx
17+
+++ b/Source/cmStdIoInit.cxx
18+
@@ -93,19 +93,23 @@ public:
19+
20+
Globals();
21+
22+
+#ifdef _WIN32
23+
+ static BOOL WINAPI CtrlHandler(DWORD /*dwCtrlType*/)
24+
+ {
25+
+ Get().StdErr.Destroy();
26+
+ Get().StdOut.Destroy();
27+
+ Get().StdIn.Destroy();
28+
+ return FALSE;
29+
+ }
30+
+#endif
31+
+
32+
static Globals& Get();
33+
};
34+
35+
#ifdef _WIN32
36+
Globals::Globals()
37+
{
38+
- static auto const ctrlHandler = [](DWORD /*dwCtrlType*/) -> BOOL {
39+
- Get().StdErr.Destroy();
40+
- Get().StdOut.Destroy();
41+
- Get().StdIn.Destroy();
42+
- return FALSE;
43+
- };
44+
- SetConsoleCtrlHandler(ctrlHandler, TRUE);
45+
+ SetConsoleCtrlHandler(CtrlHandler, TRUE);
46+
}
47+
#else
48+
Globals::Globals() = default;
49+
--
50+
GitLab
51+

mingw-w64-cmake/PKGBUILD

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ source=("https://github.com/Kitware/CMake/releases/download/v${_pkgver}/${_realn
5151
"0001-Disable-response-files-for-MSYS-Generator.patch"
5252
"0002-Do-not-install-Qt-bundle-in-cmake-gui.patch"
5353
"0003-fix-find-python-on-mingw-aarch64.patch"
54-
"0005-Default-to-ninja-generator.patch")
54+
"0005-Default-to-ninja-generator.patch"
55+
"0100-Restore-compilation-on-32-bit-MinGW.patch")
5556
sha256sums=('414aacfac54ba0e78e64a018720b64ed6bfca14b587047b8b3489f407a14a070'
5657
'25793edcbac05bb6d17fa9947b52ace4a6b5ccccf7758e22ae9ae022ed089061'
5758
'f6cf6a6f2729db2b9427679acd09520af2cd79fc26900b19a49cead05a55cd1a'
5859
'557b5cbc05d4d50b3a67a7892391fcaa5cd95c492cdb4338d86305d1f4a3b88a'
59-
'426818278090704d2a12f62ef3dfd94c47b11fa2784bb842989b7f6a09ee7aa2')
60+
'426818278090704d2a12f62ef3dfd94c47b11fa2784bb842989b7f6a09ee7aa2'
61+
'2306d79614a10d51826c33e0dc5bc533ad06ee221a0d72ca9efb0a105574804d')
6062

6163
# Helper macros to help make tasks easier #
6264
apply_patch_with_msg() {
@@ -88,6 +90,12 @@ prepare() {
8890
apply_patch_with_msg \
8991
0005-Default-to-ninja-generator.patch
9092

93+
# Taken from <https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11503>.
94+
# See <https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11457#note_1743658>
95+
# for more context.
96+
apply_patch_with_msg \
97+
0100-Restore-compilation-on-32-bit-MinGW.patch
98+
9199
find . -name "*.orig" -exec rm -f {} \;
92100
}
93101

0 commit comments

Comments
 (0)