-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
(abandoned) makefile: improve use of precompiled headers #42535
Conversation
CI doesn't seem to like the pre-existing flag |
I'm very excited to see what this does to build times! |
-Werror-no= doesn't seem to be working, if possible we'd prefer to suppress the warning within the source file itself, but if that is untennable for some reason, perhaps -Wno-uused-macros will work. I believe you need to pass -DCATCH_CONFIG_ALL_PARTS to the compilation process, otherwise it will suppress pch inclusion. i.e. the header that "would have been included" and the header as compiled into the pch must be identical. This may also break pch in comestibles_test.cpp again since we aren't setting CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER explicitly. Also see https://ccache.dev/manual/3.7.11.html#_precompiled_headers ccache needs special handling for precompiled headers, which you can see here: https://travis-ci.org/github/CleverRaven/Cataclysm-DDA/jobs/713045770
|
Might depend on compiler version, though I do agree that it's better to disable it with pragma diagnostics
This isn't necessary when the pch is included explicitly unless the macro changes the API or other odd stuff. Both gcc and clang complain if the pch isn't actually used due to
As far as I can tell, that macro only enables extra symbols and is covered by
I think I'm already covering that entire second bullet point in the link. Is the first one something I can do on my end? I'll look into it EDIT: looks like I already had that ccache config locally and I'm not seeing any hits for Also I just finished a benchmark on a different system with similar results as in the OP
|
By the way, that |
ccache does indeed work on my end with PCH=1. I reset the stats, then ran
no pch misses (the failures are from that friendly |
So is the next step to wrap all the system header inclusion blocks in #ifndef PCH? The ones in .cpp files anyway i.e.
Note if it is I don't want it in this PR, one step at a time. |
Nope, this is fully set up as it is and there are no further changes needed (at least for native compilation with gcc and clang). The |
There's no double inclusion, but we still pay the overhead of inlining all those headers, right? (we just skip compiling the contents) I'll do some tests and see if there's anything measurable once I have a little while to look at it. |
Ah ok, I get your point. The issue with that is you'll have to rebuild the pch every time you add a new (project-wide) include which necessarily triggers a full rebuild and might counteract any time savings. The alternative would be to teach people to add new includes outside of the |
Is this something that's going to happen more than once every few months? I think we're pretty nearly at saturation already.
We currently trigger nearly-full rebuilds pretty constantly anyway, CI builds in particular get hit really hard with this, but this way those full rebuilds are much faster. As for the ccache thing, I think you want |
I doubt it's doing anything in the code now since Edit: removed it and it still compiles on MinGW-w64. |
Thanks @Qrox. I'll leave it as it is in this PR since the |
So travis' old clang doesn't understand What do? |
Alright, I'm done. I've pushed another hack for clang+ccache that seems to work locally. Hacking Makefiles is extremely unfun and I'd rather be doing something else, so if this doesn't work for CI, I'm going to close the PR |
If you give up please leave it open for a bit and someone is going to take it up. Regardless thanks a ton for grinding away on this, it's going to have a really high impact. |
hopefully fix bizarre error in mac build
Sorry, I couldn't get it to work on travis (works for me™). Maybe smarter people can figure it out |
Well you got everything but the XCode build, I'm sure we can sort that out, thanks a ton. |
According to this
So maybe removing the indentations from the entire |
Nice! There's still this bizarre error that prevents clang build from using PCH:
Adding |
One of us can dive into resolving the remaining issues in another PR, I just want this one in the can! |
I hope it turns out to be useful. Thanks for merging it |
Actually I think it would've been succeed on Travis if not for a time limit. We'll see how it will work on Jenkins. |
Summary
SUMMARY: Build "Improve use of precompiled headers"
Purpose of change
(waste everyone's time with a pipe dream of) Speed-up build from Makefile
Don't pass
-DCATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
globallyDescribe the solution
Main target uses precompiled system headers
Test target uses precompiled catch2 with minor modifications as specified here
Supports both gcc and clang
Describe alternatives you've considered
Making a PR for my meson build definition instead (❤️ meson)
Testing
In progress
Compilation of ncurses targets with gcc and clang worked so far, with both RELEASE=1 and 0
Preliminary benchmark shows 10% improvement on my machine:
make PREFIX=/usr RELEASE=1 PCH=0 ASTYLE=0 LINTJSON=0 -j4
3087.03s user 137.14s system 363% cpu 14:46.61 totalmake PREFIX=/usr RELEASE=1 PCH=1 ASTYLE=0 LINTJSON=0 -j4
2779.49s user 122.96s system 376% cpu 12:50.86 totalAdditional context
I ported these changes straight from meson and didn't test too much yet with this Makefile
I've also included my hacky script for auto-generating
pch.hpp
(update-pch.sh
)src/translations.cpp
defines the__STRICT_ANSI__
macro, but that's an implementation detail of libstdc++ and has no business in the project's code and also causes an error with precompiled headers. To work around that, the makefile adds the flag-Wno-error=unused-macros
Makefile:414: *** commands commence before first target. Stop.
Makefile:415: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
I don't know why the mac build make fails to process an
undefine
instruction. This is not something people should waste time on./usr/bin/ld: cannot open output file obj/__bla__.o: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation) ()
Another great mystery. How does this clang fail to linkint main(){}
?!