Fix statistics gathering destruction ordering
Prevents internal compiler errors caused by statistics gathering objects being destroyed in the wrong order.
This change addresses destruction ordering issues within GCC’s statistics gathering infrastructure. File-local static variables responsible for tracking data structure allocations could be destroyed before the structures they were monitoring, leading to internal compiler errors (ICEs). The fix ensures these statistics objects are never destroyed, as they are intended to persist for the entire process duration.
In Details
When --enable-gather-detailed-mem-stats is used, mem_alloc_description objects, which are file-local statics, can be referenced by the destructors of tracked GGC'd containers (e.g., hash maps, vectors). This leads to destruction order issues if mem_alloc_description is destroyed before a container that still needs to log its destruction. The fix makes mem_alloc_description a singleton that is never destroyed.
- ICE
- Internal Compiler Error. An unrecoverable error within the compiler itself, usually indicating a bug.
- GGC
- GNU Garbage Collector. GCC's internal memory management system for its own data structures.
- bootstrap
- The process of building a compiler using a previous version of itself. It's a way to ensure the compiler can be built from source without external dependencies.
- LTO
- Link-Time Optimization. An optimization technique where the compiler performs optimizations across multiple translation units during the linking stage.