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