-fvisibility=hidden not passed by compiler for Deb

2019-07-09 03:52发布

问题:

I am building a project in which I have enabled GCC_INLINES_ARE_PRIVATE_EXTERN and GCC_SYMBOLS_PRIVATE_EXTERN because I am consuming static libraries that were pre-built with those flags on.

However, when I build my project for Debug -fvisibility=hidden is not included in the compiler flags, but it does get included when I build my project for Release.

Is there any other flag that I need to turn on to make this happen?

回答1:

This is old, but it it seems the conflict comes from the Enable Testability setting. If you turn that off, then -fvisibility=hidden will work properly. It seems that Enable Testability has higher precedence over GCC_SYMBOLS_PRIVATE_EXTERN.

If you need that setting, you can always modify the settings on a configuration basis and mix and match (ie. Enable Testability is on and OTHER_CFLAGS containing -fvisibility=hidden)



回答2:

Seems like an Xcode bug. I didn’t find any other solution that setting OTHER_CFLAGS explicitly (in debug build only, on the same level GCC_INLINES_ARE_PRIVATE_EXTERN is set) to override it:

OTHER_CFLAGS = "-fvisibility=hidden";