llvm-project

Форк
0
74 строки · 3.0 Кб
1
# -*- Python -*-
2

3
import os
4
import platform
5
import re
6

7
import lit.formats
8

9
def get_required_attr(config, attr_name):
10
  attr_value = getattr(config, attr_name, None)
11
  if attr_value is None:
12
    lit_config.fatal(
13
      'No attribute %r in test configuration! You may need to run '
14
      'tests from your build directory or add this attribute '
15
      'to lit.site.cfg.py ' % attr_name)
16
  return attr_value
17

18
# Setup config name.
19
config.name = 'AddressSanitizerABI' + config.name_suffix
20

21
# Platform-specific default ASAN_ABI_OPTIONS for lit tests.
22
default_asan_abi_opts = list(config.default_sanitizer_opts)
23

24
default_asan_abi_opts_str = ':'.join(default_asan_abi_opts)
25
if default_asan_abi_opts_str:
26
  config.environment['ASAN_ABI_OPTIONS'] = default_asan_abi_opts_str
27
  default_asan_abi_opts_str += ':'
28
config.substitutions.append(('%env_asan_abi_opts=',
29
                             'env ASAN_ABI_OPTIONS=' + default_asan_abi_opts_str))
30

31
# Setup source root.
32
config.test_source_root = os.path.dirname(__file__)
33

34
# GCC-ASan doesn't link in all the necessary libraries automatically, so
35
# we have to do it ourselves.
36
extra_link_flags = []
37

38
# Setup default compiler flags used with -fsanitize=address option.
39
# FIXME: Review the set of required flags and check if it can be reduced.
40
target_cflags = [get_required_attr(config, 'target_cflags')] + extra_link_flags
41
target_cxxflags = config.cxx_mode_flags + target_cflags
42
clang_asan_abi_static_cflags = (['-fsanitize=address',
43
                            '-fsanitize-stable-abi',
44
                            '-mno-omit-leaf-frame-pointer',
45
                            '-fno-omit-frame-pointer',
46
                            '-fno-optimize-sibling-calls'] +
47
                            config.debug_info_flags + target_cflags)
48
clang_asan_abi_static_cxxflags = config.cxx_mode_flags + clang_asan_abi_static_cflags
49

50
config.available_features.add('asan_abi-static-runtime')
51
clang_asan_abi_cflags = clang_asan_abi_static_cflags
52
clang_asan_abi_cxxflags = clang_asan_abi_static_cxxflags
53

54
def build_invocation(compile_flags):
55
  return ' ' + ' '.join([config.clang] + compile_flags) + ' '
56

57
config.substitutions.append( ('%clang ', build_invocation(target_cflags)) )
58
config.substitutions.append( ('%clangxx ', build_invocation(target_cxxflags)) )
59
config.substitutions.append( ('%clang_asan_abi ', build_invocation(clang_asan_abi_cflags)) )
60
config.substitutions.append( ('%clangxx_asan_abi ', build_invocation(clang_asan_abi_cxxflags)) )
61

62
libasan_abi_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_abi_osx.a'.format(config.apple_platform))
63

64
if libasan_abi_path is not None:
65
  config.substitutions.append( ('%libasan_abi', libasan_abi_path) )
66
  config.substitutions.append( ('%clang_asan_abi_static ', build_invocation(clang_asan_abi_static_cflags)) )
67
  config.substitutions.append( ('%clangxx_asan_abi_static ', build_invocation(clang_asan_abi_static_cxxflags)) )
68

69
config.suffixes = ['.c', '.cpp']
70

71
if config.host_os == 'Darwin':
72
  config.suffixes.append('.mm')
73
else:
74
  config.unsupported = True
75

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.