[cfe-dev] add new option -fnovisibility for clang
Hubert Tong via cfe-dev
cfe-dev at lists.llvm.org
Fri Sep 11 12:54:59 PDT 2020
On Fri, Sep 11, 2020 at 2:58 PM James Y Knight <jyknight at google.com> wrote:
> On Thu, Sep 10, 2020 at 10:30 PM Hubert Tong <
> hubert.reinterpretcast at gmail.com> wrote:
>
>> On Thu, Sep 10, 2020 at 9:07 PM James Y Knight <jyknight at google.com>
>> wrote:
>>
>>>
>>>
>>> On Thu, Sep 10, 2020, 6:57 PM Hubert Tong <
>>> hubert.reinterpretcast at gmail.com> wrote:
>>>
>>>> On Thu, Sep 10, 2020 at 6:30 PM James Y Knight via cfe-dev <
>>>> cfe-dev at lists.llvm.org> wrote:
>>>>
>>>>> But *why* does AIX want to ignore visibility restrictions encoded via
>>>>> attribute? Especially by default?
>>>>>
>>>> One reason is that AIX performs more early/less lazy symbol resolution
>>>> (even with runtime linking) than, say, Linux. So, if a project goes with an
>>>> export-by-default model (via attribute in some scope), they can cause
>>>> link-time errors from symbol references to undefined symbols from code that
>>>> would otherwise have been discarded as unreferenced by the linker. It seems
>>>> such code is not uncommon (and has the questionable effect of exporting
>>>> template instantiations based on "client provided" types that are not part
>>>> of the "library"/"utility" code in question).
>>>>
>>>
>>> But, the default visibility is "default" -- which is the most export-y
>>> visibility setting there is. So, without specifying visibility options on
>>> the command line, the only thing you can do with visibility attributes in
>>> code is to *remove *exports, not add additional ones.
>>>
>>> What am I missing?
>>>
>> That AIX is not an ELF platform. AIX has a default visibility for XCOFF
>> called "unspecified". This is because the ELF-based visibility options do
>> not quite match the base case on AIX. That the most export-y visibility is
>> named "default" at the source level is an ELF-ism.
>>
>
> But Clang doesn't have an "unspecified" visibility, only default,
> protected, and hidden. And this proposal doesn't propose to add one,
> either. So I don't see how this command-line option makes sense in Clang,
> right now.
>
It makes sense for Clang on AIX if it improves the consistency of behaviour
with other compilers on that platform. GCC on AIX does not support encoding
visibility into XCOFF and the default behaviour of the IBM
xlclang/xlclang++ compiler on AIX is to not encode visibility into XCOFF.
That there will be future complementary changes does not seem to be a
practical reason for leaving Clang gratuitously different on AIX from other
AIX compilers.
>
> Perhaps it would make sense if proposed as a component of a larger change
> to visibility handling in clang.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200911/09bca6ea/attachment.html>
More information about the cfe-dev
mailing list