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 declare_args() { 16 # Address Sanitizer: memory bugs (e.g., UAF). 17 is_asan = false 18 19 # Leak Sanitizer: memory leaks. 20 is_lsan = false 21 22 # Memory Sanitizer: uninitialized reads. 23 is_msan = false 24 25 # Thread Sanitizer: threading bugs. 26 is_tsan = false 27 28 # Undefined Behaviour Sanitizer. 29 is_ubsan = false 30 31 # Compile for fuzzing. 32 is_fuzzer = false 33 34 # When enabled, only relevant sanitizer defines are set, but compilation 35 # happens with no extra flags. This is useful when in component build 36 # enabling sanitizers only in some of the components. 37 use_sanitizer_configs_without_instrumentation = false 38 } 39 40 declare_args() { 41 # Link in LLVM LibFuzzer. 42 use_libfuzzer = is_fuzzer 43 44 # If is_fuzzer=true and use_libfuzzer=false, add this flag to ldflags when 45 # linking fuzzer executables. 46 link_fuzzer = "" 47 } 48 49 declare_args() { 50 using_sanitizer = 51 is_asan || is_lsan || is_tsan || is_msan || is_ubsan || use_libfuzzer 52 } 53 54 assert(!using_sanitizer || is_clang || is_system_compiler, 55 "is_*san requires is_clang=true'") 56 assert(!is_msan || is_linux, "msan only supported on linux") 57 assert(!is_tsan || (is_linux || is_mac), "tsan only supported on linux and mac") 58 assert(!is_fuzzer || use_libfuzzer || link_fuzzer != "") 59