Home | History | Annotate | Download | only in sanitizers
      1 # Copyright (C) 2017 The Android Open Source Project
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #      http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 
     15 import("//gn/standalone/android.gni")
     16 import("//gn/standalone/sanitizers/vars.gni")
     17 import("//gn/standalone/toolchain/llvm.gni")
     18 
     19 declare_args() {
     20   sanitizer_lib_base_name_ = ""
     21   if (is_asan || is_tsan || is_ubsan) {
     22     if (is_asan) {
     23       sanitizer_lib_base_name_ = "clang_rt.asan"
     24     }
     25     if (is_tsan) {
     26       sanitizer_lib_base_name_ = "clang_rt.tsan"
     27     }
     28     if (is_ubsan) {
     29       sanitizer_lib_base_name_ = "clang_rt.ubsan"
     30       if (is_android || is_linux) {
     31         sanitizer_lib_base_name_ += "_standalone"
     32       }
     33     }
     34   }
     35 }
     36 
     37 declare_args() {
     38   sanitizer_lib_dir = ""
     39   sanitizer_lib = ""
     40   sanitizer_lib_dir_is_static = false
     41   if (sanitizer_lib_base_name_ != "") {
     42     if (is_mac) {
     43       sanitizer_lib = "${sanitizer_lib_base_name_}_osx_dynamic"
     44       sanitizer_lib_dir = mac_clangrt_dir
     45     }
     46     if (is_linux) {
     47       sanitizer_lib = "lib${sanitizer_lib_base_name_}-x86_64.a"
     48       sanitizer_lib_dir_is_static = true
     49       sanitizer_lib_dir = linux_clangrt_dir
     50     }
     51     if (is_android) {
     52       sanitizer_lib = "${sanitizer_lib_base_name_}-${android_llvm_arch}-android"
     53       sanitizer_lib_dir = android_clangrt_dir
     54     }
     55   }
     56 }
     57 
     58 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan || is_ubsan
     59 assert(!using_sanitizer || is_clang, "is_*san requires is_clang=true'")
     60 assert(!is_msan || is_linux, "msan only supported on linux")
     61 assert(!is_tsan || (is_linux || is_mac), "tsan only supported on linux and mac")
     62