From Jason Turner
Watch on YouTube

Summary

This episode explores the significant benefits of using the -fvisibility=hidden compiler flag when creating shared libraries. Jason demonstrates how GCC's default behavior of exposing all symbols and enabling semantic interposition prevents effective function inlining, even with optimization flags. By using -fvisibility=hidden, only explicitly marked functions are exported from the shared library, leading to improved performance (around 6% in Jason's testing), smaller binary sizes, and fewer branches, as the compiler can more aggressively inline functions that don't need external visibility.

Resources

Tags