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 = "$target_gen_dir/${crt_current_target_arch}AsanConfig/lit.site.cfg.py"
11 values = [
12 "LSAN_LIT_SOURCE_DIR=" + rebase_path("."),
13 "LSAN_TEST_CONFIG_SUFFIX=$crt_current_target_suffix",
14 "LSAN_TEST_TARGET_CFLAGS=$target_flags_string",
15 # TODO(lgrey): Support standalone mode
16 "LSAN_LIT_TEST_MODE=AddressSanitizer",
17 "LSAN_TEST_TARGET_ARCH=$crt_current_target_arch",
18 "COMPILER_RT_BINARY_DIR=" + rebase_path("$root_gen_dir/compiler-rt"),
19 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
20 ]
21 }
22
23 if (current_toolchain != host_toolchain) {
24 group("lsan_toolchain") {
25 deps = [
26 ":asan_mode_cfg",
27 "//compiler-rt/include($host_toolchain)",
28 "//compiler-rt/lib/asan",
29 "//compiler-rt/lib/lsan:common_sources",
30 "//compiler-rt/lib/profile",
31 "//compiler-rt/test:lit_common_configured",
32 "//llvm/tools/llvm-readobj($host_toolchain)",
33 "//llvm/tools/llvm-symbolizer($host_toolchain)",
34 "//llvm/utils/FileCheck($host_toolchain)",
35 "//llvm/utils/count($host_toolchain)",
36 "//llvm/utils/llvm-lit($host_toolchain)",
37 "//llvm/utils/not($host_toolchain)",
38 ]
39 }
40 }
41
42 supported_toolchains = []
43 if (host_os == "linux" || host_os == "mac") {
44 supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
45 }
46
47 group("lsan") {
48 deps = []
49 foreach(toolchain, supported_toolchains) {
50 deps += [ ":lsan_toolchain($toolchain)" ]
51 }
52 }
53
54 if (supported_toolchains != []) {
55 action("check-lsan") {
56 script = "$root_build_dir/bin/llvm-lit"
57 args = [ "-sv" ]
58 foreach(toolchain, supported_toolchains) {
59 test_dir = rebase_path(
60 get_label_info(":lit_site_cfg($toolchain)", "target_gen_dir"),
61 root_build_dir)
62 args += [
63 test_dir + "/${crt_current_target_arch}AsanConfig",
64 ]
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 }