[cfe-dev] add new option -fnovisibility for clang

digger lin via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 15 10:31:06 PDT 2020


Hi All,
 According to the response of the email, we decidle to change the option
name as -mignore-xcoff-visibility , and the option only work on the AIX OS,
for other no AIX OS, using the option will report an unsupport options
error as:

clang   -mignore-xcoff-visibility   -target powerpc-unknown-linux
 -emit-llvm  -S test.c
*clang-12: error: unsupported option '-mignore-xcoff-visibility' for target
'powerpc-unknown-linux*

in AIX OS
1.1  the option  -mignore-xcoff-visibility is enabled by default , if there
is not -fvisibility=* and  -mignore-xcoff-visibility explicitly in the
clang command .

*  clang * *-mignore-xcoff-visibility* *    -target powerpc-unknown-aix
 -emit-llvm  -S test.c*
 or
  *clang -target powerpc-unknown-aix  -emit-llvm  -S test.c * ( the -
mignore-xcoff-visibility  is *enabled* by default in AIX OS)

 Generate IR as :

  *@b = global i32 0, align 4*

1.2 if there is  -fvisibility=* explicitly but
not -mignore-xcoff-visibility  explicitly in the clang command.  it will
generate visibility attributes.

*clang ** -fvisibility=default   -target powerpc-unknown-aix   -emit-llvm
 -S test.c*

  Generate IR as :
  *@b = protected global i32 0, align 4*

1.3  if there are  both  -fvisibility=* and
-mignore-xcoff-visibility  explicitly in the clang command. The option
"-mignore-xcoff-visibility" wins , it ignores the visibility attribute.
* clang * *-mignore-xcoff-visibility* *  -fvisibility=default  -target
powerpc-unknown-aix  -emit-llvm  -S test.c*

 Generate IR as :

  *@b = global i32 0, align 4*

Thanks

Digger


On Fri, Sep 11, 2020 at 10:02 AM Jason Liu <jasonliu.development at gmail.com>
wrote:

> Hi James,
>
> I think the rationale is that by default, we want users to use an `export
> list` to manually control the symbol visibility on AIX instead of relying
> on the attribute in the code (which could cause unwanted effects as Hubert
> already described).
> Here's some description on how to use export list on AIX:
> https://developer.ibm.com/technologies/systems/articles/au-aix-symbol-visibility/#3-using-the-export-list
> Not sure if that answers your question.
>
> Thanks,
>
> Jason Liu
>
> On Thu, Sep 10, 2020 at 9:07 PM James Y Knight via cfe-dev <
> cfe-dev at lists.llvm.org> 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?
>>
>> Now, if someone was porting their project to AIX, it is reasonable to ask
>>> them to figure out the problem with their less-than-discriminate usage of
>>> visibility. For developers trying to use packages with such problems,
>>> they're rather less interested in fixing the projects that they're
>>> dependent on.
>>>
>>>
>>>>
>>>> On Thu, Sep 10, 2020 at 10:04 AM digger lin via cfe-dev <
>>>> cfe-dev at lists.llvm.org> wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>>   In IBM compiler Xlclang , there is option -fnovisibiilty. The option
>>>>> is description as
>>>>>
>>>>> https://www.ibm.com/support/knowledgecenter/SSGH3R_16.1.0/com.ibm.xlcpp161.aix.doc/compiler_ref/opt_visibility.html
>>>>>
>>>>>
>>>>>   we need to add the option -fnovisibiilty for clang in the IBM AIX
>>>>> OS(and the option is enabled by default in AIX OS).
>>>>>   I will implement the option in the other OS platform.(but the option
>>>>> is disabled by default in other OS).
>>>>>
>>>>>   For example, the file test.c
>>>>>
>>>>>  bash-4.2$ test.c
>>>>>  __attribute__((visibility ("protected"))) int b;
>>>>>
>>>>>  1 In AIX OS:
>>>>>
>>>>>  1.1 Compiled with
>>>>>
>>>>> *  clang -fnovisibility    -target powerpc-unknown-aix  -emit-llvm  -S
>>>>> test.c*
>>>>>  or
>>>>>   *clang -target powerpc-unknown-aix  -emit-llvm  -S test.c * ( the
>>>>> -fnovisibility is *enabled* by default in AIX OS)
>>>>>
>>>>>  Generate IR as :
>>>>>
>>>>>   *@b = global i32 0, align 4*
>>>>>
>>>>>  1.2 Compiled with
>>>>>   (If have "-fnovisibility  -fvisibility=*" at the same time.  the
>>>>> compile will ignore the -fnovisibility).
>>>>>
>>>>>   *clang -fnovisibility  -fvisibility=default   -target
>>>>> powerpc-unknown-aix   -emit-llvm  -S test.c*
>>>>>
>>>>> Or
>>>>>
>>>>>   *clang -fvisibility=default   -target powerpc-unknown-aix
>>>>> -emit-llvm  -S test.c*
>>>>>
>>>>>   Generate IR as :
>>>>>   *@b = protected global i32 0, align 4*
>>>>>
>>>>>  2. In Other OS(not AIX)
>>>>>    2.1* clang -fnovisibility    -target powerpc-unknown-linux
>>>>>  -emit-llvm  -S test.c*
>>>>>
>>>>>     Generate IR as :
>>>>>     *@b = global i32 0, align 4*
>>>>>
>>>>>   2.2
>>>>>    * clang -target powerpc-unknown-linux  -emit-llvm  -S test.c* (
>>>>> the -fnovisibility is *disabled *by default in not AIX OS)
>>>>>   Or
>>>>>     (if have "-fnovisibility  -fvisibility=*" at the same time.  the
>>>>> compile will ignore the -fnovisibility).
>>>>>     *clang -fnovisibility  -fvisibility=default   -target
>>>>> powerpc-unknown-linux   -emit-llvm  -S test.c*
>>>>>   Or
>>>>>     *clang -fvisibility=default   -target powerpc-unknown-linux
>>>>> -emit-llvm  -S test.c*
>>>>>
>>>>>    Generate IR as :
>>>>>     *@b = protected global i32 0, align 4 *
>>>>> _______________________________________________
>>>>> cfe-dev mailing list
>>>>> cfe-dev at lists.llvm.org
>>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>>
>>>> _______________________________________________
>>>> cfe-dev mailing list
>>>> cfe-dev at lists.llvm.org
>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>
>>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200915/94368e0e/attachment.html>


More information about the cfe-dev mailing list