Files
MINGW-packages/mingw-w64-python/0073-configure-define-_DEBUG-for-a-debug-build.patch
2026-01-07 22:17:09 +01:00

62 lines
2.0 KiB
Diff

From e3d22cd2d009ff684c1f59bdd80ac2ec7b64fa84 Mon Sep 17 00:00:00 2001
From: Alexey Pavlov <alexpux@gmail.com>
Date: Fri, 29 Aug 2025 08:50:31 +0300
Subject: [PATCH 073/N] configure: define _DEBUG for a debug build
The Windows code expects it in some places for a debug build
Skip some things which fail to link with _DEBUG
---
Modules/_winapi.c | 2 +-
PC/clinic/msvcrtmodule.c.h | 4 ++--
configure.ac | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 3c2eb81..8d29c46 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -1491,7 +1491,7 @@ static PyObject *
_winapi_ExitProcess_impl(PyObject *module, UINT ExitCode)
/*[clinic end generated code: output=a387deb651175301 input=4f05466a9406c558]*/
{
- #if defined(Py_DEBUG)
+ #if defined(Py_DEBUG) && defined(_MSC_VER)
#ifdef MS_WINDOWS_DESKTOP
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|
SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX);
diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h
index e3f7ea4..f425fb1 100644
--- a/PC/clinic/msvcrtmodule.c.h
+++ b/PC/clinic/msvcrtmodule.c.h
@@ -483,7 +483,7 @@ exit:
#endif /* defined(MS_WINDOWS_DESKTOP) */
-#if defined(_DEBUG)
+#if defined(_DEBUG) && defined(_MSC_VER)
PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__,
"CrtSetReportFile($module, type, file, /)\n"
@@ -530,7 +530,7 @@ exit:
#endif /* defined(_DEBUG) */
-#if defined(_DEBUG)
+#if defined(_DEBUG) && defined(_MSC_VER)
PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__,
"CrtSetReportMode($module, type, mode, /)\n"
diff --git a/configure.ac b/configure.ac
index b6ea5de..0e4a937 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2469,6 +2469,7 @@ _RESTORE_VAR([CFLAGS])
PYDEBUG_CFLAGS="-O0"
AS_VAR_IF([ac_cv_cc_supports_og], [yes],
[PYDEBUG_CFLAGS="-Og"])
+PYDEBUG_CFLAGS="-D_DEBUG $PYDEBUG_CFLAGS"
# tweak OPT based on compiler and platform, only if the user didn't set
# it on the command line