• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- Python -*-
2
3import os
4
5# Setup config name.
6config.name = 'MemorySanitizer' + getattr(config, 'name_suffix', 'default')
7
8# Setup source root.
9config.test_source_root = os.path.dirname(__file__)
10
11# Setup default compiler flags used with -fsanitize=memory option.
12clang_msan_cflags = (["-fsanitize=memory",
13                      "-mno-omit-leaf-frame-pointer",
14                      "-fno-omit-frame-pointer",
15                      "-fno-optimize-sibling-calls"] +
16                      [config.target_cflags] +
17                      config.debug_info_flags)
18# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
19if config.host_os == 'FreeBSD':
20  clang_msan_cflags += ["-lexecinfo", "-fPIC"]
21# On SystemZ we need -mbackchain to make the fast unwinder work.
22if config.target_arch == 's390x':
23  clang_msan_cflags.append("-mbackchain")
24clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags
25
26# Flags for KMSAN invocation. This is C-only, we're not interested in C++.
27clang_kmsan_cflags = (["-fsanitize=kernel-memory"] +
28                      [config.target_cflags] +
29                      config.debug_info_flags)
30
31def build_invocation(compile_flags):
32  return " " + " ".join([config.clang] + compile_flags) + " "
33
34config.substitutions.append( ("%clang_msan ", build_invocation(clang_msan_cflags)) )
35config.substitutions.append( ("%clangxx_msan ", build_invocation(clang_msan_cxxflags)) )
36config.substitutions.append( ("%clang_kmsan ", build_invocation(clang_kmsan_cflags)) )
37
38# Default test suffixes.
39config.suffixes = ['.c', '.cpp']
40
41if config.host_os not in ['Linux', 'NetBSD', 'FreeBSD']:
42  config.unsupported = True
43
44# For mips64, mips64el we have forced store_context_size to 1 because these
45# archs use slow unwinder which is not async signal safe. Therefore we only
46# check the first frame since store_context size is 1.
47if config.host_arch in ['mips64', 'mips64el']:
48  config.substitutions.append( ('CHECK-%short-stack', 'CHECK-SHORT-STACK'))
49else:
50  config.substitutions.append( ('CHECK-%short-stack', 'CHECK-FULL-STACK'))
51
52if config.host_os == 'NetBSD':
53  config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
54