Debian Codegraph @

llvm-project/llvm/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn

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