Skip to content

Conversation

dementive
Copy link
Contributor

@dementive dementive commented Sep 13, 2025

Adds an option to use clang PCH to build a pch and then use it.

On my computer this makes clean build times go from 92 seconds without PCH to 11 seconds with PCH.

For me PCH isn't even really about clean build time though that is what Unity Builds are for. This also makes incremental builds in user code considerably faster as you can pre compile all the expensive bloated headers from godot-cpp and from your own code. I measured this by just changing a number in example.cpp, without PCH this takes about 10 seconds to recompile. With PCH that same change only takes 3 seconds.

The way this is implemented is definitely wrong though and i'll need some help/tips on how to get it to fit more idiomatically in with the godot-cpp build. I ripped this straight out of how I currently do it in my engine module build system. I'm not really sure what the best way to adapt it to fit properly into godot-cpp's build system is since PCH is very complicated but it probably has to be it's own Builder which I don't' really know how to do.

It's also very compiler specific, this only works for clang. I've tested GCC's PCH and it pretty much doesn't work at all in my experience. I guess msvc also has solid PCH that scons has a built in Builder for but I've never used it.

There are also some minor problems with my current implementation because I can't figure out a way to get godot-cpp to generate all the bindings files without actually doing a full compilation. There doesn't seem to be any option to do that and the binding gen is so tightly coupled with the build system it's hard to figure it out.

@dementive dementive requested a review from a team as a code owner September 13, 2025 16:07
@Calinou Calinou added the enhancement This is an enhancement on the current functionality label Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants