6 def get_required_attr(config
, attr_name
):
7 attr_value
= getattr(config
, attr_name
, None)
10 "No attribute %r in test configuration! You may need to run "
11 "tests from your build directory or add this attribute "
12 "to lit.site.cfg.py " % attr_name
18 config
.test_source_root
= os
.path
.dirname(__file__
)
19 config
.name
= "UBSan-Minimal-" + config
.target_arch
22 def build_invocation(compile_flags
):
23 return " " + " ".join([config
.clang
] + compile_flags
) + " "
26 target_cflags
= [get_required_attr(config
, "target_cflags")]
27 clang_ubsan_cflags
= ["-fsanitize-minimal-runtime"] + target_cflags
28 clang_ubsan_cxxflags
= config
.cxx_mode_flags
+ clang_ubsan_cflags
30 # Define %clang and %clangxx substitutions to use in test RUN lines.
31 config
.substitutions
.append(("%clang ", build_invocation(clang_ubsan_cflags
)))
32 config
.substitutions
.append(("%clangxx ", build_invocation(clang_ubsan_cxxflags
)))
34 # Default test suffixes.
35 config
.suffixes
= [".c", ".cpp"]
37 # Check that the host supports UndefinedBehaviorSanitizerMinimal tests
38 if config
.host_os
not in [
46 config
.unsupported
= True
48 # Don't target x86_64h if the test machine can't execute x86_64h binaries.
49 if "-arch x86_64h" in target_cflags
and "x86_64h" not in config
.available_features
:
50 config
.unsupported
= True