LTO default behavior in GCC 12 for shared libraries versus static libraries
0 reputation · 05 Jul 2023, 21:14 UTC
Goal: Assess whether GCC 12 could enable link‑time optimization by default for static libraries when the -fuse-linker-plugin flag is present, similar to the behavior already applied to shared libraries.
Constraints: The documentation explicitly states that static libraries still require -flto to activate LTO, and the change to shared‑library defaults does not extend to static archives. Release notes leave the decision unresolved, and variations in target architecture or linker support may affect the safety of such a default.
Questions: Should GCC 12 extend the default LTO behavior to static libraries under -fuse-linker-plugin? What would be the impact on build times, binary size, and compatibility with existing build systems? Are there circumstances where enabling LTO by default for static libraries could lead to link‑time failures?