@@ -17,31 +17,33 @@ extern "C" {
1717
1818// Macros to burn global values in custom sections so out-of-process 
1919// profilers can locate them easily. 
20- 
21- #define  GENERATE_DEBUG_SECTION (name , declaration ) \
22-     _GENERATE_DEBUG_SECTION_WINDOWS(name)         \
23-     _GENERATE_DEBUG_SECTION_APPLE(name)           \
24-     declaration                                   \
25-     _GENERATE_DEBUG_SECTION_LINUX(name)
20+ #define  GENERATE_DEBUG_SECTION (name , declaration )     \
21+    _GENERATE_DEBUG_SECTION_WINDOWS(name)            \
22+    _GENERATE_DEBUG_SECTION_APPLE(name)              \
23+    declaration                                      \
24+    _GENERATE_DEBUG_SECTION_LINUX(name)
2625
2726#if  defined(MS_WINDOWS )
2827#define  _GENERATE_DEBUG_SECTION_WINDOWS (name )                       \
29-     _Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
30-     __declspec(allocate(Py_STRINGIFY(name)))
28+    _Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
29+    __declspec(allocate(Py_STRINGIFY(name)))                        \
30+    __declspec(used)
3131#else 
3232#define  _GENERATE_DEBUG_SECTION_WINDOWS (name )
3333#endif 
3434
3535#if  defined(__APPLE__ )
3636#define  _GENERATE_DEBUG_SECTION_APPLE (name ) \
37-     __attribute__((section(SEG_DATA "," Py_STRINGIFY(name))))
37+    __attribute__((section(SEG_DATA "," Py_STRINGIFY(name))))      \
38+    __attribute__((used))
3839#else 
3940#define  _GENERATE_DEBUG_SECTION_APPLE (name )
4041#endif 
4142
4243#if  defined(__linux__ ) &&  (defined(__GNUC__ ) ||  defined(__clang__ ))
4344#define  _GENERATE_DEBUG_SECTION_LINUX (name ) \
44-     __attribute__((section("." Py_STRINGIFY(name))))
45+    __attribute__((section("." Py_STRINGIFY(name))))               \
46+    __attribute__((used))
4547#else 
4648#define  _GENERATE_DEBUG_SECTION_LINUX (name )
4749#endif 
0 commit comments