Reputation: 41
I am compiling ngspice. Its configure.ac adds -fvisibility=hidden to all compile steps, not only during generating the 'code models' that are shared libs.
Is there a risk if -fvisibility=hidden is added during compiling of the standard executable?
Upvotes: 3
Views: 1521
Reputation: 7973
For standard executables, it is normally not necessary to have any visible symbols, except main
. However, it seems compilers are smart enough to keep main
visible if you compile with -fvisibility=hidden
.
The exception is when your program is made to load plugin libraries at runtime using dlopen()
, and those plugins expect to be able to call functions in the main program. Your plugins will then not be able to find the required symbols.
Upvotes: 2
Reputation: 60107
No. It'll just slap an attribute on external symbols and that attribute will get ignored by the linker when it sees it's making an executable (unless you're using -rdynamic
/-Wl,--export-dynamic
). What might hurt performance, on the other hand, is compiling with -fpic/-fPIC
as that will slow your code down a bit. -fpic/-fPIC
is unnecessary for executables unless they're position-independent executables (PIE).
Upvotes: 0