-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Shared precompiled header #4350
Comments
That is not supported ATM. The problem is that if any compiler flag changes, the PCH file is no longer guaranteed to be valid. |
Also, this will be backend dependent. I don't think you can easily re-use a precompiled header across multiple VS projects in a solution, but I'll gladly review a PR implementing this. |
pch as a build target can be valuable since for compilers like clang that support chained pch, meson is better to support something like: clang++ -x c++-header header1.h -o header1.h.pch
clang++ -x c++-header header2.h -o header2.h.pch -include-pch header1.h.pch Where header2.h includes header1.h . True that pch outputs are sensitive to compiler flags. When having pch as a build target, it should be very easy for meson to figure this out as configuration error - so this should not be an issue with meson design. |
This affects us in Lix, since we have a lot of libraries and we have little reason to not simply use the same PCH across all our libraries. It looks like we would save about 40 cpu-seconds by this being fixed, which is about 5% of our current build time. We could get more build-time savings by doing any other optimization, so this is not a huge priority for us but it would be nice. |
Probably it would be possible in the backend to take a list of all pch files and figure out which ones are called with the same flags, then merge rules. Anyone want to look into implementing this? |
@eli-schwartz Recent experiments in one of my projects (which involves many plugins which are separate .so files, but have the exact same flags for compilation) show that this could save up to 20% of compile-times so I am interested in looking into this, I have some experience with Python but unfortunately never looked into meson's codebase. Do you have some hints as to what has to happen broadly / which parts of the code I should look and hook into for this to be made possible? |
I have C++ project organized as few libraries. All of them use the same precompiled header. Currently meson precompiles this header for each invocation of library() call. Is there any way to precompile this header only once, and after that just share it among all library() calls?
The text was updated successfully, but these errors were encountered: