Debian Codegraph @

llvm/utils/gn/secondary/compiler-rt/test/lsan/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("asan_mode_cfg") {
9 input = "lit.site.cfg.py.in"
10 output =
11 "$target_gen_dir/${crt_current_target_arch}AsanConfig/lit.site.cfg.py"
12 values = [
13 "LSAN_LIT_SOURCE_DIR=" + rebase_path("."),
14 "LSAN_TEST_CONFIG_SUFFIX=$crt_current_target_suffix",
15 "LSAN_TEST_TARGET_CFLAGS=$target_flags_string",
16
17 # TODO(lgrey): Support standalone mode
18 "LSAN_LIT_TEST_MODE=AddressSanitizer",
19 "LSAN_TEST_TARGET_ARCH=$crt_current_target_arch",
20 "COMPILER_RT_BINARY_DIR=" + rebase_path("$root_gen_dir/compiler-rt"),
21 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
22 ]
23 }
24
25 if (current_toolchain != host_toolchain) {
26 group("lsan_toolchain") {
27 deps = [
28 ":asan_mode_cfg",
29 "//compiler-rt/include($host_toolchain)",
30 "//compiler-rt/lib/asan",
31 "//compiler-rt/lib/lsan:common_sources",
32 "//compiler-rt/lib/profile",
33 "//compiler-rt/test:lit_common_configured",
34 "//llvm/tools/llvm-readobj($host_toolchain)",
35 "//llvm/tools/llvm-symbolizer($host_toolchain)",
36 "//llvm/utils/FileCheck($host_toolchain)",
37 "//llvm/utils/count($host_toolchain)",
38 "//llvm/utils/llvm-lit($host_toolchain)",
39 "//llvm/utils/not($host_toolchain)",
40 ]
41 }
42 }
43
44 supported_toolchains = []
45 if (host_os == "linux" || host_os == "mac") {
46 supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
47 }
48
49 group("lsan") {
50 deps = []
51 foreach(toolchain, supported_toolchains) {
52 deps += [ ":lsan_toolchain($toolchain)" ]
53 }
54 }
55
56 if (supported_toolchains != []) {
57 action("check-lsan") {
58 script = "$root_build_dir/bin/llvm-lit"
59 args = [ "-sv" ]
60 foreach(toolchain, supported_toolchains) {
61 test_dir = rebase_path(
62 get_label_info(":lit_site_cfg($toolchain)", "target_gen_dir"),
63 root_build_dir)
64 args += [ test_dir + "/${crt_current_target_arch}AsanConfig" ]
65 }
66 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs
67 # it each time.
68
69 # Since check-lsan is always dirty, //:default doesn't depend on it so
70 # that it's not part of the default ninja target. Hence, check-lsan
71 # shouldn't have any deps except :lsan. so that the default target is
72 # sure to build all the deps.
73 deps = [ ":lsan" ]
74 testonly = true
75
76 pool = "//:console"
77 }
78 }