[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / cfi / lit.cfg.py
blob2f2d1ddcaa7920e8de1dc298b605d7fc331177a6
1 import lit.formats
2 import os
4 config.name = 'cfi' + config.name_suffix
5 config.suffixes = ['.c', '.cpp', '.test']
6 config.test_source_root = os.path.dirname(__file__)
8 def build_invocation(compile_flags):
9 return " " + " ".join([config.clang] + compile_flags) + " "
11 clang = build_invocation([config.target_cflags])
12 clangxx = build_invocation([config.target_cflags] + config.cxx_mode_flags)
14 config.substitutions.append((r"%clang ", clang + ' '))
15 config.substitutions.append((r"%clangxx ", clangxx + ' '))
17 if 'darwin' in config.available_features:
18 # -fsanitize=cfi is not supported on Darwin hosts
19 config.unsupported = True
20 elif config.lto_supported:
21 clang_cfi = clang + '-fsanitize=cfi '
23 if config.cfi_lit_test_mode == "Devirt":
24 config.available_features.add('devirt')
25 clang_cfi += '-fwhole-program-vtables '
26 config.substitutions.append((r"%expect_crash_unless_devirt ", ""))
27 else:
28 config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash))
30 cxx = ' '.join(config.cxx_mode_flags) + ' '
31 diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi '
32 non_dso = '-fvisibility=hidden '
33 dso = '-fsanitize-cfi-cross-dso -fvisibility=default '
34 if config.android:
35 dso += '-include ' + config.test_source_root + '/cross-dso/util/cfi_stubs.h '
36 config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso))
37 config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso))
38 config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag))
39 config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag))
40 config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso))
41 config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag))
42 config.substitutions.append((r"%debug_info_flags", ' '.join(config.debug_info_flags)))
43 else:
44 config.unsupported = True
46 if config.default_sanitizer_opts:
47 config.environment['UBSAN_OPTIONS'] = ':'.join(config.default_sanitizer_opts)
49 if lit_config.params.get('check_supported', None) and config.unsupported:
50 raise BaseException("Tests unsupported")