3

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?

Holger
  • 41
  • 3

2 Answers2

2

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.

yugr
  • 19,769
  • 3
  • 51
  • 96
G. Sliepen
  • 7,637
  • 1
  • 15
  • 31
1

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).

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142