The Power and Pain of Hidden Symbols in C++ Programming
summary
Claim: making symbols -fvisibility=hidden by default and exporting only the intended API, then enabling link-time optimization, shrinks and speeds real C++ shared libraries. Tools and tactics: use the GNU visibility attribute (or a small CMake-generated export macro), check with Compiler Explorer, and run LTO/PGO. Concrete result: EnergyPlus builds drop ~6% size and gain ~3% from hidden alone, and combined hidden+LTO yields roughly 14% smaller binary and ~10% faster in the presented case. Pain points: must export dependent types, handle tests, and fix ODR/LTO issues.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 5:44Shared libraries and API
- 9:19Symbol inlining and optimization
- 14:26Semantic interposition and visibility
- 20:04Static, inline, and anonymous rules
- 23:18Inline namespaces for ABI
- 27:32Cross-platform exports
- 31:05Hidden symbols: power and pain
- 36:06Link time vs traditional compilation
- 40:04Energy Plus case study
- 48:06Position independent executables
- 49:29ODR violations and LTO
- 51:58Constexpr data and LTO tricks
- 57:12Summary and CMake guide
related talks
01h 00mLinkers, Loaders and Shared Libraries in Windows, Linux, and C++
01h 02mDeep CMake for Library Authors
26mC++ Modules Myth Busting
01h 44mImproving C++ Compilation Times: Tools & Techniques
52mNon-conforming C++: the Secrets the Committee Is Hiding From You
24m(Ab)using Compiler Tools
01h 29mWhat Does It Take to Implement the C++ Standard Library?
01h 30mDangerous Optimizations in C and C++ Programming Languages
