1import("//compiler-rt/target.gni") 2import("//compiler-rt/test/test.gni") 3import("//llvm/utils/gn/build/toolchain/compiler.gni") 4import("//llvm/utils/gn/build/write_cmake_config.gni") 5import("//llvm/version.gni") 6 7write_cmake_config("lit_site_cfg") { 8 input = "lit.site.cfg.py.in" 9 output = "$target_gen_dir/lit.site.cfg.py" 10 11 values = [ 12 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit", 13 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", 17 18 "COMPILER_RT_BINARY_DIR=" + rebase_path("$root_gen_dir/compiler-rt"), 19 "HWASAN_LIT_SOURCE_DIR=" + rebase_path("."), 20 ] 21 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 } 29} 30 31if (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 ] 43 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 } 54} 55 56supported_toolchains = [] 57if (host_os == "linux" && host_cpu == "x64") { 58 supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ] 59} 60if (android_ndk_path != "") { 61 supported_toolchains += 62 [ "//llvm/utils/gn/build/toolchain:stage2_android_aarch64" ] 63} 64 65group("hwasan") { 66 deps = [] 67 foreach(toolchain, supported_toolchains) { 68 deps += [ ":hwasan_toolchain($toolchain)" ] 69 } 70} 71 72if (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 = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs 85 # it each time. 86 87 # Since check-hwasan is always dirty, //:default doesn't depend on it so that 88 # it's not part of the default ninja target. Hence, check-hwasan shouldn't 89 # have any deps except :hwasan. so that the default target is sure to build 90 # all the deps. 91 deps = [ ":hwasan" ] 92 testonly = true 93 94 pool = "//:console" 95 } 96} 97