[cfe-commits] r124633 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/visibility-hidden-extern-templates.cpp

John McCall rjmccall at apple.com
Mon Jan 31 21:06:47 PST 2011

On Jan 31, 2011, at 8:38 PM, Rafael Ávila de Espíndola wrote:

>>> // Set visibility for definitions. NamedDecl::LinkageInfo LV =
>>> D->getLinkageAndVisibility(); -  if (LV.visibilityExplicit() ||
>>> !GV->hasAvailableExternallyLinkage()) -
>>> GV->setVisibility(GetLLVMVisibility(LV.visibility())); +
>>> GV->setVisibility(GetLLVMVisibility(LV.visibility())); }
>> Following GCC's lead, we should only restrict the visibility of
>> external symbols (i.e. declarations and available_externally
>> definitions) if they have an explicit visibility attribute.  The idea
>> is to allow users to build with -fvisibility=hidden and
>> -fvisibility-inlines-hidden without needing to carefully tag all
>> external declarations with default visibility.  It leads to
>> sub-optimal code, but it's absolutely required for compatibility.
> That will create a case were one file will have a default visibility available_externally constant and another will have a hidden external one. This is OK, but we would have to update the linker to accept it.
> Is that (changing the linker) OK?

The LLVM linker absolutely needs to be able to handle merging a default-visibility declaration with a hidden-visibility definition by preserving the visibility of the definition.  That is the traditional linker behavior for this.


More information about the cfe-commits mailing list