2011-12-18 16:27:59 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import re
|
|
|
|
import subprocess
|
2014-03-26 08:53:48 +08:00
|
|
|
import locale
|
2011-12-18 16:27:59 +08:00
|
|
|
|
2013-08-10 02:51:17 +08:00
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
2011-12-18 16:27:59 +08:00
|
|
|
|
2017-09-19 06:26:48 +08:00
|
|
|
from lit.llvm import llvm_config
|
|
|
|
|
2011-12-18 16:27:59 +08: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.
|
|
|
|
#
|
2020-12-04 08:51:56 +08:00
|
|
|
# For now we require '&&' between commands, until they get globally killed and the test runner updated.
|
2017-09-19 06:26:48 +08:00
|
|
|
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
2011-12-18 16:27:59 +08:00
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
2017-06-27 00:42:44 +08:00
|
|
|
config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt']
|
2011-12-18 16:27:59 +08:00
|
|
|
|
2015-04-24 23:51:45 +08: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 16:27:59 +08:00
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
2017-09-16 06:10:46 +08:00
|
|
|
config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
|
2011-12-18 16:27:59 +08: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-07 01:54:46 +08:00
|
|
|
llvm_config.use_default_substitutions()
|
2017-10-13 05:56:05 +08:00
|
|
|
llvm_config.use_lld()
|
2016-10-27 02:59:00 +08:00
|
|
|
|
2017-09-22 06:16:40 +08:00
|
|
|
tool_patterns = [
|
2021-11-09 23:42:21 +08:00
|
|
|
'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-otool', 'llvm-pdbutil',
|
2020-07-29 04:26:09 +08:00
|
|
|
'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
|
|
|
|
'opt', 'llvm-dis']
|
2017-09-22 06:16:40 +08:00
|
|
|
|
2017-10-13 05:56:05 +08:00
|
|
|
llvm_config.add_tool_substitutions(tool_patterns)
|
2015-12-11 03:17:35 +08:00
|
|
|
|
2018-12-24 05:20:09 +08:00
|
|
|
# LLD tests tend to be flaky on NetBSD, so add some retries.
|
|
|
|
# We don't do this on other platforms because it's slower.
|
|
|
|
if platform.system() in ['NetBSD']:
|
|
|
|
config.test_retry_attempts = 2
|
|
|
|
|
2011-12-18 16:27:59 +08: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-10 02:51:17 +08:00
|
|
|
if lit_config.useValgrind:
|
2011-12-18 16:27:59 +08:00
|
|
|
config.target_triple += '-vg'
|
|
|
|
|
2014-09-11 08:52:05 +08:00
|
|
|
# Running on ELF based *nix
|
2019-01-03 03:39:26 +08:00
|
|
|
if platform.system() in ['FreeBSD', 'NetBSD', 'Linux']:
|
2014-09-11 08:52:05 +08:00
|
|
|
config.available_features.add('system-linker-elf')
|
|
|
|
|
2016-02-09 15:30:11 +08: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-19 06:26:48 +08:00
|
|
|
llvm_config.feature_config(
|
2021-12-17 23:04:30 +08:00
|
|
|
[('--targets-built', {'AArch64': 'aarch64',
|
2017-10-07 01:54:27 +08:00
|
|
|
'AMDGPU': 'amdgpu',
|
|
|
|
'ARM': 'arm',
|
|
|
|
'AVR': 'avr',
|
2018-06-14 02:45:25 +08:00
|
|
|
'Hexagon': 'hexagon',
|
2017-10-07 01:54:27 +08:00
|
|
|
'Mips': 'mips',
|
2019-01-10 21:43:06 +08:00
|
|
|
'MSP430': 'msp430',
|
2017-10-07 01:54:27 +08:00
|
|
|
'PowerPC': 'ppc',
|
2018-08-10 01:59:56 +08:00
|
|
|
'RISCV': 'riscv',
|
2017-10-07 01:54:27 +08:00
|
|
|
'Sparc': 'sparc',
|
2017-11-18 02:14:09 +08:00
|
|
|
'WebAssembly': 'wasm',
|
2017-10-07 01:54:27 +08:00
|
|
|
'X86': 'x86'})
|
|
|
|
])
|
2013-11-04 13:17:54 +08:00
|
|
|
|
2018-03-21 02:10:30 +08:00
|
|
|
# Set a fake constant version so that we get consistent output.
|
2016-11-11 04:20:37 +08:00
|
|
|
config.environment['LLD_VERSION'] = 'LLD 1.0'
|
2021-11-01 07:55:12 +08:00
|
|
|
|
|
|
|
# LLD_IN_TEST determines how many times `main` is run inside each process, which
|
|
|
|
# lets us test that it's cleaning up after itself and resetting global state
|
|
|
|
# correctly (which is important for usage as a library).
|
|
|
|
run_lld_main_twice = lit_config.params.get('RUN_LLD_MAIN_TWICE', False)
|
|
|
|
if not run_lld_main_twice:
|
|
|
|
config.environment['LLD_IN_TEST'] = '1'
|
|
|
|
else:
|
|
|
|
config.environment['LLD_IN_TEST'] = '2'
|
|
|
|
# Many ELF tests fail in this mode.
|
|
|
|
config.excludes.append('ELF')
|
|
|
|
# Some old Mach-O backend tests fail, and it's due for removal anyway.
|
|
|
|
config.excludes.append('mach-o')
|
|
|
|
# Some new Mach-O backend tests fail; give them a way to mark themselves
|
|
|
|
# unsupported in this mode.
|
|
|
|
config.available_features.add('main-run-twice')
|
2016-11-11 04:20:37 +08:00
|
|
|
|
2017-07-08 11:06:10 +08:00
|
|
|
# Indirectly check if the mt.exe Microsoft utility exists by searching for
|
2017-08-22 11:15:28 +08:00
|
|
|
# cvtres, which always accompanies it. Alternatively, check if we can use
|
|
|
|
# libxml2 to merge manifests.
|
2020-07-25 06:47:38 +08:00
|
|
|
if (lit.util.which('cvtres', config.environment['PATH']) or
|
2020-09-10 13:03:13 +08:00
|
|
|
config.have_libxml2):
|
2017-08-22 11:15:28 +08:00
|
|
|
config.available_features.add('manifest_tool')
|
2017-09-06 09:50:36 +08:00
|
|
|
|
2021-04-17 04:46:45 +08:00
|
|
|
if config.have_libxar:
|
|
|
|
config.available_features.add('xar')
|
|
|
|
|
2020-07-25 06:47:38 +08:00
|
|
|
if config.have_libxml2:
|
2017-09-06 09:50:36 +08:00
|
|
|
config.available_features.add('libxml2')
|
2017-10-21 03:48:26 +08:00
|
|
|
|
2018-03-24 03:57:25 +08:00
|
|
|
if config.have_dia_sdk:
|
|
|
|
config.available_features.add("diasdk")
|
|
|
|
|
2019-03-02 02:53:41 +08:00
|
|
|
if config.sizeof_void_p == 8:
|
|
|
|
config.available_features.add("llvm-64-bits")
|
|
|
|
|
2022-03-24 14:52:16 +08:00
|
|
|
if config.has_plugins:
|
|
|
|
config.available_features.add('plugins')
|
|
|
|
|
|
|
|
if config.build_examples:
|
|
|
|
config.available_features.add('examples')
|
|
|
|
|
|
|
|
if config.linked_bye_extension:
|
|
|
|
config.substitutions.append(('%loadbye', ''))
|
|
|
|
config.substitutions.append(('%loadnewpmbye', ''))
|
|
|
|
else:
|
|
|
|
config.substitutions.append(('%loadbye',
|
|
|
|
'-load={}/Bye{}'.format(config.llvm_shlib_dir,
|
|
|
|
config.llvm_shlib_ext)))
|
|
|
|
config.substitutions.append(('%loadnewpmbye',
|
|
|
|
'-load-pass-plugin={}/Bye{}'
|
|
|
|
.format(config.llvm_shlib_dir,
|
|
|
|
config.llvm_shlib_ext)))
|
|
|
|
|
2017-10-26 10:31:36 +08:00
|
|
|
tar_executable = lit.util.which('tar', config.environment['PATH'])
|
|
|
|
if tar_executable:
|
2021-03-25 05:58:54 +08:00
|
|
|
env = os.environ
|
|
|
|
env['LANG'] = 'C'
|
2017-10-26 10:31:36 +08:00
|
|
|
tar_version = subprocess.Popen(
|
2018-12-15 06:38:01 +08:00
|
|
|
[tar_executable, '--version'],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
2021-03-25 05:58:54 +08:00
|
|
|
env=env)
|
2018-12-15 06:38:01 +08:00
|
|
|
sout, _ = tar_version.communicate()
|
|
|
|
if 'GNU tar' in sout.decode():
|
2017-10-26 10:31:36 +08:00
|
|
|
config.available_features.add('gnutar')
|
2020-10-08 14:34:18 +08:00
|
|
|
|
|
|
|
# ELF tests expect the default target for ld.lld to be ELF.
|
|
|
|
if config.ld_lld_default_mingw:
|
|
|
|
config.excludes.append('ELF')
|