llvm-project/bolt/test/lit.cfg.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
3.4 KiB
Python
Raw Normal View History

# -*- 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')
# 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.')
if config.bolt_enable_runtime:
config.available_features.add("bolt-runtime")
llvm_config.use_default_substitutions()
[BOLT][CMAKE] Accept BOLT_CLANG_EXE and BOLT_LLD_EXE Add CMake options to supply clang and lld binaries for use in check-bolt instead of requiring the build of clang and lld projects. Suggested by Mehdi Amini in https://lists.llvm.org/pipermail/llvm-dev/2021-December/154426.html Test Plan: ``` cmake -G Ninja ~/local/llvm-project/llvm \ -DLLVM_TARGETS_TO_BUILD="X86" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_PROJECTS="bolt" \ -DBOLT_CLANG_EXE=~/local/bin/clang \ -DBOLT_LLD_EXE=~/local/bin/lld ninja check-bolt ... llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /home/aaupov/local/bin/clang llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld.lld: /home/aaupov/local/bin/ld.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld-link: /home/aaupov/local/bin/lld-link llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld64.lld: /home/aaupov/local/bin/ld64.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using wasm-ld: /home/aaupov/local/bin/wasm-ld ... ``` Tested all configurations: - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + no BOLT_*_EXE - LLVM_ENABLE_PROJECTS="bolt;clang" + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;lld" + BOLT_CLANG_EXE - LLVM_ENABLE_PROJECTS="bolt" + BOLT_CLANG_EXE + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + BOLT_CLANG_EXE + BOLT_LLD_EXE Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D117061
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)])
config.substitutions.append(('%cflags', '-no-pie'))
config.substitutions.append(('%cxxflags', '-no-pie'))
link_fdata_cmd = os.path.join(config.test_source_root, 'link_fdata.py')
tool_dirs = [config.llvm_tools_dir,
config.test_source_root]
tools = [
ToolSubst('llc', unresolved='fatal'),
ToolSubst('llvm-dwarfdump', unresolved='fatal'),
ToolSubst('llvm-bolt', unresolved='fatal'),
ToolSubst('llvm-boltdiff', unresolved='fatal'),
ToolSubst('perf2bolt', unresolved='fatal'),
ToolSubst('yaml2obj', unresolved='fatal'),
ToolSubst('llvm-mc', unresolved='fatal'),
ToolSubst('llvm-nm', unresolved='fatal'),
ToolSubst('llvm-objdump', unresolved='fatal'),
ToolSubst('llvm-objcopy', unresolved='fatal'),
ToolSubst('llvm-strip', unresolved='fatal'),
ToolSubst('llvm-readelf', unresolved='fatal'),
ToolSubst('link_fdata', command=link_fdata_cmd, unresolved='fatal'),
ToolSubst('merge-fdata', unresolved='fatal'),
]
llvm_config.add_tool_substitutions(tools, tool_dirs)
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)
])