Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pablogsal merged 3 commits intopython:mainfrompablogsal:gh-91048-win
Apr 25, 2025

Conversation

pablogsal
Copy link
Member

@pablogsalpablogsal commentedApr 25, 2025
edited by bedevere-appbot
Loading

To avoid having the debug sections being optimised away by the compiler we useattribute((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.

…ucture on WindowsTo avoid having the debug sections being optimised away by the compilerwe use  __attribute__((used)) on gcc and clang but in Windows this isnot supported by the Microsoft compiler and there is no equivalent flag.Unfortunately Windows offers almost no alternative other than exportingthe symbol in the dynamic table or using it somehow.
@Fidget-Spinner
Copy link
Member

Sorry can't test this out right now, but doesdllexport not prevent it from being optimized away? Or are there other reasons we can't use it?

@pablogsal
Copy link
MemberAuthor

pablogsal commentedApr 25, 2025
edited
Loading

Sorry can't test this out right now, but doesdllexport not prevent it from being optimized away?

Check the commit message: we don't want to export the symbol in the dynamic table. This is basically the less intrusive option Windows offers.

@pablogsal
Copy link
MemberAuthor

Just for completeness, we also get an error if we try to add__declspec(dllexport) to the macro:

C:\Users\pablogsal\GitHub\cpython\Python\pylifecycle.c(113,1): error C2370: '_PyRuntime': redefinition; different storage class [C:\Users\pablogsal\GitHub\cpython\PCbuild\_freeze_module.vcxproj]

we could have it as an option only for shared modules but then we need to deal with this other error:

C:\Users\pablogsal\GitHub\cpython\PCbuild\win32\_freeze_module.exe : fatal error LNK1120: 1 unresolved externals [C:\Users\pablogsal\GitHub\cpython\PCbuild\_freeze_module.vcxproj]

@pablogsal
Copy link
MemberAuthor

I also tried doing this but doesn't work:

#if defined(MS_WINDOWS)#define _GENERATE_DEBUG_SECTION_WINDOWS(name)                       \   _Pragma("optimize(\"g\", off)")                                 \   _Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \   __declspec(allocate(Py_STRINGIFY(name)))                        \   _Pragma("optimize(\"g\", on)")#else#define _GENERATE_DEBUG_SECTION_WINDOWS(name)#endif

@pablogsalpablogsalenabled auto-merge (squash)April 25, 2025 17:18
@pablogsalpablogsal merged commita5e628b intopython:mainApr 25, 2025
41 checks passed
@pablogsalpablogsal deleted the gh-91048-win branchApril 25, 2025 17:43
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Then we'd even do not need the__attribute__((used)) any longer in theGENERATE_DEBUG_SECTION macros.
But it doesn't hurt either - so let's keep it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah I still prefer to keep it

chris-eibl reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@zoobazoobazooba left review comments

@chris-eiblchris-eiblchris-eibl left review comments

@Fidget-SpinnerFidget-SpinnerFidget-Spinner approved these changes

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303kumaraditya303 is a code owner

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@pablogsal@Fidget-Spinner@zooba@chris-eibl

[8]ページ先頭

©2009-2025 Movatter.jp