The compiler warning tracking tooling is intended to alert developers about newcompiler warnings introduced by their contributions. The tooling consists ofa Python script which is ran by the following GitHub workflows:
Ubuntu/build and test (.github/workflows/reusable-ubuntu.yml)
macOS/build and test (.github/workflows/reusable-macos.yml)
You can check the documentation for theTools/build/check_warnings.py toolby running:
pythonTools/build/check_warnings.py--help
The script can be run locally by providing the compiler output file(where the output is saved) and the compiler output type(eithergcc orclang) to see a list of unique warnings:
pythonTools/build/check_warnings.py--compiler-output-file-path=compiler_output.txt--compiler-output-type=gcc
TheTools/build/check_warnings.py tool will fail if the compiler generatesmore or less warnings than expected for a given source file as defined in theplatform-specific warning ignore file. The warning ignore file is eitherTools/build/.warningignore_ubuntu orTools/build/.warningignore_macos depending on the platform.
If a warning check fails with:
Unexpected warnings
Attempt to refactor the code to avoid the warning.
If it is not possible to avoid the warning document in the PR why it isreasonable to ignore and add the warning to the platform-specificwarning ignore file. If the file exists in the warning ignore fileincrement the count by the number of newly introduced warnings.
Unexpected improvements (less warnings)
Document in the PR that the change reduces the number of compilerwarnings. Decrement the count in the platform-specific warningignore file or remove the file if the count is now zero.
The warning ignore files can be found in theTools/build/ directory.Both files and directories can be added to the ignore file. Files can have an explicit warning count or a wildcard count.Directories must be followed by a wildcard count. Wildcards indicate that 0 or more warnings will be ignored.The following is an example of the warning ignore file format:
Modules/_ctypes/_ctypes_test_generated.c.h*Objects/longobject.c46Objects/methodobject.c1Objects/mimalloc/*
Using wildcards is reserved for code that is not maintained by CPython, or code that is for tests.Keep lines in warning ignore files sorted lexicographically.