[InstCombine] Signed saturation patterns
[llvm-complete.git] / utils / gn / secondary / compiler-rt / test / hwasan / BUILD.gn
blob37ad25ff428435d1d7aeed26e2ab66e12e754bb0
1 import("//compiler-rt/target.gni")
2 import("//compiler-rt/test/test.gni")
3 import("//llvm/utils/gn/build/toolchain/compiler.gni")
4 import("//llvm/utils/gn/build/write_cmake_config.gni")
5 import("//llvm/version.gni")
7 write_cmake_config("lit_site_cfg") {
8   input = "lit.site.cfg.py.in"
9   output = "$target_gen_dir/lit.site.cfg.py"
11   values = [
12     "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
14     "HWASAN_TEST_CONFIG_SUFFIX=$crt_current_target_suffix",
15     "HWASAN_TEST_TARGET_CFLAGS=$target_flags_string",
16     "HWASAN_TEST_TARGET_ARCH=$crt_current_target_arch",
18     "COMPILER_RT_BINARY_DIR=" + rebase_path("$root_gen_dir/compiler-rt"),
19     "HWASAN_LIT_SOURCE_DIR=" + rebase_path("."),
20   ]
22   if (current_os == "android") {
23     values += [ "HWASAN_ANDROID_FILES_TO_PUSH=[\"" + rebase_path(
24                     "$crt_current_out_dir/libclang_rt.hwasan$crt_current_target_suffix.so") + "\", \"" + rebase_path(
25                     "$root_out_dir/bin/llvm-symbolizer") + "\"]" ]
26   } else {
27     values += [ "HWASAN_ANDROID_FILES_TO_PUSH=[]" ]
28   }
31 if (current_toolchain != host_toolchain) {
32   group("hwasan_toolchain") {
33     deps = [
34       ":lit_site_cfg",
35       "//compiler-rt/include($host_toolchain)",
36       "//compiler-rt/lib/cfi:blacklist($host_toolchain)",
37       "//compiler-rt/lib/hwasan:hwasan_shared",
38       "//compiler-rt/test:lit_common_configured",
39       "//llvm/utils/FileCheck($host_toolchain)",
40       "//llvm/utils/llvm-lit($host_toolchain)",
41       "//llvm/utils/not($host_toolchain)",
42     ]
44     # FIXME: Make the host use the stage2 llvm-symbolizer as well, for
45     # consistency. Currently lit.common.cfg sets up the sanitizer runtime to
46     # look for llvm-symbolizer in llvm_tools_dir, and also looks there for
47     # other tools which are built with the host toolchain.
48     if (current_os == host_os && current_cpu == host_cpu) {
49       deps += [ "//llvm/tools/llvm-symbolizer($host_toolchain)" ]
50     } else {
51       deps += [ "//llvm/tools/llvm-symbolizer" ]
52     }
53   }
56 supported_toolchains = []
57 if (host_os == "linux" && host_cpu == "x64") {
58   supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
60 if (android_ndk_path != "") {
61   supported_toolchains +=
62       [ "//llvm/utils/gn/build/toolchain:stage2_android_aarch64" ]
65 group("hwasan") {
66   deps = []
67   foreach(toolchain, supported_toolchains) {
68     deps += [ ":hwasan_toolchain($toolchain)" ]
69   }
72 if (supported_toolchains != []) {
73   action("check-hwasan") {
74     script = "$root_build_dir/bin/llvm-lit"
75     if (host_os == "win") {
76       script += ".py"
77     }
78     args = [ "-sv" ]
79     foreach(toolchain, supported_toolchains) {
80       args += [ rebase_path(
81               get_label_info(":lit_site_cfg($toolchain)", "target_gen_dir"),
82               root_build_dir) ]
83     }
84     outputs = [
85       "$target_gen_dir/run-lit",  # Non-existing, so that ninja runs it each time.
86     ]
88     # Since check-hwasan is always dirty, //:default doesn't depend on it so that
89     # it's not part of the default ninja target.  Hence, check-hwasan shouldn't
90     # have any deps except :hwasan. so that the default target is sure to build
91     # all the deps.
92     deps = [
93       ":hwasan",
94     ]
95     testonly = true
97     pool = "//:console"
98   }