[PATCH] D101972: Force visibility of llvm::Any to external

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 27 02:42:48 PDT 2021


serge-sans-paille added a comment.

After weeks of painful quest, I now understand why this is not enough:

compiling the following:

  lass __attribute__((visibility("default"))) foo{};
  class __attribute__((visibility("hidden"))) bar{};
  
  template<class T>
  __attribute__((visibility("default"))) bool check() __attribute__((noinline)) {
    return true;
  }
  
  void pain(bool& x, bool& y) {
    x = check<foo>();
    y = check<bar>();
  }

with

  clang++ -shared -fPIC -o liba.so a.cpp -nostdlib

and inspecting the symbol table with

  nm liba.so -DC

yields

  0000000000201020 D __bss_start
  0000000000201020 D _edata
  0000000000201020 D _end
  0000000000000330 T pain(bool&, bool&)
  0000000000000360 W bool check<foo>()

interestingly, `check<bar>` is not listed, because a default linkage function parametrized by an hidden linkage class turns into an hidden linkage function (!). So a potential fix here would be to flag every `llvm::Any::TypeID` parameter class as default linkage (but we can't static assert on that, because we can't inspect such attributes). So the way forward really should be in the spirit of https://reviews.llvm.org/D108690


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101972/new/

https://reviews.llvm.org/D101972



More information about the llvm-commits mailing list