This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: On which platforms is -fvisibility supported?

Geoffrey Keating wrote:

> Jonathan Turkanis <> writes:

>> On which platforms is the -fvisibility option supported? The GCC docs >> here ( 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., and 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]