Clock IDs on Cygwin

While compiling CPython 3.13.7 on Cygwin I obtained the following error during the make step:

In file included from ./Include/internal/pycore_backoff.h:12, from ./Include/internal/pycore_code.h:12, from ./Include/internal/pycore_interp.h:16, from ./Include/internal/pycore_runtime.h:17, from ./Modules/timemodule.c:7: ./Modules/timemodule.c: In function ‘time_clockid_converter’: ./Include/pymacro.h:77:13: error: static assertion failed: "sizeof(clk_id) == sizeof(*p)" 77 | static_assert((cond), #cond); \ | ^~~~~~~~~~~~~ ./Modules/timemodule.c:203:5: note: in expansion of macro ‘Py_BUILD_ASSERT’ 203 | Py_BUILD_ASSERT(sizeof(clk_id) == sizeof(*p)); | ^~~~~~~~~~~~~~~ make: *** [Makefile:3543: Modules/timemodule.o] Error 1 

ChatGPT explained to me, that the assertion would be based on the assumption, that all POSIX-like platforms are expected to have clockid_t == int, where clk_id is of type clockid_t (“Clock IDs”), and p would be an int*. On Cygwin, this would be different, withclockid_t being long (32 bit or 64 bit, build-dependent). Furthermore, ChatGPT told me that, in essence, the difference would not matter much. ChatGPT proposed a “fix” in Modules/timemodule.c:

#if !defined(__CYGWIN__) Py_BUILD_ASSERT(sizeof(clk_id) == sizeof(*p)); #endif 

And indeed this resolves this build error.

I do not know if this is a real solution, though. Possibly it is against the notion of an assertion to ignore it in cases where it isn’t met, but I am not a Python core developer.

However, this problem prevents CPython 3.13.7 from compiling on Cygwin without the abovementioned ChatGPT proposition.

There are some more problems related to compiling Python 3.13.7 on Cygwin, but I’ll report on these separately, as I consider them to be a completely different matter.

Please don’t just ask ChatGPT, that has not provide any value either to yourself or to this discussion.

Because ChatGPT is just wrong.

If you actually read the surrounding code, the answer becomes obvious. And if you compare it with the main branch, you can see that this is even a bug that was fixed already, it just hasn’t been back-ported: `time_clockid_converter()` selects the wrong type for clockid_t on Cygwin. · Issue #134771 · python/cpython · GitHub