On which platforms is -fvisibility supported?

Jonathan Turkanis technews@kangaroologic.com
Fri Sep 16 17:15:00 GMT 2005


Geoffrey Keating wrote:

 > Jonathan Turkanis <technews@kangaroologic.com> writes:


 >> On which platforms is the -fvisibility option supported? The GCC docs
 >> here (http://tinyurl.com/99wc8) suggest that it is a subset of ELF
 >> platforms. Is that correct?


 > I think I can give you an answer which is completely correct and yet
 > completely useless:  -fvisibility=default is supported on every platform.


Thank you -- it's not completely useless. I don't want to recommend that users 
supply -fvisibility=default if it will result in an 'unrecognized option' error 
on some platforms.

 > (What, that wasn't the flag you were planning to use?)


I sense a joke lurking here.

 > As Mike says,


 >> If you tell us what the real question is, maybe we can answer that one.


To me, that sounds like an insult: why do you think I wouldn't ask the "real" 
question? But I'll give you the benefit of the doubt and assume you mean 
something as yet unspecified.

The docs for -fvisibility say: "Set the default ELF image symbol visibility to 
the specified option —- all symbols will be marked with this unless overridden 
within the code...."

This seems consistent with option being recognized only on ELF platforms, with 
it being recognized everywhere but ignored on non-ELF platforms, with it being 
supported everywhere with analogous semantics to those described in terms of ELF 
visibility, or some mixture of the the these scenarios. To further cloud the 
issue, the docs refer to an article which seems to be refering only to ELF 
platforms, and the dos for the visibility attribute say that not all ELF targets 
support it.

So it seems a fair question to ask where -fvisibility is supported. An answer 
that isn't "completely useless" would be appreciated.

I'm trying to decide what recommendations to make with repect to -fvisibility 
for a forthcoming O'Reilly C++ book. At first it looked like a nice way to 
enable Windows-style exporting of symbols from dynamic libraries on some 
UNIX/Linux platforms. Now it appears that there may be some serious problems 
with it, at least as currently implemented. See e.g., 
http://article.gmane.org/gmane.comp.lib.boost.build/10072 and 
http://article.gmane.org/gmane.comp.lib.boost.build/10110. Those threads were 
also the first indication I had that -fvisibility was supported on some non-ELF 
platforms.

I don't have time to verify the assertions made in that thread -- the book went 
into production in August -- but I trust the author and he seems to have 
conducted some careful experiments. I'm now inclined just to say that the 
option, together with the attribute, offered the possibility of Windows-style 
exporting on some (unspecified) platforms, but that initial implementation is 
buggy; -fvisibility=default should be specified everywhere, until further notice.

-- 
Jonathan Turkanis
www.kangaroologic.com




More information about the Gcc mailing list