Skip to content

Commit 66aea6e

Browse files
committedJan 8, 2018
Don't try to run MCJIT/OrcJIT EH tests when C++ library is statically linked
These tests assumes availability of external symbols provided by the C++ library, but those won't be available in case when the C++ library is statically linked because lli itself doesn't need these. This uses llvm-readobj -needed-libs to check if C++ library is linked as shared library and exposes that information as a feature to lit. Differential Revision: https://reviews.llvm.org/D41272 llvm-svn: 321981
1 parent b3f8022 commit 66aea6e

File tree

9 files changed

+38
-0
lines changed

9 files changed

+38
-0
lines changed
 

‎llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -relocation-model=pic -code-model=large %s
23
; XFAIL: cygwin, win32, mingw, mips-, mipsel-, i686, i386, aarch64, arm
34
declare i8* @__cxa_allocate_exception(i64)

‎llvm/test/ExecutionEngine/MCJIT/eh.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli %s
23
; XFAIL: arm, cygwin, win32, mingw
34
declare i8* @__cxa_allocate_exception(i64)

‎llvm/test/ExecutionEngine/MCJIT/multi-module-eh-a.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -extra-module=%p/Inputs/multi-module-eh-b.ll %s
23
; XFAIL: arm, cygwin, win32, mingw
34
declare i8* @__cxa_allocate_exception(i64)

‎llvm/test/ExecutionEngine/MCJIT/remote/eh.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -remote-mcjit -mcjit-remote-process=lli-child-target%exeext %s
23
; XFAIL: arm, cygwin, win32, mingw
34
; UNSUPPORTED: powerpc64-unknown-linux-gnu

‎llvm/test/ExecutionEngine/OrcMCJIT/eh-lg-pic.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -jit-kind=orc-mcjit -relocation-model=pic -code-model=large %s
23
; XFAIL: cygwin, win32, mingw, mips-, mipsel-, i686, i386, aarch64, arm
34
declare i8* @__cxa_allocate_exception(i64)

‎llvm/test/ExecutionEngine/OrcMCJIT/eh.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -jit-kind=orc-mcjit %s
23
; XFAIL: arm, cygwin, win32, mingw
34
declare i8* @__cxa_allocate_exception(i64)

‎llvm/test/ExecutionEngine/OrcMCJIT/multi-module-eh-a.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -jit-kind=orc-mcjit -extra-module=%p/Inputs/multi-module-eh-b.ll %s
23
; XFAIL: arm, cygwin, win32, mingw
34
declare i8* @__cxa_allocate_exception(i64)

‎llvm/test/ExecutionEngine/OrcMCJIT/remote/eh.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; REQUIRES: cxx-shared-library
12
; RUN: %lli -remote-mcjit -mcjit-remote-process=lli-child-target%exeext %s
23
; XFAIL: arm, cygwin, win32, mingw
34
; UNSUPPORTED: powerpc64-unknown-linux-gnu

‎llvm/test/lit.cfg.py

+30
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,36 @@ def get_asan_rtlib():
194194
if not config.build_shared_libs and not config.link_llvm_dylib:
195195
config.available_features.add('static-libs')
196196

197+
def have_cxx_shared_library():
198+
readobj_exe = lit.util.which('llvm-readobj', config.llvm_tools_dir)
199+
if not readobj_exe:
200+
print('llvm-readobj not found')
201+
return False
202+
203+
try:
204+
readobj_cmd = subprocess.Popen(
205+
[readobj_exe, '-needed-libs', readobj_exe], stdout=subprocess.PIPE)
206+
except OSError:
207+
print('could not exec llvm-readobj')
208+
return False
209+
210+
readobj_out = readobj_cmd.stdout.read().decode('ascii')
211+
readobj_cmd.wait()
212+
213+
regex = re.compile(r'(libc\+\+|libstdc\+\+|msvcp).*\.(so|dylib|dll)')
214+
needed_libs = False
215+
for line in readobj_out.splitlines():
216+
if 'NeededLibraries [' in line:
217+
needed_libs = True
218+
if ']' in line:
219+
needed_libs = False
220+
if needed_libs and regex.search(line.lower()):
221+
return True
222+
return False
223+
224+
if have_cxx_shared_library():
225+
config.available_features.add('cxx-shared-library')
226+
197227
# Direct object generation
198228
if not 'hexagon' in config.target_triple:
199229
config.available_features.add('object-emission')

0 commit comments

Comments
 (0)