[PATCH] D87451: add new clang option -fnovisibility.

Digger via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 06:39:39 PDT 2020


DiggerLin created this revision.
DiggerLin added reviewers: hubert.reinterpretcast, jasonliu, daltenty.
Herald added subscribers: cfe-commits, dang, steven.zhang.
Herald added a project: clang.
DiggerLin requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fnovisibility.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87451.290958.patch
Type: text/x-patch
Size: 7153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200910/d052b7d7/attachment.bin>


More information about the cfe-commits mailing list