annotate test/lit.cfg.py @ 129:9ec641e857f8

Fix compile error to update llvm 5.0
author mir3636
date Tue, 12 Dec 2017 19:42:58 +0900
parents 803732b1fca8
children 3a76565eade5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 # -*- Python -*-
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 # Configuration file for the 'lit' test runner.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 import os
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 import sys
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 import re
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 import platform
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 import subprocess
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 import lit.util
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 import lit.formats
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 from lit.llvm import llvm_config
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14 from lit.llvm.subst import FindTool
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 from lit.llvm.subst import ToolSubst
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 # name: The name of this test suite.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 config.name = 'LLVM'
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 # testFormat: The test format to use to interpret tests.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 # suffixes: A list of file extensions to treat as test files. This is overriden
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 # by individual lit.local.cfg files in the test subdirectories.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 config.suffixes = ['.ll', '.c', '.cxx', '.test', '.txt', '.s', '.mir']
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 # subdirectories contain auxiliary inputs for various tests in their parent
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 # directories.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 # test_source_root: The root path where tests are located.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 config.test_source_root = os.path.dirname(__file__)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 # test_exec_root: The root path where tests should be run.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 config.test_exec_root = os.path.join(config.llvm_obj_root, 'test')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 # Tweak the PATH to include the tools dir.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 # Propagate some variables from the host environment.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 llvm_config.with_system_environment(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP', 'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 # Set up OCAMLPATH to include newly built OCaml libraries.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 llvm_ocaml_lib = os.path.join(top_ocaml_lib, 'llvm')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 llvm_config.with_system_environment('OCAMLPATH')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51 llvm_config.with_environment('OCAMLPATH', top_ocaml_lib, append_path=True)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52 llvm_config.with_environment('OCAMLPATH', llvm_ocaml_lib, append_path=True)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54 llvm_config.with_system_environment('CAML_LD_LIBRARY_PATH')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 llvm_config.with_environment(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
56 'CAML_LD_LIBRARY_PATH', llvm_ocaml_lib, append_path=True)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
57
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
58 # Set up OCAMLRUNPARAM to enable backtraces in OCaml tests.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
59 llvm_config.with_environment('OCAMLRUNPARAM', 'b')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
60
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
61 # Provide the path to asan runtime lib 'libclang_rt.asan_osx_dynamic.dylib' if
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
62 # available. This is darwin specific since it's currently only needed on darwin.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
63
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
64
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
65 def get_asan_rtlib():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
66 if not 'Address' in config.llvm_use_sanitizer or \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
67 not 'Darwin' in config.host_os or \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
68 not 'x86' in config.host_triple:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
69 return ''
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
70 try:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
71 import glob
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
72 except:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
73 print('glob module not found, skipping get_asan_rtlib() lookup')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
74 return ''
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
75 # The libclang_rt.asan_osx_dynamic.dylib path is obtained using the relative
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
76 # path from the host cc.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
77 host_lib_dir = os.path.join(os.path.dirname(config.host_cc), '../lib')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
78 asan_dylib_dir_pattern = host_lib_dir + \
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
79 '/clang/*/lib/darwin/libclang_rt.asan_osx_dynamic.dylib'
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
80 found_dylibs = glob.glob(asan_dylib_dir_pattern)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
81 if len(found_dylibs) != 1:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
82 return ''
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
83 return found_dylibs[0]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
84
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
85
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
86 llvm_config.use_default_substitutions()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
87
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
88 # Add site-specific substitutions.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
89 config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
90 config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
91 config.substitutions.append(('%exeext', config.llvm_exe_ext))
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
92 config.substitutions.append(('%host_cc', config.host_cc))
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
93
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
94
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
95 lli_args = []
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
96 # The target triple used by default by lli is the process target triple (some
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
97 # triple appropriate for generating code for the current process) but because
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
98 # we don't support COFF in MCJIT well enough for the tests, force ELF format on
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
99 # Windows. FIXME: the process target triple should be used here, but this is
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
100 # difficult to obtain on Windows.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
101 if re.search(r'cygwin|mingw32|windows-gnu|windows-msvc|win32', config.host_triple):
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
102 lli_args = ['-mtriple=' + config.host_triple + '-elf']
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
103
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
104 llc_args = []
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
105
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
106 # Similarly, have a macro to use llc with DWARF even when the host is win32.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
107 if re.search(r'win32', config.target_triple):
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
108 llc_args = [' -mtriple=' +
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
109 config.target_triple.replace('-win32', '-mingw32')]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
110
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
111 # Provide the path to asan runtime lib if available. On darwin, this lib needs
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
112 # to be loaded via DYLD_INSERT_LIBRARIES before libLTO.dylib in case the files
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
113 # to be linked contain instrumented sanitizer code.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
114 ld64_cmd = config.ld64_executable
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
115 asan_rtlib = get_asan_rtlib()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
116 if asan_rtlib:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
117 ld64_cmd = 'DYLD_INSERT_LIBRARIES={} {}'.format(asan_rtlib, ld64_cmd)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
118
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
119 ocamlc_command = '%s ocamlc -cclib -L%s %s' % (
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
120 config.ocamlfind_executable, config.llvm_lib_dir, config.ocaml_flags)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
121 ocamlopt_command = 'true'
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
122 if config.have_ocamlopt:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
123 ocamlopt_command = '%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s' % (
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
124 config.ocamlfind_executable, config.llvm_lib_dir, config.llvm_lib_dir, config.ocaml_flags)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
125
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
126
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
127 tools = [
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
128 ToolSubst('%lli', FindTool('lli'), post='.', extra_args=lli_args),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
129 ToolSubst('%llc_dwarf', FindTool('llc'), extra_args=llc_args),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
130 ToolSubst('%go', config.go_executable, unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
131 ToolSubst('%gold', config.gold_executable, unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
132 ToolSubst('%ld64', ld64_cmd, unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
133 ToolSubst('%ocamlc', ocamlc_command, unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
134 ToolSubst('%ocamlopt', ocamlopt_command, unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
135 ]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
136
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
137 # FIXME: Why do we have both `lli` and `%lli` that do slightly different things?
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
138 tools.extend([
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
139 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as', 'llvm-bcanalyzer', 'llvm-config', 'llvm-cov',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
140 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis', 'llvm-dsymutil',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
141 'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-lib',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
142 'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mcmarkup',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
143 'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
144 'llvm-pdbutil', 'llvm-profdata', 'llvm-ranlib', 'llvm-readobj',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
145 'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings', 'llvm-tblgen',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
146 'llvm-c-test', 'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
147 'yaml-bench', 'verify-uselistorder',
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
148 'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'])
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
149
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
150 # The following tools are optional
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
151 tools.extend([
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
152 ToolSubst('llvm-go', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
153 ToolSubst('llvm-mt', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
154 ToolSubst('Kaleidoscope-Ch3', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
155 ToolSubst('Kaleidoscope-Ch4', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
156 ToolSubst('Kaleidoscope-Ch5', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
157 ToolSubst('Kaleidoscope-Ch6', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
158 ToolSubst('Kaleidoscope-Ch7', unresolved='ignore'),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
159 ToolSubst('Kaleidoscope-Ch8', unresolved='ignore')])
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
160
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
161 llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
162
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
163 # Targets
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
164
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
165 config.targets = frozenset(config.targets_to_build.split())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
166
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
167 for arch in config.targets_to_build.split():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
168 config.available_features.add(arch.lower() + '-registered-target')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
169
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
170 # Features
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
171
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
172 # Others/can-execute.txt
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
173 if sys.platform not in ['win32']:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
174 config.available_features.add('can-execute')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
175 config.available_features.add('not_COFF')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
176
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
177 # Loadable module
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
178 # FIXME: This should be supplied by Makefile or autoconf.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
179 if sys.platform in ['win32', 'cygwin']:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
180 loadable_module = (config.enable_shared == 1)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
181 else:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
182 loadable_module = True
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
183
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
184 if loadable_module:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
185 config.available_features.add('loadable_module')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
186
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
187 # Static libraries are not built if BUILD_SHARED_LIBS is ON.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
188 if not config.build_shared_libs and not config.link_llvm_dylib:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
189 config.available_features.add('static-libs')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
190
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
191 # Direct object generation
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
192 if not 'hexagon' in config.target_triple:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
193 config.available_features.add('object-emission')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
194
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
195 # LLVM can be configured with an empty default triple
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
196 # Some tests are "generic" and require a valid default triple
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
197 if config.target_triple:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
198 config.available_features.add('default_triple')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
199
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
200 import subprocess
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
201
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
202
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
203 def have_ld_plugin_support():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
204 if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
205 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
206
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
207 ld_cmd = subprocess.Popen(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
208 [config.gold_executable, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
209 ld_out = ld_cmd.stdout.read().decode()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
210 ld_cmd.wait()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
211
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
212 if not '-plugin' in ld_out:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
213 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
214
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
215 # check that the used emulations are supported.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
216 emu_line = [l for l in ld_out.split('\n') if 'supported emulations' in l]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
217 if len(emu_line) != 1:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
218 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
219 emu_line = emu_line[0]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
220 fields = emu_line.split(':')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
221 if len(fields) != 3:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
222 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
223 emulations = fields[2].split()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
224 if 'elf_x86_64' not in emulations:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
225 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
226 if 'elf32ppc' in emulations:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
227 config.available_features.add('ld_emu_elf32ppc')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
228
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
229 ld_version = subprocess.Popen(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
230 [config.gold_executable, '--version'], stdout=subprocess.PIPE, env={'LANG': 'C'})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
231 if not 'GNU gold' in ld_version.stdout.read().decode():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
232 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
233 ld_version.wait()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
234
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
235 return True
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
236
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
237
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
238 if have_ld_plugin_support():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
239 config.available_features.add('ld_plugin')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
240
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
241
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
242 def have_ld64_plugin_support():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
243 if not config.llvm_tool_lto_build or config.ld64_executable == '':
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
244 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
245
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
246 ld_cmd = subprocess.Popen(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
247 [config.ld64_executable, '-v'], stderr=subprocess.PIPE)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
248 ld_out = ld_cmd.stderr.read().decode()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
249 ld_cmd.wait()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
250
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
251 if 'ld64' not in ld_out or 'LTO' not in ld_out:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
252 return False
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
253
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
254 return True
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
255
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
256
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
257 if have_ld64_plugin_support():
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
258 config.available_features.add('ld64_plugin')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
259
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
260 # Ask llvm-config about asserts and global-isel.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
261 llvm_config.feature_config(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
262 [('--assertion-mode', {'ON': 'asserts'}),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
263 ('--has-global-isel', {'ON': 'global-isel'})])
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
264
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
265 if 'darwin' == sys.platform:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
266 try:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
267 sysctl_cmd = subprocess.Popen(['sysctl', 'hw.optional.fma'],
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
268 stdout=subprocess.PIPE)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
269 except OSError:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
270 print('Could not exec sysctl')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
271 result = sysctl_cmd.stdout.read().decode('ascii')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
272 if -1 != result.find('hw.optional.fma: 1'):
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
273 config.available_features.add('fma3')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
274 sysctl_cmd.wait()
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
275
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
276 # .debug_frame is not emitted for targeting Windows x64.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
277 if not re.match(r'^x86_64.*-(mingw32|windows-gnu|win32)', config.target_triple):
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
278 config.available_features.add('debug_frame')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
279
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
280 if config.have_libxar:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
281 config.available_features.add('xar')
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
282
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
283 if config.llvm_libxml2_enabled == '1':
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
284 config.available_features.add('libxml2')