101 lines · plain
1import("//compiler-rt/target.gni")2import("//compiler-rt/test/test.gni")3import("//llvm/lib/Target/targets.gni")4import("//llvm/utils/gn/build/toolchain/compiler.gni")5import("//llvm/utils/gn/build/write_cmake_config.gni")6import("//llvm/version.gni")7 8write_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 34if (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_preinit",41 "//compiler-rt/lib/hwasan:hwasan_shared",42 "//compiler-rt/test:lit_common_configured",43 "//llvm/utils/FileCheck($host_toolchain)",44 "//llvm/utils/llvm-lit($host_toolchain)",45 "//llvm/utils/not($host_toolchain)",46 ]47 48 # FIXME: Make the host use the stage2 llvm-symbolizer as well, for49 # consistency. Currently lit.common.cfg sets up the sanitizer runtime to50 # look for llvm-symbolizer in llvm_tools_dir, and also looks there for51 # other tools which are built with the host toolchain.52 if (current_os == host_os && current_cpu == host_cpu) {53 deps += [ "//llvm/tools/llvm-symbolizer($host_toolchain)" ]54 } else {55 deps += [ "//llvm/tools/llvm-symbolizer" ]56 }57 }58}59 60supported_toolchains = []61if (host_os == "linux" && (host_cpu == "arm64" || host_cpu == "x64")) {62 supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]63}64if (llvm_build_AArch64 && android_ndk_path != "") {65 supported_toolchains +=66 [ "//llvm/utils/gn/build/toolchain:stage2_android_aarch64" ]67}68 69group("hwasan") {70 deps = [ "//compiler-rt/lib/hwasan/scripts:hwasan_symbolize" ]71 foreach(toolchain, supported_toolchains) {72 deps += [ ":hwasan_toolchain($toolchain)" ]73 }74}75 76if (supported_toolchains != []) {77 action("check-hwasan") {78 script = "$root_build_dir/bin/llvm-lit"79 if (host_os == "win") {80 script += ".py"81 }82 args = [ "-sv" ]83 foreach(toolchain, supported_toolchains) {84 args += [ rebase_path(85 get_label_info(":lit_site_cfg($toolchain)", "target_gen_dir"),86 root_build_dir) ]87 }88 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs89 # it each time.90 91 # Since check-hwasan is always dirty, //:default doesn't depend on it so92 # that it's not part of the default ninja target. Hence, check-hwasan93 # shouldn't have any deps except :hwasan. so that the default target is94 # sure to build all the deps.95 deps = [ ":hwasan" ]96 testonly = true97 98 pool = "//:console"99 }100}101