2011-12-18 08:27:59 +00:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import re
|
|
|
|
import subprocess
|
2014-03-26 00:53:48 +00:00
|
|
|
import locale
|
2011-12-18 08:27:59 +00:00
|
|
|
|
2013-08-09 18:51:17 +00:00
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
2011-12-18 08:27:59 +00:00
|
|
|
|
2017-09-18 22:26:48 +00:00
|
|
|
from lit.llvm import llvm_config
|
[lit] Improve tool substitution in lit.
This addresses two sources of inconsistency in test configuration
files.
1. Substitution boundaries. Previously you would specify a
substitution, such as 'lli', and then additionally a set
of characters that should fail to match before and after
the tool. This was used, for example, so that matches that
are parts of full paths would not be replaced. But not all
tools did this, and those that did would often re-invent
the set of characters themselves, leading to inconsistency.
Now, every tool substitution defaults to using a sane set
of reasonable defaults and you have to explicitly opt out
of it. This actually fixed a few latent bugs that were
never being surfaced, but only on accident.
2. There was no standard way for the system to decide how to
locate a tool. Sometimes you have an explicit path, sometimes
we would search for it and build up a path ourselves, and
sometimes we would build up a full command line. Furthermore,
there was no standardized way to handle missing tools. Do we
warn, fail, ignore, etc? All of this is now encapsulated in
the ToolSubst class. You either specify an exact command to
run, or an instance of FindTool('<tool-name>') and everything
else just works. Furthermore, you can specify an action to
take if the tool cannot be resolved.
Differential Revision: https://reviews.llvm.org/D38565
llvm-svn: 315085
2017-10-06 17:54:46 +00:00
|
|
|
from lit.llvm.subst import ToolSubst
|
2017-09-18 22:26:48 +00:00
|
|
|
|
2011-12-18 08:27:59 +00:00
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'lld'
|
|
|
|
|
|
|
|
# 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.
|
2017-09-18 22:26:48 +00:00
|
|
|
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
2011-12-18 08:27:59 +00:00
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
2017-06-26 16:42:44 +00:00
|
|
|
config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt']
|
2011-12-18 08:27:59 +00:00
|
|
|
|
2015-04-24 15:51:45 +00:00
|
|
|
# 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']
|
|
|
|
|
2011-12-18 08:27:59 +00:00
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
2017-09-15 22:10:46 +00:00
|
|
|
config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
|
2011-12-18 08:27:59 +00:00
|
|
|
|
|
|
|
# Tweak the PATH to include the tools dir and the scripts dir.
|
2017-09-21 22:16:40 +00:00
|
|
|
llvm_config.with_environment('PATH',
|
|
|
|
[config.llvm_tools_dir, config.lld_tools_dir], append_path=True)
|
2017-09-15 22:10:46 +00:00
|
|
|
|
2017-09-21 22:16:40 +00:00
|
|
|
llvm_config.with_environment('LD_LIBRARY_PATH',
|
|
|
|
[config.lld_libs_dir, config.llvm_libs_dir], append_path=True)
|
2011-12-18 08:27:59 +00:00
|
|
|
|
[lit] Improve tool substitution in lit.
This addresses two sources of inconsistency in test configuration
files.
1. Substitution boundaries. Previously you would specify a
substitution, such as 'lli', and then additionally a set
of characters that should fail to match before and after
the tool. This was used, for example, so that matches that
are parts of full paths would not be replaced. But not all
tools did this, and those that did would often re-invent
the set of characters themselves, leading to inconsistency.
Now, every tool substitution defaults to using a sane set
of reasonable defaults and you have to explicitly opt out
of it. This actually fixed a few latent bugs that were
never being surfaced, but only on accident.
2. There was no standard way for the system to decide how to
locate a tool. Sometimes you have an explicit path, sometimes
we would search for it and build up a path ourselves, and
sometimes we would build up a full command line. Furthermore,
there was no standardized way to handle missing tools. Do we
warn, fail, ignore, etc? All of this is now encapsulated in
the ToolSubst class. You either specify an exact command to
run, or an instance of FindTool('<tool-name>') and everything
else just works. Furthermore, you can specify an action to
take if the tool cannot be resolved.
Differential Revision: https://reviews.llvm.org/D38565
llvm-svn: 315085
2017-10-06 17:54:46 +00:00
|
|
|
llvm_config.use_default_substitutions()
|
|
|
|
|
2017-09-21 22:16:40 +00:00
|
|
|
# For each occurrence of a clang tool name, replace it with the full path to
|
|
|
|
# the build directory holding that tool. We explicitly specify the directories
|
|
|
|
# to search to ensure that we get the tools just built and not some random
|
2015-12-10 19:17:35 +00:00
|
|
|
# tools that might happen to be in the user's PATH.
|
2017-09-21 22:16:40 +00:00
|
|
|
tool_dirs = [config.lld_tools_dir, config.llvm_tools_dir]
|
2016-10-26 18:59:00 +00:00
|
|
|
|
2017-09-21 22:16:40 +00:00
|
|
|
tool_patterns = [
|
[lit] Improve tool substitution in lit.
This addresses two sources of inconsistency in test configuration
files.
1. Substitution boundaries. Previously you would specify a
substitution, such as 'lli', and then additionally a set
of characters that should fail to match before and after
the tool. This was used, for example, so that matches that
are parts of full paths would not be replaced. But not all
tools did this, and those that did would often re-invent
the set of characters themselves, leading to inconsistency.
Now, every tool substitution defaults to using a sane set
of reasonable defaults and you have to explicitly opt out
of it. This actually fixed a few latent bugs that were
never being surfaced, but only on accident.
2. There was no standard way for the system to decide how to
locate a tool. Sometimes you have an explicit path, sometimes
we would search for it and build up a path ourselves, and
sometimes we would build up a full command line. Furthermore,
there was no standardized way to handle missing tools. Do we
warn, fail, ignore, etc? All of this is now encapsulated in
the ToolSubst class. You either specify an exact command to
run, or an instance of FindTool('<tool-name>') and everything
else just works. Furthermore, you can specify an action to
take if the tool cannot be resolved.
Differential Revision: https://reviews.llvm.org/D38565
llvm-svn: 315085
2017-10-06 17:54:46 +00:00
|
|
|
ToolSubst('ld.lld', extra_args=['--full-shutdown']),
|
|
|
|
'lld-link', 'llvm-as', 'llvm-mc', 'llvm-nm',
|
2017-09-21 22:16:40 +00:00
|
|
|
'llvm-objdump', 'llvm-pdbutil', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
|
[lit] Improve tool substitution in lit.
This addresses two sources of inconsistency in test configuration
files.
1. Substitution boundaries. Previously you would specify a
substitution, such as 'lli', and then additionally a set
of characters that should fail to match before and after
the tool. This was used, for example, so that matches that
are parts of full paths would not be replaced. But not all
tools did this, and those that did would often re-invent
the set of characters themselves, leading to inconsistency.
Now, every tool substitution defaults to using a sane set
of reasonable defaults and you have to explicitly opt out
of it. This actually fixed a few latent bugs that were
never being surfaced, but only on accident.
2. There was no standard way for the system to decide how to
locate a tool. Sometimes you have an explicit path, sometimes
we would search for it and build up a path ourselves, and
sometimes we would build up a full command line. Furthermore,
there was no standardized way to handle missing tools. Do we
warn, fail, ignore, etc? All of this is now encapsulated in
the ToolSubst class. You either specify an exact command to
run, or an instance of FindTool('<tool-name>') and everything
else just works. Furthermore, you can specify an action to
take if the tool cannot be resolved.
Differential Revision: https://reviews.llvm.org/D38565
llvm-svn: 315085
2017-10-06 17:54:46 +00:00
|
|
|
'lld']
|
2017-09-21 22:16:40 +00:00
|
|
|
|
|
|
|
llvm_config.add_tool_substitutions(tool_patterns, tool_dirs)
|
2015-12-10 19:17:35 +00:00
|
|
|
|
2011-12-18 08:27:59 +00:00
|
|
|
# When running under valgrind, we mangle '-vg' onto the end of the triple so we
|
|
|
|
# can check it with XFAIL and XTARGET.
|
2013-08-09 18:51:17 +00:00
|
|
|
if lit_config.useValgrind:
|
2011-12-18 08:27:59 +00:00
|
|
|
config.target_triple += '-vg'
|
|
|
|
|
2014-09-11 00:52:05 +00:00
|
|
|
# Running on ELF based *nix
|
2014-09-12 13:16:30 +00:00
|
|
|
if platform.system() in ['FreeBSD', 'Linux']:
|
2014-09-11 00:52:05 +00:00
|
|
|
config.available_features.add('system-linker-elf')
|
|
|
|
|
2016-02-09 07:30:11 +00:00
|
|
|
# Set if host-cxxabi's demangler can handle target's symbols.
|
|
|
|
if platform.system() not in ['Windows']:
|
|
|
|
config.available_features.add('demangler')
|
|
|
|
|
2017-09-18 22:26:48 +00:00
|
|
|
llvm_config.feature_config(
|
2017-10-06 17:54:27 +00:00
|
|
|
[('--build-mode', {'DEBUG': 'debug'}),
|
|
|
|
('--assertion-mode', {'ON': 'asserts'}),
|
|
|
|
('--targets-built', {'AArch64': 'aarch64',
|
|
|
|
'AMDGPU': 'amdgpu',
|
|
|
|
'ARM': 'arm',
|
|
|
|
'AVR': 'avr',
|
|
|
|
'Mips': 'mips',
|
|
|
|
'PowerPC': 'ppc',
|
|
|
|
'Sparc': 'sparc',
|
|
|
|
'X86': 'x86'})
|
|
|
|
])
|
2013-11-04 05:17:54 +00:00
|
|
|
|
2016-11-10 20:20:37 +00:00
|
|
|
# Set a fake constant version so that we get consitent output.
|
|
|
|
config.environment['LLD_VERSION'] = 'LLD 1.0'
|
|
|
|
|
2017-07-08 03:06:10 +00:00
|
|
|
# Indirectly check if the mt.exe Microsoft utility exists by searching for
|
2017-08-22 03:15:28 +00:00
|
|
|
# cvtres, which always accompanies it. Alternatively, check if we can use
|
|
|
|
# libxml2 to merge manifests.
|
|
|
|
if (lit.util.which('cvtres', config.environment['PATH'])) or \
|
2017-10-06 17:54:27 +00:00
|
|
|
(config.llvm_libxml2_enabled == '1'):
|
2017-08-22 03:15:28 +00:00
|
|
|
config.available_features.add('manifest_tool')
|
2017-09-06 01:50:36 +00:00
|
|
|
|
2017-10-06 17:54:27 +00:00
|
|
|
if (config.llvm_libxml2_enabled == '1'):
|
2017-09-06 01:50:36 +00:00
|
|
|
config.available_features.add('libxml2')
|