[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / compiler-rt / test / hwasan / lit.cfg.py
blobbbf23e683240ac4aa3e83434ddfdac9ea3f52704
1 # -*- Python -*-
3 import os
5 from lit.llvm import llvm_config
6 from lit.llvm.subst import ToolSubst, FindTool
8 # Setup config name.
9 config.name = "HWAddressSanitizer" + getattr(config, "name_suffix", "default")
11 # Setup source root.
12 config.test_source_root = os.path.dirname(__file__)
14 # Setup default compiler flags used with -fsanitize=memory option.
15 clang_cflags = [config.target_cflags] + config.debug_info_flags
16 clang_cxxflags = config.cxx_mode_flags + clang_cflags
17 clang_hwasan_common_cflags = clang_cflags + ["-fsanitize=hwaddress", "-fuse-ld=lld"]
19 if config.target_arch == "x86_64" and config.enable_aliases != "0":
20 clang_hwasan_common_cflags += ["-fsanitize-hwaddress-experimental-aliasing"]
21 else:
22 config.available_features.add("pointer-tagging")
23 if config.target_arch == "x86_64":
24 # The callback instrumentation used on x86_64 has a 1/64 chance of choosing a
25 # stack tag of 0. This causes stack tests to become flaky, so we force tags
26 # to be generated via calls to __hwasan_generate_tag, which never returns 0.
27 # TODO: See if we can remove this once we use the outlined instrumentation.
28 clang_hwasan_common_cflags += ["-mllvm", "-hwasan-generate-tags-with-calls=1"]
29 clang_hwasan_cflags = clang_hwasan_common_cflags + [
30 "-mllvm",
31 "-hwasan-globals",
32 "-mllvm",
33 "-hwasan-use-short-granules",
34 "-mllvm",
35 "-hwasan-instrument-landing-pads=0",
36 "-mllvm",
37 "-hwasan-instrument-personality-functions",
39 clang_hwasan_oldrt_cflags = clang_hwasan_common_cflags + [
40 "-mllvm",
41 "-hwasan-use-short-granules=0",
42 "-mllvm",
43 "-hwasan-instrument-landing-pads=1",
44 "-mllvm",
45 "-hwasan-instrument-personality-functions=0",
48 clang_hwasan_cxxflags = config.cxx_mode_flags + clang_hwasan_cflags
49 clang_hwasan_oldrt_cxxflags = config.cxx_mode_flags + clang_hwasan_oldrt_cflags
52 def build_invocation(compile_flags):
53 return " " + " ".join([config.clang] + compile_flags) + " "
56 config.substitutions.append(("%clangxx ", build_invocation(clang_cxxflags)))
57 config.substitutions.append(("%clang_hwasan ", build_invocation(clang_hwasan_cflags)))
58 config.substitutions.append(
59 ("%clang_hwasan_oldrt ", build_invocation(clang_hwasan_oldrt_cflags))
61 config.substitutions.append(
62 ("%clangxx_hwasan ", build_invocation(clang_hwasan_cxxflags))
64 config.substitutions.append(
65 ("%clangxx_hwasan_oldrt ", build_invocation(clang_hwasan_oldrt_cxxflags))
67 config.substitutions.append(("%compiler_rt_libdir", config.compiler_rt_libdir))
69 default_hwasan_opts_str = ":".join(
70 ["disable_allocator_tagging=1", "random_tags=0", "fail_without_syscall_abi=0"]
71 + config.default_sanitizer_opts
73 if default_hwasan_opts_str:
74 config.environment["HWASAN_OPTIONS"] = default_hwasan_opts_str
75 default_hwasan_opts_str += ":"
76 config.substitutions.append(
77 ("%env_hwasan_opts=", "env HWASAN_OPTIONS=" + default_hwasan_opts_str)
80 # Ensure that we can use hwasan_symbolize from the expected location
81 llvm_config.add_tool_substitutions(
82 [ToolSubst("hwasan_symbolize", unresolved="fatal")],
83 search_dirs=[config.compiler_rt_bindir],
86 # Default test suffixes.
87 config.suffixes = [".c", ".cpp"]
89 if config.host_os not in ["Linux", "Android"] or not config.has_lld:
90 config.unsupported = True