Repository navigation
BUILD: Make the -Wall -Wextra and /W4 warnings errors in the native builds - #279
Draft
jwrosewell wants to merge 3 commits into
Draft
jwrosewell wants to merge 3 commits into
jwrosewell wants to merge 3 commits into
Conversation
The Device Detection and IP Intelligence on-premise packages now build their native code with every warning on and treated as an error. - MSVC: /W4 /WX for the wrapper, the C++ and the C. The /wd list is gone. - GCC and Clang: -Wall -Wextra -Werror for the wrapper, the C++ and the C. The -Wno-* flags are gone. -Wunused-result comes after the flags Python was built with, which can turn it off. The SWIG interface files now ask SWIG not to turn off any warning in the wrapper, and use fast dispatch for overloads. Fast dispatch checks only the arguments that tell overloads apart, each in a scope of its own, so no local in the dispatch code hides another (C4456). On MSVC, SWIG's runtime helpers are static inline, so those a module does not call are not reported as removed (C4505). GCC and Clang already get SWIG's unused attribute. Both wrappers are regenerated from the interface files with SWIG 4.4.1, the version that made them.
In each on-premise package, MSVC gets /D_CRT_SECURE_NO_WARNINGS for the cxx C and C++ sources only, which still call C runtime functions MSVC marks as deprecated, and no longer for the SWIG wrapper. setup.py says to remove it once those calls are gone, and names the warnings that are on, those of -Wall -Wextra and /W4. The comment in hash_python.i and ipi_python.i lists the pragmas SWIG still writes in the wrapper and why none changes this build. The wrappers are unchanged. ci/native-warnings.Tests.ps1 reads both setup.py files and both wrappers, and fails if a warning is turned off, the level is lowered, -Werror or /WX is commented out, the wrapper gets the C runtime define, or a wrapper has a pragma the interface file does not list. A new test_overload_type_error.py in each package checks that a constructor call matching no overload raises a TypeError that names it.
The cxx submodule moves from 699a9789 to 98701d9c, the head of the 51degrees-cxx rc branch. Its C and C++ sources build with -Wall -Wextra -Werror and /W4 /WX and turn no warning off, so neither setup.py gives /D_CRT_SECURE_NO_WARNINGS to the cxx sources any more. The wrapper, the C++ and the C now get the same warning options. setuptools gives cl /W3, and with /W4 after it cl printed D9025 on every compile, which /WX does not make an error. On MSVC each setup.py now takes the /W<n> options setuptools gives out of the compiler's options before it builds the libraries and the extension, so /W4 is the only level. Other compilers are unchanged. ci/native-warnings.Tests.ps1 fails on a C runtime deprecation define in either setup.py, on /external:W0 and on a /w1<n> to /w4<n> option, and checks that both setup.py files remove the MSVC level for the libraries and the extension.
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The on-premise packages now build their native code with the warnings of
-Wall -Wextraand/W4on and treated as errors, on each compiler the release uses.What changes
device-detection/fiftyone_devicedetection_onpremise/setup.pyandip-intelligence/fiftyone_ipintelligence_onpremise/setup.py:/W4 /WX, and the/wd4127 /wd4456 /wd4701 /wd4703 /wd4706list is gone.-Wall -Wextra -Werror.-Wno-strict-prototypes,-Wno-unused-variable,-Wno-missing-braces,-Wno-strict-aliasing,-Wno-atomic-alignmentand the Python 3.8-Wno-deprecated-declarationsare gone.-Wunused-resultcomes after the flags Python was built with, which can turn it off.hash_python.iandipi_python.i:SWIG_MSC_UNSUPPRESS_4505,SWIG_NO_CRT_SECURE_NO_DEPRECATE,SWIG_NO_SCL_SECURE_NO_DEPRECATE). The interface file comment lists the pragmas SWIG still writes, which no SWIG setting removes, and why none of them changes this build.static inline, so those a module does not call are not reported (C4505). GCC and Clang already get SWIG's unused attribute.hash_python_wrap.cxxandipi_python_wrap.cxxare generated again from the interface files with SWIG 4.4.1, the version that made them. The Python proxy modules do not change.cxxsubmodule moves from 699a9789 to 98701d9c, the head of the 51degrees-cxx rc branch, which holds FIX: Build the C and C++ sources without compiler warnings 51degrees-cxx#214. Its C and C++ sources build with-Wall -Wextra -Werrorand/W4 /WXand turn no warning off./D_CRT_SECURE_NO_WARNINGSto anything. The wrapper, the C++ and the C get the same warning options./W<n>options setuptools gives cl out of the compiler's options before it builds the libraries and the extension, so/W4is the only level and cl gives no D9025. Other compilers are unchanged.ci/native-warnings.Tests.ps1checks both setup.py files and both wrappers for a warning turned off, a lower level, a commented out-Werroror/WX, a C runtime deprecation define anywhere in either setup.py,/external:W0, a/w1<n>to/w4<n>option, or a pragma the interface file does not list. It also checks that both setup.py files remove the MSVC level for the libraries and the extension.tests/test_overload_type_error.pyin each package checks theTypeErrorfor a constructor call that matches no overload.Tests
At 248f746, on Windows with MSVC 14.51 and Python 3.12:
/W4 /WX, but cl printed D9025 on every compile, as/W4overrode the/W3setuptools gives, and/WXdoes not make D9025 an error. The level change at this head is for that.fiftyone_devicedetection_onpremise: 119 passed, 2 skipped.fiftyone_ipintelligence_onpremise: 89 passed, 2 skipped. The skipped tests are the free-threaded ones, which skip on a build with the GIL.Before this leaves draft
Not ready to merge until these are done.
/W3on acl.exeline and nowarning Corwarning LNKline, and the Pull Requests workflow with the full matrix passes, macOS included.-Werrorand/WXapply to every source install of these packages, so a newer compiler with a new warning stops a customer's build, as the native builds of the other languages now do, or only to the builds 51Degrees runs.cxxsubmodule, so whichever merges second takes the other's pointer.