Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | import os |
| 4 | import platform |
| 5 | import re |
| 6 | import subprocess |
Michael J. Spencer | a4f983e | 2014-03-26 00:53:48 +0000 | [diff] [blame] | 7 | import locale |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 8 | |
Daniel Dunbar | bc7bfb1 | 2013-08-09 18:51:17 +0000 | [diff] [blame] | 9 | import lit.formats |
| 10 | import lit.util |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 11 | |
Zachary Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 12 | from lit.llvm import llvm_config |
Zachary Turner | 96b04b6 | 2017-10-06 17:54:46 +0000 | [diff] [blame^] | 13 | from lit.llvm.subst import ToolSubst |
Zachary Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 14 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 15 | # Configuration file for the 'lit' test runner. |
| 16 | |
| 17 | # name: The name of this test suite. |
| 18 | config.name = 'lld' |
| 19 | |
| 20 | # testFormat: The test format to use to interpret tests. |
| 21 | # |
| 22 | # For now we require '&&' between commands, until they get globally killed and |
| 23 | # the test runner updated. |
Zachary Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 24 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 25 | |
| 26 | # suffixes: A list of file extensions to treat as test files. |
Reid Kleckner | 892d2a5 | 2017-06-26 16:42:44 +0000 | [diff] [blame] | 27 | config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt'] |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 28 | |
Rafael Espindola | c08ab8e | 2015-04-24 15:51:45 +0000 | [diff] [blame] | 29 | # excludes: A list of directories to exclude from the testsuite. The 'Inputs' |
| 30 | # subdirectories contain auxiliary inputs for various tests in their parent |
| 31 | # directories. |
| 32 | config.excludes = ['Inputs'] |
| 33 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 34 | # test_source_root: The root path where tests are located. |
| 35 | config.test_source_root = os.path.dirname(__file__) |
| 36 | |
Zachary Turner | ce92db1 | 2017-09-15 22:10:46 +0000 | [diff] [blame] | 37 | config.test_exec_root = os.path.join(config.lld_obj_root, 'test') |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 38 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 39 | # Tweak the PATH to include the tools dir and the scripts dir. |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 40 | llvm_config.with_environment('PATH', |
| 41 | [config.llvm_tools_dir, config.lld_tools_dir], append_path=True) |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 42 | |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 43 | llvm_config.with_environment('LD_LIBRARY_PATH', |
| 44 | [config.lld_libs_dir, config.llvm_libs_dir], append_path=True) |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 45 | |
Zachary Turner | 96b04b6 | 2017-10-06 17:54:46 +0000 | [diff] [blame^] | 46 | llvm_config.use_default_substitutions() |
| 47 | |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 48 | # For each occurrence of a clang tool name, replace it with the full path to |
| 49 | # the build directory holding that tool. We explicitly specify the directories |
| 50 | # to search to ensure that we get the tools just built and not some random |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 51 | # tools that might happen to be in the user's PATH. |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 52 | tool_dirs = [config.lld_tools_dir, config.llvm_tools_dir] |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 53 | |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 54 | tool_patterns = [ |
Zachary Turner | 96b04b6 | 2017-10-06 17:54:46 +0000 | [diff] [blame^] | 55 | ToolSubst('ld.lld', extra_args=['--full-shutdown']), |
| 56 | 'lld-link', 'llvm-as', 'llvm-mc', 'llvm-nm', |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 57 | 'llvm-objdump', 'llvm-pdbutil', 'llvm-readobj', 'obj2yaml', 'yaml2obj', |
Zachary Turner | 96b04b6 | 2017-10-06 17:54:46 +0000 | [diff] [blame^] | 58 | 'lld'] |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 59 | |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 60 | llvm_config.add_tool_substitutions(tool_patterns, tool_dirs) |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 61 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 62 | # When running under valgrind, we mangle '-vg' onto the end of the triple so we |
| 63 | # can check it with XFAIL and XTARGET. |
Daniel Dunbar | bc7bfb1 | 2013-08-09 18:51:17 +0000 | [diff] [blame] | 64 | if lit_config.useValgrind: |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 65 | config.target_triple += '-vg' |
| 66 | |
Nick Kledzik | 50bda29 | 2014-09-11 00:52:05 +0000 | [diff] [blame] | 67 | # Running on ELF based *nix |
Ed Maste | 933daef | 2014-09-12 13:16:30 +0000 | [diff] [blame] | 68 | if platform.system() in ['FreeBSD', 'Linux']: |
Nick Kledzik | 50bda29 | 2014-09-11 00:52:05 +0000 | [diff] [blame] | 69 | config.available_features.add('system-linker-elf') |
| 70 | |
NAKAMURA Takumi | c96ae0c | 2016-02-09 07:30:11 +0000 | [diff] [blame] | 71 | # Set if host-cxxabi's demangler can handle target's symbols. |
| 72 | if platform.system() not in ['Windows']: |
| 73 | config.available_features.add('demangler') |
| 74 | |
Zachary Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 75 | llvm_config.feature_config( |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 76 | [('--build-mode', {'DEBUG': 'debug'}), |
| 77 | ('--assertion-mode', {'ON': 'asserts'}), |
| 78 | ('--targets-built', {'AArch64': 'aarch64', |
| 79 | 'AMDGPU': 'amdgpu', |
| 80 | 'ARM': 'arm', |
| 81 | 'AVR': 'avr', |
| 82 | 'Mips': 'mips', |
| 83 | 'PowerPC': 'ppc', |
| 84 | 'Sparc': 'sparc', |
| 85 | 'X86': 'x86'}) |
| 86 | ]) |
Rui Ueyama | f23b27a | 2013-11-04 05:17:54 +0000 | [diff] [blame] | 87 | |
Rui Ueyama | 3da3f06 | 2016-11-10 20:20:37 +0000 | [diff] [blame] | 88 | # Set a fake constant version so that we get consitent output. |
| 89 | config.environment['LLD_VERSION'] = 'LLD 1.0' |
| 90 | |
Eric Beckmann | c8dba24 | 2017-07-08 03:06:10 +0000 | [diff] [blame] | 91 | # Indirectly check if the mt.exe Microsoft utility exists by searching for |
Eric Beckmann | 87c6acf | 2017-08-22 03:15:28 +0000 | [diff] [blame] | 92 | # cvtres, which always accompanies it. Alternatively, check if we can use |
| 93 | # libxml2 to merge manifests. |
| 94 | if (lit.util.which('cvtres', config.environment['PATH'])) or \ |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 95 | (config.llvm_libxml2_enabled == '1'): |
Eric Beckmann | 87c6acf | 2017-08-22 03:15:28 +0000 | [diff] [blame] | 96 | config.available_features.add('manifest_tool') |
Eric Beckmann | 0aa4b7d | 2017-09-06 01:50:36 +0000 | [diff] [blame] | 97 | |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 98 | if (config.llvm_libxml2_enabled == '1'): |
Eric Beckmann | 0aa4b7d | 2017-09-06 01:50:36 +0000 | [diff] [blame] | 99 | config.available_features.add('libxml2') |