Title: _tracemalloc.c and Clang-cl
Type: compile error Stage:
Components: Build Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gvanem
Priority: normal Keywords:

Created on 2020-10-19 07:03 by gvanem, last changed 2020-10-19 07:03 by gvanem.

Messages (1)
msg378928 - (view) Author: Gisle Vanem (gvanem) Date: 2020-10-19 07:03
Related to:

where I commented above the following. 
When using `clang-cl` to build, I get the following error:
Modules/_tracemalloc.c(55,9): error: declaration of anonymous struct must be a definition
typedef struct
Modules/_tracemalloc.c(55,1): warning: typedef requires a name [-Wmissing-declarations]
typedef struct
Modules/_tracemalloc.c(68,9): warning: #pragma pack(pop, ...) failed: stack empty [-Wignored-pragmas]
#pragma pack(pop)
Modules/_tracemalloc.c(78,5): error: unknown type name 'frame_t'
    frame_t frames[1];
Modules/_tracemalloc.c(87,103): error: use of undeclared identifier 'frame_t'
static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1));
Modules/_tracemalloc.c(87,103): error: use of undeclared identifier 'frame_t'
Modules/_tracemalloc.c(286,15): error: unknown type name 'frame_t'; did you mean 'trace_t'?
        const frame_t *frame1 = &traceback1->frames[i];
Modules/_tracemalloc.c(100,3): note: 'trace_t' declared here
} trace_t;

An easy fix is to patch it:
--- a/_tracemalloc.c 2020-10-18 12:06:55
+++ b/_tracemalloc.c 2020-10-19 09:02:17
@@ -52,11 +52,11 @@

 /* Pack the frame_t structure to reduce the memory footprint on 64-bit
    architectures: 12 bytes instead of 16. */
-typedef struct
 #ifdef __GNUC__
+typedef struct __attribute__((packed))
 #elif defined(_MSC_VER)
 #pragma pack(push, 4)
+typedef struct
     /* filename cannot be NULL: "<unknown>" is used if the Python frame

(I'm amazed it's not done before).
Date User Action Args
2020-10-19 07:03:42gvanemcreate