Skip to content

clang-cl issues many warnings when building on Windows #131296

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

Open
chris-eibl opened this issue Mar 15, 2025 · 8 comments
Open

clang-cl issues many warnings when building on Windows #131296

chris-eibl opened this issue Mar 15, 2025 · 8 comments
Labels
build The build process and cross-build OS-windows type-feature A feature request or enhancement

Comments

@chris-eibl
Copy link
Member

chris-eibl commented Mar 15, 2025

See e.g. https://github.com/python/cpython/actions/runs/13681800146/job/38255779088.

I went through roughly 100 warnings to find this one #131020.

Others are mostly benign, yet I'd like to reduce them.

Since many of the warnings stem from pythoncore, we see them twice, because the _freeze_module compiles a lot of those *.c files, too - and in case of PGO we see them a third time in the PGUpdate phase.

E.g. a bunch of warnings will disappear after the next sync with hacl-star upstream, since @msprotz thankfully already merged hacl-star/hacl-star#1028.

I think it is best to do them in small PRs per *.c file.

Ideally, I'd like to end up with the same warning configuration as used on Linux. When I configure for clang in WSL, I get

CONFIGURE_CFLAGS_NODIST= -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden

This would currently generate even more warnings, since we currently use

<AdditionalOptions>-Wno-deprecated-non-prototype -Wno-unused-label -Wno-pointer-sign -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-function %(AdditionalOptions)</AdditionalOptions>

So maybe I should do this after a first round of cleaning?

Linked PRs

gpshead pushed a commit that referenced this issue Mar 15, 2025
work around unimportant clang-cl warnings in blake2module.c
@picnixz picnixz added type-feature A feature request or enhancement OS-windows build The build process and cross-build labels Mar 15, 2025
@picnixz
Copy link
Member

picnixz commented Mar 15, 2025

Let's not backport those because I suspect it will sometimes be hard (hence the "feature")

gpshead pushed a commit that referenced this issue Mar 15, 2025
fix warning : integer literal is too large

to be represented in a signed integer type,
interpreting as unsigned [-Wimplicitly-unsigned-literal]
@chris-eibl
Copy link
Member Author

Oh sure, no backport - I'd consider this a (minor) feature, anyway. Are warnings generally treated as bug issues here?

@gpshead
Copy link
Member

gpshead commented Mar 15, 2025

thanks! all three of those should merge. actually looking at compiler warnings and minimizing them is a good thing...

we do have some CI tests that check for changes in number of warnings on other platforms, if we get clang-cl in CI, even non-blocking, we should add the same for it. ex the "Check compiler warnings" ones in .github/workflows/reusable-{macos,ubuntu}.yml.

I do consider uninvestigated warnings to be bugs. But when it isn't a https://peps.python.org/pep-0011/ tier platform arguing for it can be hard. I think clang-cl is close enough even if not on a tier yet as we obviously already care about clang warnings on other platforms that its value is demonstrable.

@gpshead gpshead closed this as completed Mar 15, 2025
gpshead pushed a commit that referenced this issue Mar 15, 2025
@chris-eibl
Copy link
Member Author

Yupp. I fully agree. My main motivation is, that clang-cl "sees all the Windows code" for which MSVC with the currently selected warning level produces no warnings. Some are really easy to fix, and will no longer cover the "real" ones like #131020.

@chris-eibl
Copy link
Member Author

chris-eibl commented Mar 15, 2025

Ups, did you close the issue on purpose? Still a lot of warnings to go ... I am not that fast in creating the PRs :)

@chris-eibl
Copy link
Member Author

I've created three more PRs. Still more than 40 warnings to go ...

@picnixz picnixz reopened this Mar 15, 2025
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
…ython#131299)

work around unimportant clang-cl warnings in blake2module.c
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
…H-131297)

fix warning : integer literal is too large

to be represented in a signed integer type,
interpreting as unsigned [-Wimplicitly-unsigned-literal]
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
vstinner added a commit to vstinner/cpython that referenced this issue Mar 20, 2025
Change MAX_NFRAME type from 'unsigned long' to size_t. On Windows
64-bit, 'unsigned long' is only 32-bit, whereas size_t is 64-bit.
vstinner added a commit to vstinner/cpython that referenced this issue Mar 20, 2025
Always set MAX_NFRAME to UINT16_MAX.

Avoid the complicated code which emitted a compiler warning.
@vstinner
Copy link
Member

Sorry, I wasn't aware of this issue when I wrote #131487. I just noticed some warnings on a CI on one of my PR and I wanted to reduce the number of warnings to help me to distinguish if the warnings were introduced by my change or not.

zooba pushed a commit that referenced this issue Mar 31, 2025
Also removes warnings suppression for MSVC that no longer need to be suppressed.
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
…ython#131299)

work around unimportant clang-cl warnings in blake2module.c
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
…H-131297)

fix warning : integer literal is too large

to be represented in a signed integer type,
interpreting as unsigned [-Wimplicitly-unsigned-literal]
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
Always set MAX_NFRAME to UINT16_MAX.

Avoid the complicated code which emitted a compiler warning.
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
…-131897)

Also removes warnings suppression for MSVC that no longer need to be suppressed.
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
picnixz pushed a commit that referenced this issue Apr 18, 2025
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-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants