2018-06-23 04:50:07 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
|
|
|
|
|
|
|
from lit.llvm import llvm_config
|
|
|
|
from lit.llvm.subst import ToolSubst
|
|
|
|
from lit.llvm.subst import FindTool
|
|
|
|
|
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'BOLT'
|
|
|
|
|
|
|
|
# testFormat: The test format to use to interpret tests.
|
|
|
|
#
|
|
|
|
# For now we require '&&' between commands, until they get globally killed and
|
|
|
|
# the test runner updated.
|
|
|
|
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
|
|
|
config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu',
|
|
|
|
'.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']
|
|
|
|
|
|
|
|
# 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.bolt_obj_root, 'test')
|
|
|
|
|
2021-08-28 02:56:24 +08:00
|
|
|
# checking if maxIndividualTestTime is available on the platform and sets
|
|
|
|
# it to 60sec if so, declares lit-max-individual-test-time feature for
|
|
|
|
# further checking by tests.
|
|
|
|
supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
|
|
|
|
if supported:
|
|
|
|
config.available_features.add("lit-max-individual-test-time")
|
|
|
|
lit_config.maxIndividualTestTime = 60
|
|
|
|
else:
|
|
|
|
lit_config.warning('Setting a timeout per test not supported. ' + errormsg
|
|
|
|
+ ' Some tests will be skipped.')
|
|
|
|
|
2021-10-27 03:26:23 +08:00
|
|
|
if config.bolt_enable_runtime:
|
|
|
|
config.available_features.add("bolt-runtime")
|
|
|
|
|
2018-06-23 04:50:07 +08:00
|
|
|
llvm_config.use_default_substitutions()
|
|
|
|
|
2022-01-15 06:18:43 +08:00
|
|
|
llvm_config.use_clang(additional_tool_dirs=[os.path.dirname(config.bolt_clang)])
|
|
|
|
llvm_config.use_lld(additional_tool_dirs=[os.path.dirname(config.bolt_lld)])
|
2020-02-19 08:00:40 +08:00
|
|
|
|
2021-05-11 08:25:49 +08:00
|
|
|
config.substitutions.append(('%cflags', '-no-pie'))
|
|
|
|
config.substitutions.append(('%cxxflags', '-no-pie'))
|
|
|
|
|
2021-12-23 21:59:35 +08:00
|
|
|
link_fdata_cmd = os.path.join(config.test_source_root, 'link_fdata.py')
|
|
|
|
|
2020-02-19 08:00:40 +08:00
|
|
|
tool_dirs = [config.llvm_tools_dir,
|
|
|
|
config.test_source_root]
|
|
|
|
|
2018-06-23 04:50:07 +08:00
|
|
|
tools = [
|
2021-06-30 00:54:08 +08:00
|
|
|
ToolSubst('llc', unresolved='fatal'),
|
2021-02-18 07:30:10 +08:00
|
|
|
ToolSubst('llvm-dwarfdump', unresolved='fatal'),
|
2018-06-23 04:50:07 +08:00
|
|
|
ToolSubst('llvm-bolt', unresolved='fatal'),
|
2021-11-16 05:53:18 +08:00
|
|
|
ToolSubst('llvm-boltdiff', unresolved='fatal'),
|
2020-02-19 08:00:40 +08:00
|
|
|
ToolSubst('perf2bolt', unresolved='fatal'),
|
|
|
|
ToolSubst('yaml2obj', unresolved='fatal'),
|
|
|
|
ToolSubst('llvm-mc', unresolved='fatal'),
|
2021-05-05 07:45:28 +08:00
|
|
|
ToolSubst('llvm-nm', unresolved='fatal'),
|
2021-06-05 03:31:31 +08:00
|
|
|
ToolSubst('llvm-objdump', unresolved='fatal'),
|
2021-06-30 00:54:08 +08:00
|
|
|
ToolSubst('llvm-objcopy', unresolved='fatal'),
|
2021-05-05 07:45:28 +08:00
|
|
|
ToolSubst('llvm-strip', unresolved='fatal'),
|
2021-10-30 04:31:22 +08:00
|
|
|
ToolSubst('llvm-readelf', unresolved='fatal'),
|
2021-12-23 21:59:35 +08:00
|
|
|
ToolSubst('link_fdata', command=link_fdata_cmd, unresolved='fatal'),
|
2021-11-04 01:41:26 +08:00
|
|
|
ToolSubst('merge-fdata', unresolved='fatal'),
|
2018-06-23 04:50:07 +08:00
|
|
|
]
|
2020-02-19 08:00:40 +08:00
|
|
|
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
2018-06-23 04:50:07 +08:00
|
|
|
|
|
|
|
def calculate_arch_features(arch_string):
|
|
|
|
features = []
|
|
|
|
for arch in arch_string.split():
|
|
|
|
features.append(arch.lower() + '-registered-target')
|
|
|
|
return features
|
|
|
|
|
|
|
|
|
|
|
|
llvm_config.feature_config(
|
|
|
|
[('--assertion-mode', {'ON': 'asserts'}),
|
|
|
|
('--cxxflags', {r'-D_GLIBCXX_DEBUG\b': 'libstdcxx-safe-mode'}),
|
|
|
|
('--targets-built', calculate_arch_features)
|
|
|
|
])
|