gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows (#132963)

To avoid having the debug sections being optimised away by the compiler
we use  __attribute__((used)) on gcc and clang but in Windows this is
not supported by the Microsoft compiler and there is no equivalent flag.
Unfortunately Windows offers almost no alternative other than exporting
the symbol in the dynamic table or using it somehow.
This commit is contained in:
Pablo Galindo Salgado 2025-04-25 18:43:32 +01:00 committed by GitHub
parent a1f4a6b246
commit a5e628beb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -185,6 +185,10 @@ typedef struct {
/* Counter for autogenerated Task names */
uint64_t task_name_counter;
/* Pointer to the asyncio debug offset to avoid it to be optimized away
by the compiler */
void *debug_offsets;
} asyncio_state;
static inline asyncio_state *
@ -4320,6 +4324,8 @@ module_init(asyncio_state *state)
goto fail;
}
state->debug_offsets = &_AsyncioDebug;
Py_DECREF(module);
return 0;