-
-
Notifications
You must be signed in to change notification settings - Fork 478
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
Support pre-compiled headers and interprocedural/link-time optimisation #2978
base: master
Are you sure you want to change the base?
Conversation
This speeds up builds by 50% to 66% on my machine.
Release builds are about 15% smaller. Runtime performance untested.
- `src/ports/emscripten.hpp` lacked an include guard. - MSVC probably defines `STRICT` as a macro.
- Moved Emscripten implementation from header to .cpp file - See if #undef MSVC-specific macro fixes MSVC builds - Filter out OpenGL headers on non-HAVE_OPENGL builds
- The MSVC bug from the parent commit wasn't a macro, apparently - Forgot to commit src/port/emscripten.cpp - Emscripten doesn't support LTO very well, disable it for now
I had to change a few more things in the code for the builds to pass. I changed it to the best of my abilities, but some involve design choices, so it might be good to review them. The diff will show all the changes, but I bumped the minimum CMake version from 3.1 to 3.9 to support policy CMP0069 (needs 3.6) and |
I tested this a couple days ago. Seems to be working fine. |
This sounds like enabling pre-compiled headers has only advantages and no disadvantage. |
@HybridDog It's something I've been thinking about, whether or not to enable them by default. They're not really relevant during development, only when making releases, which is IMO the preferred place for lesser-known non-default options to live. I haven't tried actively developing with those options enabled, but I would presume, especially with LTO, that it substantially slows down development compiling. I'm not sure how large the impact is, and active developers would be better placed to report their experience with that. |
If they are only relevant for release builds, maybe they can be enabled if and only if the build type is Release or RelWithDebInfo (-DRELEASE). |
PCH and IPO are now only enabled on Release|RelWithDebInfo builds. |
This adds CMake code to enable pre-compiled headers (PCH) and interprocedural optimisation (IPO, or LTO for link-time optimisation).
PCH
PCH makes builds 50% to 66% faster. A simple
time make -j$(nproc)
on my 12-core CPU shows:real
is the total time spent, from start to finish, as perceived by the developer.user
is the sum of the time spent by each thread, which gives a better idea of what would happen on a single-threaded system. DetailsIPO
IPO makes Release builds 15% smaller. I have not tested the runtime performance.
Notes
cmake_policy(SET CMP0069 NEW)
requires CMake >=3.9, but I did not updatecmake_minimum_required
to discuss whether or not to keep the policy.