5 config
.name
= "libFuzzer" + config
.name_suffix
6 config
.test_format
= lit
.formats
.ShTest(True)
7 config
.suffixes
= ['.test']
8 config
.test_source_root
= os
.path
.dirname(__file__
)
9 config
.available_features
.add(config
.target_arch
)
10 lit_config
.note(f
'arch feature "{config.target_arch}" available')
12 # Choose between lit's internal shell pipeline runner and a real shell. If
13 # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
14 use_lit_shell
= os
.environ
.get("LIT_USE_INTERNAL_SHELL")
16 # 0 is external, "" is default, and everything else is internal.
17 execute_external
= (use_lit_shell
== "0")
19 # Otherwise we default to internal on Windows and external elsewhere, as
20 # bash on Windows is usually very slow.
21 execute_external
= (not sys
.platform
in ['win32'])
23 # testFormat: The test format to use to interpret tests.
25 # For now we require '&&' between commands, until they get globally killed and
26 # the test runner updated.
27 config
.test_format
= lit
.formats
.ShTest(execute_external
)
29 # LeakSanitizer is not supported on OSX or Windows right now.
30 if (sys
.platform
.startswith('darwin') or
31 sys
.platform
.startswith('freebsd') or
32 sys
.platform
.startswith('win')):
33 lit_config
.note('lsan feature unavailable')
35 lit_config
.note('lsan feature available')
36 config
.available_features
.add('lsan')
38 # MemorySanitizer is not supported on OSX or Windows right now
39 if (sys
.platform
.startswith('darwin') or sys
.platform
.startswith('win') or
40 config
.target_arch
== 'i386'):
41 lit_config
.note('msan feature unavailable')
42 assert 'msan' not in config
.available_features
44 lit_config
.note('msan feature available')
45 config
.available_features
.add('msan')
47 if sys
.platform
.startswith('win') or sys
.platform
.startswith('cygwin'):
48 config
.available_features
.add('windows')
50 if sys
.platform
.startswith('darwin'):
51 config
.available_features
.add('darwin')
53 if sys
.platform
.startswith('linux'):
54 # Note the value of ``sys.platform`` is not consistent
55 # between python 2 and 3, hence the use of ``.startswith()``.
56 lit_config
.note('linux feature available')
57 config
.available_features
.add('linux')
59 lit_config
.note('linux feature unavailable')
62 config
.available_features
.add('thumb')
64 config
.substitutions
.append(('%build_dir', config
.cmake_binary_dir
))
65 libfuzzer_src_root
= os
.path
.join(config
.compiler_rt_src_root
, "lib", "fuzzer")
66 config
.substitutions
.append(('%libfuzzer_src', libfuzzer_src_root
))
68 config
.substitutions
.append(('%python', '"%s"' % (sys
.executable
)))
70 def generate_compiler_cmd(is_cpp
=True, fuzzer_enabled
=True, msan_enabled
=False):
71 compiler_cmd
= config
.clang
72 extra_cmd
= config
.target_flags
75 std_cmd
= '--driver-mode=g++'
80 sanitizers
= ['memory']
82 sanitizers
= ['address']
84 sanitizers
.append('fuzzer')
85 sanitizers_cmd
= ('-fsanitize=%s' % ','.join(sanitizers
))
89 "-O2 -gline-tables-only",
91 "-I%s" % libfuzzer_src_root
,
95 config
.substitutions
.append(('%cpp_compiler',
96 generate_compiler_cmd(is_cpp
=True, fuzzer_enabled
=True)
99 config
.substitutions
.append(('%c_compiler',
100 generate_compiler_cmd(is_cpp
=False, fuzzer_enabled
=True)
103 config
.substitutions
.append(('%no_fuzzer_cpp_compiler',
104 generate_compiler_cmd(is_cpp
=True, fuzzer_enabled
=False)
107 config
.substitutions
.append(('%no_fuzzer_c_compiler',
108 generate_compiler_cmd(is_cpp
=False, fuzzer_enabled
=False)
111 config
.substitutions
.append(('%msan_compiler',
112 generate_compiler_cmd(is_cpp
=True, fuzzer_enabled
=True, msan_enabled
=True)
115 default_asan_opts_str
= ':'.join(config
.default_sanitizer_opts
)
116 if default_asan_opts_str
:
117 config
.environment
['ASAN_OPTIONS'] = default_asan_opts_str
118 default_asan_opts_str
+= ':'
119 config
.substitutions
.append(('%env_asan_opts=',
120 'env ASAN_OPTIONS=' + default_asan_opts_str
))
122 if not config
.parallelism_group
:
123 config
.parallelism_group
= 'shadow-memory'
125 if config
.host_os
== 'NetBSD':
126 config
.substitutions
.insert(0, ('%run', config
.netbsd_noaslr_prefix
))