From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UZPGCqE7zmpbLgIAWB0awg (envelope-from ) for ; Tue, 13 Oct 2026 10:09:37 -0400 Received: by simark.ca (Postfix, from userid 112) id 23D3D1E04E; Tue, 13 Oct 2026 10:09:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2B8AA1E04E for ; Tue, 13 Oct 2026 10:09:36 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABF0E4BA23E3 for ; Tue, 13 Oct 2026 14:09:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABF0E4BA23E3 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E64764BA2E04 for ; Tue, 13 Oct 2026 14:09:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E64764BA2E04 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E64764BA2E04 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791900550; cv=none; b=w5FnNlUXAe0XYWJWl6PQgRNyrPUE47ihQO4nHM2y22Xs6TbLs6uUA+qdSpCNyhvklrB7TavOfCO/YlDo74HwMd2l4xh5sDkfFjzxtj83bjn22e10XAU3JVp7eqxpUxHTdOaI0jpbffL0ClHWcDy76jPaViCw8+0an7d3PPjhMpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791900550; c=relaxed/simple; bh=pozzCosXA/fhfX7B0skrFSGQoO+Cb3jNGe1AfdmHpyE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=EhKzWbnBhxRW6fB6alILC+HwCxyXLvZbSxVYhnqCRfGsnWXk2XJFirjXMHumhnvIP6GwZFmbKy9RUobIPJQCfN9s/Ny17Xyt6PFt4LhX9UteWbfANtwQxXcLf5gLzbu9U0obPprAgIqnN0OXEWjqRe8nSGnz+vdpBTfxSvzBNQU= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E64764BA2E04 Received: by simark.ca (Postfix) id C1B441E04E; Tue, 13 Oct 2026 10:09:08 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: fix MS_WIN64 redefinition error with Python >= 3.12 on MinGW Date: Tue, 13 Oct 2026 10:08:56 -0400 Message-ID: <20261013140907.1346231-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 | ^~~~~~~~ : 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