# -*- Python -*- # Configuration file for the 'lit' test runner. import os import sys import re import platform import subprocess import lit.util import lit.formats from lit.llvm import llvm_config # name: The name of this test suite. config.name = 'LLVM' # testFormat: The test format to use to interpret tests. config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) # suffixes: A list of file extensions to treat as test files. This is overriden # by individual lit.local.cfg files in the test subdirectories. config.suffixes = ['.ll', '.c', '.cxx', '.test', '.txt', '.s', '.mir'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent # directories. config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt'] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) # test_exec_root: The root path where tests should be run. config.test_exec_root = os.path.join(config.llvm_obj_root, 'test') # Tweak the PATH to include the tools dir. llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True) # Propagate some variables from the host environment. llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP', 'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']) # Propagate LLVM_SRC_ROOT into the environment. config.environment['LLVM_SRC_ROOT'] = config.llvm_src_root # Set up OCAMLPATH to include newly built OCaml libraries. top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml') llvm_ocaml_lib = os.path.join(top_ocaml_lib, 'llvm') llvm_config.with_system_environment('OCAMLPATH') llvm_config.with_environment('OCAMLPATH', top_ocaml_lib, append_path=True) llvm_config.with_environment('OCAMLPATH', llvm_ocaml_lib, append_path=True) llvm_config.with_system_environment('CAML_LD_LIBRARY_PATH') llvm_config.with_environment('CAML_LD_LIBRARY_PATH', llvm_ocaml_lib, append_path=True) # Set up OCAMLRUNPARAM to enable backtraces in OCaml tests. llvm_config.with_environment('OCAMLRUNPARAM', 'b') # Provide the path to asan runtime lib 'libclang_rt.asan_osx_dynamic.dylib' if # available. This is darwin specific since it's currently only needed on darwin. def get_asan_rtlib(): if not "Address" in config.llvm_use_sanitizer or \ not "Darwin" in config.host_os or \ not "x86" in config.host_triple: return "" try: import glob except: print("glob module not found, skipping get_asan_rtlib() lookup") return "" # The libclang_rt.asan_osx_dynamic.dylib path is obtained using the relative # path from the host cc. host_lib_dir = os.path.join(os.path.dirname(config.host_cc), "../lib") asan_dylib_dir_pattern = host_lib_dir + \ "/clang/*/lib/darwin/libclang_rt.asan_osx_dynamic.dylib" found_dylibs = glob.glob(asan_dylib_dir_pattern) if len(found_dylibs) != 1: return "" return found_dylibs[0] lli = 'lli' # The target triple used by default by lli is the process target triple (some # triple appropriate for generating code for the current process) but because # we don't support COFF in MCJIT well enough for the tests, force ELF format on # Windows. FIXME: the process target triple should be used here, but this is # difficult to obtain on Windows. if re.search(r'cygwin|mingw32|windows-gnu|windows-msvc|win32', config.host_triple): lli += ' -mtriple='+config.host_triple+'-elf' config.substitutions.append( ('%lli', lli ) ) # Similarly, have a macro to use llc with DWARF even when the host is win32. llc_dwarf = 'llc' if re.search(r'win32', config.target_triple): llc_dwarf += ' -mtriple='+config.target_triple.replace('-win32', '-mingw32') config.substitutions.append( ('%llc_dwarf', llc_dwarf) ) # Add site-specific substitutions. config.substitutions.append( ('%gold', config.gold_executable) ) config.substitutions.append( ('%go', config.go_executable) ) config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) ) config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) ) config.substitutions.append( ('%exeext', config.llvm_exe_ext) ) config.substitutions.append( ('%python', config.python_executable) ) config.substitutions.append( ('%host_cc', config.host_cc) ) # Provide the path to asan runtime lib if available. On darwin, this lib needs # to be loaded via DYLD_INSERT_LIBRARIES before libLTO.dylib in case the files # to be linked contain instrumented sanitizer code. ld64_cmd = config.ld64_executable asan_rtlib = get_asan_rtlib() if asan_rtlib: ld64_cmd = "DYLD_INSERT_LIBRARIES={} {}".format(asan_rtlib, ld64_cmd) config.substitutions.append( ('%ld64', ld64_cmd) ) # OCaml substitutions. # Support tests for both native and bytecode builds. config.substitutions.append( ('%ocamlc', "%s ocamlc -cclib -L%s %s" % (config.ocamlfind_executable, config.llvm_lib_dir, config.ocaml_flags)) ) if config.have_ocamlopt: config.substitutions.append( ('%ocamlopt', "%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s" % (config.ocamlfind_executable, config.llvm_lib_dir, config.llvm_lib_dir, config.ocaml_flags)) ) else: config.substitutions.append( ('%ocamlopt', "true" ) ) # For each occurrence of an llvm tool name as its own word, replace it # with the full path to the build directory holding that tool. This # ensures that we are testing the tools just built and not some random # tools that might happen to be in the user's PATH. Thus this list # includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin # (llvm_tools_dir in lit parlance). # Avoid matching RUN line fragments that are actually part of # path names or options or whatever. # The regex is a pre-assertion to avoid matching a preceding # dot, hyphen, carat, or slash (.foo, -foo, etc.). Some patterns # also have a post-assertion to not match a trailing hyphen (foo-). NOJUNK = r"(?