Skip to content

Commit 2c42a73

Browse files
author
serge-sans-paille
committed
Add extra check for llvm::Any::TypeId visibility
This check should ensure we don't reproduce the problem fixed by 02df443 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
1 parent 945df8b commit 2c42a73

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

llvm/test/lit.cfg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ def get_asan_rtlib():
240240
if not config.build_shared_libs and not config.link_llvm_dylib:
241241
config.available_features.add('static-libs')
242242

243+
if config.link_llvm_dylib:
244+
config.available_features.add('llvm-dylib')
245+
config.substitutions.append(
246+
('%llvmdylib',
247+
'{}/libLLVM-{}{}'.format(config.llvm_shlib_dir,
248+
config.llvm_dylib_version,
249+
config.llvm_shlib_ext)))
250+
243251
if config.have_tf_aot:
244252
config.available_features.add("have_tf_aot")
245253

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ config.build_examples = @LLVM_BUILD_EXAMPLES@
4545
config.enable_threads = @LLVM_ENABLE_THREADS@
4646
config.build_shared_libs = @BUILD_SHARED_LIBS@
4747
config.link_llvm_dylib = @LLVM_LINK_LLVM_DYLIB@
48+
config.llvm_dylib_version = "@LLVM_VERSION_MAJOR@@LLVM_VERSION_SUFFIX@"
4849
config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
4950
config.host_arch = "@HOST_ARCH@"
5051
config.have_opt_viewer_modules = @LLVM_HAVE_OPT_VIEWER_MODULES@
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# REQUIRES: x86_64-linux, llvm-dylib
2+
3+
# Make sure there's no llvm::Any::TypeId symbol local to the shared library. As
4+
# the adress of llvm::Any::TypeId::Id is used as a global unique identifier for
5+
# each type, having another visibility defeats the original purpose.
6+
#
7+
# This happens when llvm::Any::TypeId is parametrized by a type with hidden
8+
# visibility.
9+
10+
# RUN: llvm-nm -C %llvmdylib | FileCheck %s
11+
# RUN: llvm-nm -C %llvmdylib | FileCheck %s --check-prefix=SAFETY-CHECK
12+
13+
# CHECK-NOT: {{[^V]}} llvm::Any::TypeId
14+
# SAFETY-CHECK: V llvm::Any::TypeId

0 commit comments

Comments
 (0)