Skip to content

Commit 328a6ec

Browse files
serge-sans-pailletstellar
serge-sans-paille
authored andcommitted
Force visibility of llvm::Any to external
llvm::Any::TypeId::Id relies on the uniqueness of the address of a static variable defined in a template function. hidden visibility implies vague linkage for that variable, which does not guarantee the uniqueness of the address across a binary and a shared library. This totally breaks the implementation of llvm::Any. Ideally, setting visibility to llvm::Any::TypeId::Id should be enough, unfortunately this doesn't work as expected and we lack time (before 12.0.1 release) to understand why setting the visibility to llvm::Any does work. See https://gcc.gnu.org/wiki/Visibility and https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html for more information on that topic. Differential Revision: https://reviews.llvm.org/D101972 (cherry picked from commit 3d3abc2)
1 parent 4973ce5 commit 328a6ec

File tree

1 file changed

+6
-1
lines changed
  • llvm/include/llvm/ADT

1 file changed

+6
-1
lines changed

llvm/include/llvm/ADT/Any.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323

2424
namespace llvm {
2525

26-
class Any {
26+
class LLVM_EXTERNAL_VISIBILITY Any {
27+
28+
// The `Typeid<T>::Id` static data member below is a globally unique
29+
// identifier for the type `T`. It is explicitly marked with default
30+
// visibility so that when `-fvisibility=hidden` is used, the loader still
31+
// merges duplicate definitions across DSO boundaries.
2732
template <typename T> struct TypeId { static const char Id; };
2833

2934
struct StorageBase {

0 commit comments

Comments
 (0)