[llvm] 2c42a73 - Add extra check for llvm::Any::TypeId visibility

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 14 23:33:13 PDT 2021


Author: serge-sans-paille
Date: 2021-09-15T08:32:55+02:00
New Revision: 2c42a73d6c39af3833e697c0b306cb8cf8de5143

URL: https://github.com/llvm/llvm-project/commit/2c42a73d6c39af3833e697c0b306cb8cf8de5143
DIFF: https://github.com/llvm/llvm-project/commit/2c42a73d6c39af3833e697c0b306cb8cf8de5143.diff

LOG: Add extra check for llvm::Any::TypeId visibility

This check should ensure we don't reproduce the problem fixed by
02df443d2801601a4e42e360e436d97314e9da30

More accurately, it checks every llvm::Any::TypeId symbol in libLLVM-x.so and
make sure they have weak linkage and are not local to the library, which would
lead to duplicate definition if another weak version of the symbol is defined in
another linked library.

Differential Revision: https://reviews.llvm.org/D109252

Added: 
    llvm/test/tools/llvm-shlib/typeids.test

Modified: 
    llvm/test/lit.cfg.py
    llvm/test/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 6378cfcd3c18..6772066eacd2 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -240,6 +240,14 @@ def get_asan_rtlib():
 if not config.build_shared_libs and not config.link_llvm_dylib:
     config.available_features.add('static-libs')
 
+if config.link_llvm_dylib:
+    config.available_features.add('llvm-dylib')
+    config.substitutions.append(
+        ('%llvmdylib',
+         '{}/libLLVM-{}{}'.format(config.llvm_shlib_dir,
+                                  config.llvm_dylib_version,
+                                  config.llvm_shlib_ext)))
+
 if config.have_tf_aot:
     config.available_features.add("have_tf_aot")
 

diff  --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index fd39e78e91a5..f33069555d2a 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -45,6 +45,7 @@ config.build_examples = @LLVM_BUILD_EXAMPLES@
 config.enable_threads = @LLVM_ENABLE_THREADS@
 config.build_shared_libs = @BUILD_SHARED_LIBS@
 config.link_llvm_dylib = @LLVM_LINK_LLVM_DYLIB@
+config.llvm_dylib_version = "@LLVM_VERSION_MAJOR@@LLVM_VERSION_SUFFIX@"
 config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
 config.host_arch = "@HOST_ARCH@"
 config.have_opt_viewer_modules = @LLVM_HAVE_OPT_VIEWER_MODULES@

diff  --git a/llvm/test/tools/llvm-shlib/typeids.test b/llvm/test/tools/llvm-shlib/typeids.test
new file mode 100644
index 000000000000..158abc8407de
--- /dev/null
+++ b/llvm/test/tools/llvm-shlib/typeids.test
@@ -0,0 +1,14 @@
+# REQUIRES: x86_64-linux, llvm-dylib
+
+# Make sure there's no llvm::Any::TypeId symbol local to the shared library.  As
+# the adress of llvm::Any::TypeId::Id is used as a global unique identifier for
+# each type, having another visibility defeats the original purpose.
+#
+# This happens when llvm::Any::TypeId is parametrized by a type with hidden
+# visibility.
+
+# RUN: llvm-nm -C %llvmdylib | FileCheck %s
+# RUN: llvm-nm -C %llvmdylib | FileCheck %s --check-prefix=SAFETY-CHECK
+
+# CHECK-NOT: {{[^V]}} llvm::Any::TypeId
+# SAFETY-CHECK: V llvm::Any::TypeId


        


More information about the llvm-commits mailing list