Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiling python_uwp.cpp with clang-cl on Windows #131291

Closed
chris-eibl opened this issue Mar 15, 2025 · 5 comments
Closed

Fix compiling python_uwp.cpp with clang-cl on Windows #131291

chris-eibl opened this issue Mar 15, 2025 · 5 comments
Labels
build The build process and cross-build OS-windows type-bug An unexpected behavior, bug, or error

Comments

@chris-eibl
Copy link
Contributor

chris-eibl commented Mar 15, 2025

clang-cl fails with the following error when compiling python_uwp.cpp:

1>In file included from ..\PC\python_uwp.cpp:14:
1>In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt\winrt\Windows.ApplicationModel.h:9:
1>In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt\winrt/base.h:56:
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\experimental/coroutine(29,2): error : The <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> headers do not support Clang, but the C++20 <coroutine> header does.

Let's fix it using

#if defined(__clang__)
#define _SILENCE_CLANG_COROUTINE_MESSAGE
#endif

before including the respective header.

This only happens when IncludeUwp is set in case of building with build.bat or in the Visual Studio IDE, because there always all projects are built.

Linked PRs

@encukou
Copy link
Member

encukou commented Mar 17, 2025

Will this result in a working “uwp” build?
Could IncludeUwp be unset on clang instead? (That's a naive question, I don't know much about how PCbuild works.)

Could you add a source comment about why this is needed, perhaps with a link to docs about _SILENCE_CLANG_COROUTINE_MESSAGE?

@encukou encukou added the build The build process and cross-build label Mar 17, 2025
@picnixz picnixz added type-bug An unexpected behavior, bug, or error OS-windows labels Mar 17, 2025
@chris-eibl
Copy link
Contributor Author

Will this result in a working “uwp” build?

Yes. At least a quick test I did is working: enable developer mode so that local UWP apps can be run. Starting the app then gives me

Python 3.14.0a6+ (heads/fix_clangcl_sysmodule-dirty:0eea635960, Mar 17 2025, 08:32:10) [Clang 19.1.1 ] 64 bit (AMD64) with MSC v.1943 CRT] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Could IncludeUwp be unset on clang instead? (That's a naive question, I don't know much about how PCbuild works.)

You already have to opt-in by setting it when doing a "regular" build.bat. Only in the Visual Studio IDE it is compiled by default.

In the latter, you could opt-out via deselecting it in the Configuration Manager.

Could you add a source comment about why this is needed, perhaps with a link to docs about _SILENCE_CLANG_COROUTINE_MESSAGE?

This comes directly out of the MSVC STL header: https://github.com/microsoft/STL/pull/136/files.
python_uwp.cpp doesn't need it, so it's safe to deactivate it. Would you like me to put that link as a comment above the define in the PR?

@zooba
Copy link
Member

zooba commented Mar 17, 2025

I would probably tend towards disabling IncludeUwp on Clang, or just ignoring the warning. Whichever way PEP 773 goes, I'm hopeful that this entire project will go away soon enough.

@zooba
Copy link
Member

zooba commented Mar 17, 2025

Or the PR was already there I guess, so easy enough to just merge it.

@zooba zooba closed this as completed Mar 17, 2025
@chris-eibl
Copy link
Contributor Author

Thanks for merging. This one wasn't a warning but an error. Sorry for not being explicit here.
Too much scrolling would have been needed to see it in the issue, so I am reformatting that part here:

1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\experimental/coroutine(29,2):
error : The <experimental/coroutine>, <experimental/generator>, and
<experimental/resumable> headers do not support Clang, but the C++20 <coroutine> header does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants