* [PATCH] gdb: fix MS_WIN64 redefinition error with Python >= 3.12 on MinGW
@ 2026-10-13 14:08 Simon Marchi
2026-10-14 11:57 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2026-10-13 14:08 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
When trying to cross-build GDB for x86_64-w64-mingw32 on Arch Linux
against Python 3.14 [1], I see:
CXX python/py-arch.o
In file included from /usr/x86_64-w64-mingw32/include/python314/Python.h:14,
from /home/smarchi/src/binutils-gdb/gdb/python/python-internal.h:59,
from /home/smarchi/src/binutils-gdb/gdb/python/py-arch.c:23:
/usr/x86_64-w64-mingw32/include/python314/pyconfig.h:253:9: error: ‘MS_WIN64’ redefined [-Werror]
253 | #define MS_WIN64
| ^~~~~~~~
<command-line>: note: this is the location of the previous definition
Our configure.ac defines MS_WIN64 because of this:
# On x64 Windows, Python's include headers, and pyconfig.h in
# particular, rely on MS_WIN64 macro to detect that it's a 64bit
# version of Windows. Unfortunately, MS_WIN64 is only defined if
# _MSC_VER, a Microsoft-specific macro, is defined. So, when
# building on x64 Windows with GCC, we define MS_WIN64 ourselves.
# The issue was reported to the Python community, but still isn't
# solved as of 2012-10-02 (http://bugs.python.org/issue4709).
Actually, since CPython commit 158b8a07212c ("gh-79218: Define
`MS_WIN64` macro for Mingw-w64 64bit on Windows (GH-100137)",
2022-12-12), which is in Python 3.12, pyconfig.h does define this macro
when building with MinGW. However, it defines it empty, whereas our
`-DMS_WIN64` defines it to 1, causing the macro redefinition error.
Change it to `-DMS_WIN64=`, which defines an empty macro, and avoids the
redefinition warning on Python >= 3.12. Older Python versions still get
the macro they need.
Regenerate configure.
[1] https://aur.archlinux.org/packages/mingw-w64-python314-bin
Change-Id: I67d9b6cb22d66812b4230d0cd5a51cfdc96dc379
---
gdb/configure | 15 +++++++++------
gdb/configure.ac | 15 +++++++++------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/gdb/configure b/gdb/configure
index 810e9ed7a378..90a8ea0b7ebd 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -28677,16 +28677,19 @@ $as_echo "${PYTHON_CFLAGS}" >&6; }
# On x64 Windows, Python's include headers, and pyconfig.h in
# particular, rely on MS_WIN64 macro to detect that it's a 64bit
- # version of Windows. Unfortunately, MS_WIN64 is only defined if
- # _MSC_VER, a Microsoft-specific macro, is defined. So, when
- # building on x64 Windows with GCC, we define MS_WIN64 ourselves.
- # The issue was reported to the Python community, but still isn't
- # solved as of 2012-10-02 (http://bugs.python.org/issue4709).
+ # version of Windows. Before Python 3.12, MS_WIN64 is only defined
+ # if _MSC_VER, a Microsoft-specific macro, is defined. So, when
+ # building on x64 Windows with GCC, we define MS_WIN64 ourselves
+ # (http://bugs.python.org/issue4709). Python 3.12 and later define
+ # it as empty for MinGW too, so define it as empty as well here too.
+ #
+ # This can be removed when support for Python 3.12 and below is
+ # dropped.
case "$gdb_host" in
mingw64)
if test "${GCC}" = yes; then
- CPPFLAGS="$CPPFLAGS -DMS_WIN64"
+ CPPFLAGS="$CPPFLAGS -DMS_WIN64="
fi
;;
esac
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 0d88a280b163..3c526c9c108e 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1080,16 +1080,19 @@ if test "${have_libpython}" != no; then
# On x64 Windows, Python's include headers, and pyconfig.h in
# particular, rely on MS_WIN64 macro to detect that it's a 64bit
- # version of Windows. Unfortunately, MS_WIN64 is only defined if
- # _MSC_VER, a Microsoft-specific macro, is defined. So, when
- # building on x64 Windows with GCC, we define MS_WIN64 ourselves.
- # The issue was reported to the Python community, but still isn't
- # solved as of 2012-10-02 (http://bugs.python.org/issue4709).
+ # version of Windows. Before Python 3.12, MS_WIN64 is only defined
+ # if _MSC_VER, a Microsoft-specific macro, is defined. So, when
+ # building on x64 Windows with GCC, we define MS_WIN64 ourselves
+ # (http://bugs.python.org/issue4709). Python 3.12 and later define
+ # it as empty for MinGW too, so define it as empty as well here too.
+ #
+ # This can be removed when support for Python 3.12 and below is
+ # dropped.
case "$gdb_host" in
mingw64)
if test "${GCC}" = yes; then
- CPPFLAGS="$CPPFLAGS -DMS_WIN64"
+ CPPFLAGS="$CPPFLAGS -DMS_WIN64="
fi
;;
esac
base-commit: 80b91cb32b083868945f8da8fdeb2c20b5c9f099
--
2.56.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] gdb: fix MS_WIN64 redefinition error with Python >= 3.12 on MinGW
2026-10-13 14:08 [PATCH] gdb: fix MS_WIN64 redefinition error with Python >= 3.12 on MinGW Simon Marchi
@ 2026-10-14 11:57 ` Tom Tromey
2026-10-14 12:52 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2026-10-14 11:57 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> Actually, since CPython commit 158b8a07212c ("gh-79218: Define
Simon> `MS_WIN64` macro for Mingw-w64 64bit on Windows (GH-100137)",
Simon> 2022-12-12), which is in Python 3.12, pyconfig.h does define this macro
Simon> when building with MinGW. However, it defines it empty, whereas our
Simon> `-DMS_WIN64` defines it to 1, causing the macro redefinition error.
Simon> Change it to `-DMS_WIN64=`, which defines an empty macro, and avoids the
Simon> redefinition warning on Python >= 3.12. Older Python versions still get
Simon> the macro they need.
Seems reasonable to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] gdb: fix MS_WIN64 redefinition error with Python >= 3.12 on MinGW
2026-10-14 11:57 ` Tom Tromey
@ 2026-10-14 12:52 ` Simon Marchi
0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-10-14 12:52 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 10/14/26 7:57 AM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> Actually, since CPython commit 158b8a07212c ("gh-79218: Define
> Simon> `MS_WIN64` macro for Mingw-w64 64bit on Windows (GH-100137)",
> Simon> 2022-12-12), which is in Python 3.12, pyconfig.h does define this macro
> Simon> when building with MinGW. However, it defines it empty, whereas our
> Simon> `-DMS_WIN64` defines it to 1, causing the macro redefinition error.
> Simon> Change it to `-DMS_WIN64=`, which defines an empty macro, and avoids the
> Simon> redefinition warning on Python >= 3.12. Older Python versions still get
> Simon> the macro they need.
>
> Seems reasonable to me.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom
Thanks, pushed.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-14 12:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-13 14:08 [PATCH] gdb: fix MS_WIN64 redefinition error with Python >= 3.12 on MinGW Simon Marchi
2026-10-14 11:57 ` Tom Tromey
2026-10-14 12:52 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox