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