-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
What's the problem this feature will solve?
Since all 3 of the major compilers (MSVC), GCC, and clang all support creating and using Precompiled Headers which can help speed up building C extension modules, I would love it if the setuptools C extension builder class had a way for it to pass the proper command line options to create and use the precompiled headers for us without manually having to build the specific C source files manually in order to use the Precompiled Header feature for a build performance improvement for large C extensions.
Describe the solution you'd like
Expose a field that represents a file that will output a precompiled header for which this precompiled header would be consumed while building the C source files of a project (say for example pch.c or pch.h).
Alternative Solutions
Manually doing what setuptools does in finding the compiler to use and selecting the proper command line options to use (more painful than just using setuptools and exposing way to use precompiled headers).
Additional context
It's needed to improve compile performance in large multiple C file C extensions which all use a common header as the compiler would process the exact same header for the exact number of C source files. This results in a build performance penalty that could be avoided with allowing to specify in setuptools that a precompiled header should be made for that header the first time a C source file is compiled resulting in a faster compile on the other C source files.
https://clang.llvm.org/docs/UsersManual.html#precompiled-headers

in MSVC there is a different option for this as well.
https://learn.microsoft.com/en-us/cpp/build/reference/yc-create-precompiled-header-file?view=msvc-170
https://learn.microsoft.com/en-us/cpp/build/reference/yu-use-precompiled-header-file?view=msvc-170
As such, it would be nice if setuptools could expose this.
Code of Conduct
- I agree to follow the PSF Code of Conduct