[edit:] After experimenting, I recommend the following:
-param=max-vartrack-size=1500000
Which seems to be surprisingly problem-free, and actually seems to improve my build times.
[...end of edit]
The Variable Tracking Assignments feature is used to track use of variables in inlined code. The information is used by debuggers and tools (notably, gdb and Visual Studio Code). If you exceed the cache size, your debugger and tools may not be able to display variable values in inlined code.
[edit: optimizers also use it]
You can increase the size of the variable tracking cache using the following GCC option:
--param=max-vartrack-size=n
The default is 10000, so the following might be a good starting point:
--param=max-vartrack-size=200000
[edit:] Variable Tracking Assignments are also used by optimizers. So maybe better to bump the limit than to indiscriminately disable Variable Tracking.
For some reason, the project I'm currently working on uses a coding style that aggravates this problem. I only get the warnings with RelWithDebInfo builds. Initially, I had a bout a dozen files that had the problem. Debug and release builds are both fine.
-param=max-vartrack-size=400000
has been part of my standard build scripts for some time; but it wasn't enough for this project. In the end I settled on
-param=max-vartrack-size=1500000
which not only cured the problem, but also improved my build time by ~33%. As far as I can see, there are no problems at all with memory usage. Total memory usage for the build (76 files, 4 concurrent ninja build threads) isn't much more the 1- or 200 megabytes. There's only a modest bump in memory usage during the build. Whatever problem this feature is trying to solve, doesn't actually seem to be a problem, or perhaps it is a problem that's dwarfed by modern IDEs that use 4GB of memory at any given time. (Or modern browsers that use 6GB of memory to read online Linux man pages).
In previous projects I've run into the problem in code that was initialising medium-sized static tables (hundreds-ish entries). In this project, I'm pretty sure the following coding style has something to do with GCC blowing up:
auto main = CairoFlexGridElement::Create();
main->Style()
.FlexAlignItems(CairoAlignment::Start)
.FlexDirection(CairoFlexDirection::Row)
.FlexWrap(CairoFlexWrap::Wrap)
.FlexColumnGap(16)
.Background(theme->paper)
.Padding({24, 16, 24, 16}) //<-- maybe this?!
.VerticalAlignment(CairoAlignment::Stretch)
.HorizontalAlignment(CairoAlignment::Stretch);
There's something about that coding style that cause problems with variable tracking, even though there's hardly a variable in sight. All the methods are non-template, and not inlined. Could be brace initializers. Or maybe it's GCC 10.4. Hard to say.
But in the end it's nothing that meeelions of cache entries and a couple of hundred megabytes or RAM can't take care of.