diff options
| author | Martin Hořeňovský | 2026-09-03 20:16:55 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-09-03 20:22:37 +0200 |
| commit | de1330d036168492a04b649a1fa0593faece6f74 (patch) | |
| tree | 09fae90a513ef3ae05c2027279715276c8b3f910 /tools/ThirdPartyMain.cpp | |
| parent | 317ac1ed4c0bb6e6b91eafc817e05c488feffcb3 (diff) | |
| download | catch3-de1330d036168492a04b649a1fa0593faece6f74.tar.gz | |
Avoid bad compile time scaling of test registration with optimizations
GCC is especially bad, as it had quadratic scaling in the number of
registered test cases in a TU, but Clang also scaled superlinearly, and
this commit fixes both.
AIUI:
1) Each `TEST_CASE` creates a separate global fragment to handle creating
the `unique_ptr<ITestInvoker>`, moving the instance into AutoReg,
destroying the old instance, etc, etc.
2) With optimizations enabled, the compiler merges all these global
fragments into one big global fragment.
3) Then the compiler runs various optimizations passes on this new global
fragment.
4) Because some of the passes scale superlinearly, the compilation times
scale superlinearly in the number of `TEST_CASE` in a translation unit.
For bonus point, no optimization actually happens.
This commit fixes the problem (for non-LTO builds) by adding new `AutoReg`
constructor, one that takes the function pointer raw, instead of wrapped
in `ITestInvoker`. By delaying the construction of the `ITestInvoker`
into the outlined constructor, we no longer create big global fragments
for the compiler to optimize.
Diffstat (limited to 'tools/ThirdPartyMain.cpp')
0 files changed, 0 insertions, 0 deletions