6 config
.name
= "GWP-ASan" + config
.name_suffix
9 config
.test_source_root
= os
.path
.dirname(__file__
)
12 config
.suffixes
= [".c", ".cpp", ".test"]
15 c_flags
= [config
.target_cflags
]
17 cxx_flags
= c_flags
+ config
.cxx_mode_flags
+ ["-std=c++14"]
19 libscudo_standalone
= os
.path
.join(
20 config
.compiler_rt_libdir
, "libclang_rt.scudo_standalone%s.a" % config
.target_suffix
22 libscudo_standalone_cxx
= os
.path
.join(
23 config
.compiler_rt_libdir
,
24 "libclang_rt.scudo_standalone_cxx%s.a" % config
.target_suffix
,
29 "-Wl,--whole-archive",
31 "-Wl,--no-whole-archive",
33 scudo_link_cxx_flags
= [
34 "-Wl,--whole-archive",
35 libscudo_standalone_cxx
,
36 "-Wl,--no-whole-archive",
39 # -rdynamic is necessary for online function symbolization.
40 gwp_asan_flags
= ["-rdynamic"] + scudo_link_flags
43 def build_invocation(compile_flags
):
44 return " " + " ".join([config
.clang
] + compile_flags
) + " "
48 config
.substitutions
.append(("%clang ", build_invocation(c_flags
)))
49 config
.substitutions
.append(
50 ("%clang_gwp_asan ", build_invocation(c_flags
+ gwp_asan_flags
))
52 config
.substitutions
.append(
55 build_invocation(cxx_flags
+ gwp_asan_flags
+ scudo_link_cxx_flags
),
59 # Platform-specific default GWP_ASAN for lit tests. Ensure that GWP-ASan is
60 # enabled and that it samples every allocation.
61 default_gwp_asan_options
= "GWP_ASAN_Enabled=1:GWP_ASAN_SampleRate=1"
63 config
.environment
["SCUDO_OPTIONS"] = default_gwp_asan_options
64 default_gwp_asan_options
+= ":"
65 config
.substitutions
.append(
66 ("%env_scudo_options=", "env SCUDO_OPTIONS=" + default_gwp_asan_options
)
69 # GWP-ASan tests are currently supported on Linux only.
70 if config
.host_os
not in ["Linux"]:
71 config
.unsupported
= True