1# -*- Python -*- 2 3import os 4import platform 5import re 6import subprocess 7import tempfile 8 9import lit.formats 10import lit.util 11 12from lit.llvm import llvm_config 13from lit.llvm.subst import ToolSubst 14from lit.llvm.subst import FindTool 15 16# Configuration file for the 'lit' test runner. 17 18# name: The name of this test suite. 19config.name = 'BOLT' 20 21# testFormat: The test format to use to interpret tests. 22# 23# For now we require '&&' between commands, until they get globally killed and 24# the test runner updated. 25config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) 26 27# suffixes: A list of file extensions to treat as test files. 28config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', 29 '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] 30 31# excludes: A list of directories to exclude from the testsuite. The 'Inputs' 32# subdirectories contain auxiliary inputs for various tests in their parent 33# directories. 34config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt'] 35 36# test_source_root: The root path where tests are located. 37config.test_source_root = os.path.dirname(__file__) 38 39# test_exec_root: The root path where tests should be run. 40config.test_exec_root = os.path.join(config.bolt_obj_root, 'test') 41 42# checking if maxIndividualTestTime is available on the platform and sets 43# it to 60sec if so, declares lit-max-individual-test-time feature for 44# further checking by tests. 45supported, errormsg = lit_config.maxIndividualTestTimeIsSupported 46if supported: 47 config.available_features.add("lit-max-individual-test-time") 48 lit_config.maxIndividualTestTime = 60 49else: 50 lit_config.warning('Setting a timeout per test not supported. ' + errormsg 51 + ' Some tests will be skipped.') 52 53if config.bolt_enable_runtime: 54 config.available_features.add("bolt-runtime") 55 56if config.gnu_ld: 57 config.available_features.add("gnu_ld") 58 59llvm_config.use_default_substitutions() 60 61llvm_config.config.environment['CLANG'] = config.bolt_clang 62llvm_config.use_clang() 63 64llvm_config.config.environment['LD_LLD'] = config.bolt_lld 65ld_lld = llvm_config.use_llvm_tool('ld.lld', required=True, search_env='LD_LLD') 66llvm_config.config.available_features.add('ld.lld') 67llvm_config.add_tool_substitutions([ToolSubst(r'ld\.lld', command=ld_lld)]) 68 69config.substitutions.append(('%cflags', '')) 70config.substitutions.append(('%cxxflags', '')) 71 72link_fdata_cmd = os.path.join(config.test_source_root, 'link_fdata.py') 73 74tool_dirs = [config.llvm_tools_dir, 75 config.test_source_root] 76 77tools = [ 78 ToolSubst('llc', unresolved='fatal'), 79 ToolSubst('llvm-dwarfdump', unresolved='fatal'), 80 ToolSubst('llvm-bolt', unresolved='fatal'), 81 ToolSubst('llvm-boltdiff', unresolved='fatal'), 82 ToolSubst('llvm-bolt-heatmap', unresolved='fatal'), 83 ToolSubst('perf2bolt', unresolved='fatal'), 84 ToolSubst('yaml2obj', unresolved='fatal'), 85 ToolSubst('llvm-mc', unresolved='fatal'), 86 ToolSubst('llvm-nm', unresolved='fatal'), 87 ToolSubst('llvm-objdump', unresolved='fatal'), 88 ToolSubst('llvm-objcopy', unresolved='fatal'), 89 ToolSubst('llvm-strip', unresolved='fatal'), 90 ToolSubst('llvm-readelf', unresolved='fatal'), 91 ToolSubst('link_fdata', command=sys.executable, unresolved='fatal', extra_args=[link_fdata_cmd]), 92 ToolSubst('merge-fdata', unresolved='fatal'), 93 ToolSubst('llvm-readobj', unresolved='fatal'), 94] 95llvm_config.add_tool_substitutions(tools, tool_dirs) 96 97def calculate_arch_features(arch_string): 98 features = [] 99 for arch in arch_string.split(): 100 features.append(arch.lower() + '-registered-target') 101 return features 102 103 104llvm_config.feature_config( 105 [('--assertion-mode', {'ON': 'asserts'}), 106 ('--cxxflags', {r'-D_GLIBCXX_DEBUG\b': 'libstdcxx-safe-mode'}), 107 ('--targets-built', calculate_arch_features) 108 ]) 109 110config.targets = frozenset(config.targets_to_build.split()) 111