| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 declare_args() { | 5 if (current_toolchain == default_toolchain) { |
| 6 # Compile for Address Sanitizer to find memory bugs. | 6 declare_args() { |
| 7 # Compile for Address Sanitizer to find memory bugs. |
| 8 is_asan = false |
| 9 |
| 10 # Compile for Leak Sanitizer to find leaks. |
| 11 is_lsan = false |
| 12 |
| 13 # Compile for Memory Sanitizer to find uninitialized reads. |
| 14 is_msan = false |
| 15 |
| 16 # Compile for Thread Sanitizer to find threading bugs. |
| 17 is_tsan = false |
| 18 |
| 19 # Compile for Undefined Behaviour Sanitizer to find various types of |
| 20 # undefined behaviour (excludes vptr checks). |
| 21 is_ubsan = false |
| 22 |
| 23 # Halt the program if a problem is detected. |
| 24 is_ubsan_no_recover = false |
| 25 |
| 26 # Compile for Undefined Behaviour Sanitizer's null pointer checks. |
| 27 is_ubsan_null = false |
| 28 |
| 29 # Compile for Undefined Behaviour Sanitizer's vptr checks. |
| 30 is_ubsan_vptr = false |
| 31 |
| 32 # Track where uninitialized memory originates from. From fastest to slowest: |
| 33 # 0 - no tracking, 1 - track only the initial allocation site, 2 - track the |
| 34 # chain of stores leading from allocation site to use site. |
| 35 msan_track_origins = 2 |
| 36 |
| 37 # Use dynamic libraries instrumented by one of the sanitizers instead of the |
| 38 # standard system libraries. Set this flag to download prebuilt binaries |
| 39 # from GCS. |
| 40 use_prebuilt_instrumented_libraries = false |
| 41 |
| 42 # Use dynamic libraries instrumented by one of the sanitizers instead of the |
| 43 # standard system libraries. Set this flag to build the libraries from |
| 44 # source. |
| 45 use_locally_built_instrumented_libraries = false |
| 46 |
| 47 # Enable building with SyzyAsan which can find certain types of memory |
| 48 # errors. Only works on Windows. See |
| 49 # https://github.com/google/syzygy/wiki/SyzyASanHowTo |
| 50 is_syzyasan = false |
| 51 |
| 52 # Compile with Control Flow Integrity to protect virtual calls and casts. |
| 53 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html |
| 54 # |
| 55 # TODO(pcc): Remove this flag if/when CFI is enabled in official builds. |
| 56 is_cfi = false |
| 57 |
| 58 # Enable checks for bad casts: derived cast and unrelated cast. |
| 59 # TODO(krasin): remove this when we're ready to add these checks by default. |
| 60 # https://crbug.com/626794 |
| 61 use_cfi_cast = false |
| 62 |
| 63 # By default, Control Flow Integrity will crash the program if it detects a |
| 64 # violation. Set this to true to print detailed diagnostics instead. |
| 65 use_cfi_diag = false |
| 66 |
| 67 # Compile for fuzzing with LLVM LibFuzzer. |
| 68 # See http://www.chromium.org/developers/testing/libfuzzer |
| 69 use_libfuzzer = false |
| 70 |
| 71 # Compile for fuzzing with AFL. |
| 72 use_afl = false |
| 73 |
| 74 # Enables core ubsan security features. Will later be removed once it |
| 75 # matches is_ubsan. |
| 76 is_ubsan_security = false |
| 77 |
| 78 # Compile for fuzzing with Dr. Fuzz |
| 79 # See http://www.chromium.org/developers/testing/dr-fuzz |
| 80 use_drfuzz = false |
| 81 |
| 82 # Helper variable for testing builds with disabled libfuzzer. |
| 83 # Not for client use. |
| 84 disable_libfuzzer = false |
| 85 |
| 86 # Value for -fsanitize-coverage flag. Setting this causes |
| 87 # use_sanitizer_coverage to be enabled. |
| 88 # Default value when unset and use_afl=true: |
| 89 # trace-pc |
| 90 # Default value when unset and use_sanitizer_coverage=true: |
| 91 # edge,indirect-calls,8bit-counters |
| 92 sanitizer_coverage_flags = "" |
| 93 } |
| 94 |
| 95 # Args that are in turn dependent on other args must be in a separate |
| 96 # declare_args block. User overrides are only applied at the end of a |
| 97 # declare_args block. |
| 98 declare_args() { |
| 99 # Use libc++ (buildtools/third_party/libc++ and |
| 100 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard |
| 101 # library. This is intended to be used for instrumented builds. |
| 102 use_custom_libcxx = |
| 103 (is_asan && is_linux && !is_chromeos) || is_tsan || is_msan || |
| 104 is_ubsan || is_ubsan_security || use_libfuzzer || use_afl |
| 105 |
| 106 # Enable -fsanitize-coverage. |
| 107 use_sanitizer_coverage = |
| 108 use_libfuzzer || use_afl || sanitizer_coverage_flags != "" |
| 109 |
| 110 # Detect overflow/underflow for global objects. |
| 111 # |
| 112 # Android build relies on -Wl,--gc-sections removing unreachable code. |
| 113 # ASan instrumentation for globals inhibits this and results in a |
| 114 # library with unresolvable relocations. |
| 115 # TODO(eugenis): find a way to reenable this. |
| 116 # |
| 117 # Mac: http://crbug.com/352073 |
| 118 asan_globals = !is_android && !is_mac |
| 119 } |
| 120 } else { |
| 121 # Disable sanitizers for non-default toolchains. |
| 7 is_asan = false | 122 is_asan = false |
| 8 | |
| 9 # Compile for Leak Sanitizer to find leaks. | |
| 10 is_lsan = false | |
| 11 | |
| 12 # Compile for Memory Sanitizer to find uninitialized reads. | |
| 13 is_msan = false | |
| 14 | |
| 15 # Compile for Thread Sanitizer to find threading bugs. | |
| 16 is_tsan = false | |
| 17 | |
| 18 # Compile for Undefined Behaviour Sanitizer to find various types of | |
| 19 # undefined behaviour (excludes vptr checks). | |
| 20 is_ubsan = false | |
| 21 | |
| 22 # Halt the program if a problem is detected. | |
| 23 is_ubsan_no_recover = false | |
| 24 | |
| 25 # Compile for Undefined Behaviour Sanitizer's null pointer checks. | |
| 26 is_ubsan_null = false | |
| 27 | |
| 28 # Compile for Undefined Behaviour Sanitizer's vptr checks. | |
| 29 is_ubsan_vptr = false | |
| 30 | |
| 31 # Track where uninitialized memory originates from. From fastest to slowest: | |
| 32 # 0 - no tracking, 1 - track only the initial allocation site, 2 - track the | |
| 33 # chain of stores leading from allocation site to use site. | |
| 34 msan_track_origins = 2 | |
| 35 | |
| 36 # Use dynamic libraries instrumented by one of the sanitizers instead of the | |
| 37 # standard system libraries. Set this flag to download prebuilt binaries from | |
| 38 # GCS. | |
| 39 use_prebuilt_instrumented_libraries = false | |
| 40 | |
| 41 # Use dynamic libraries instrumented by one of the sanitizers instead of the | |
| 42 # standard system libraries. Set this flag to build the libraries from source. | |
| 43 use_locally_built_instrumented_libraries = false | |
| 44 | |
| 45 # Enable building with SyzyAsan which can find certain types of memory | |
| 46 # errors. Only works on Windows. See | |
| 47 # https://github.com/google/syzygy/wiki/SyzyASanHowTo | |
| 48 is_syzyasan = false | |
| 49 | |
| 50 # Compile with Control Flow Integrity to protect virtual calls and casts. | |
| 51 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html | |
| 52 # | |
| 53 # TODO(pcc): Remove this flag if/when CFI is enabled in official builds. | |
| 54 is_cfi = false | |
| 55 | |
| 56 # Enable checks for bad casts: derived cast and unrelated cast. | |
| 57 # TODO(krasin): remove this, when we're ready to add these checks by default. | |
| 58 # https://crbug.com/626794 | |
| 59 use_cfi_cast = false | |
| 60 | |
| 61 # By default, Control Flow Integrity will crash the program if it detects a | |
| 62 # violation. Set this to true to print detailed diagnostics instead. | |
| 63 use_cfi_diag = false | |
| 64 | |
| 65 # Compile for fuzzing with LLVM LibFuzzer. | |
| 66 # See http://www.chromium.org/developers/testing/libfuzzer | |
| 67 use_libfuzzer = false | |
| 68 | |
| 69 # Compile for fuzzing with AFL. | |
| 70 use_afl = false | |
| 71 | |
| 72 # Enables core ubsan security features. Will later be removed once it matches | |
| 73 # is_ubsan. | |
| 74 is_ubsan_security = false | |
| 75 | |
| 76 # Compile for fuzzing with Dr. Fuzz | |
| 77 # See http://www.chromium.org/developers/testing/dr-fuzz | |
| 78 use_drfuzz = false | |
| 79 | |
| 80 # Helper variable for testing builds with disabled libfuzzer. | |
| 81 # Not for client use. | |
| 82 disable_libfuzzer = false | |
| 83 | |
| 84 # Value for -fsanitize-coverage flag. Setting this causes | |
| 85 # use_sanitizer_coverage to be enabled. | |
| 86 # Default value when unset and use_afl=true: | |
| 87 # trace-pc | |
| 88 # Default value when unset and use_sanitizer_coverage=true: | |
| 89 # edge,indirect-calls,8bit-counters | |
| 90 sanitizer_coverage_flags = "" | |
| 91 } | |
| 92 | |
| 93 # Disable sanitizers for non-default toolchains. | |
| 94 if (current_toolchain != default_toolchain) { | |
| 95 is_asan = false | |
| 96 is_cfi = false | |
| 97 is_lsan = false | 123 is_lsan = false |
| 98 is_msan = false | 124 is_msan = false |
| 99 is_syzyasan = false | 125 is_syzyasan = false |
| 100 is_tsan = false | 126 is_tsan = false |
| 101 is_ubsan = false | 127 is_ubsan = false |
| 128 is_ubsan_no_recover = false |
| 102 is_ubsan_null = false | 129 is_ubsan_null = false |
| 103 is_ubsan_no_recover = false | |
| 104 is_ubsan_security = false | |
| 105 is_ubsan_vptr = false | 130 is_ubsan_vptr = false |
| 106 msan_track_origins = 0 | 131 msan_track_origins = 0 |
| 107 sanitizer_coverage_flags = "" | |
| 108 use_cfi_diag = false | |
| 109 use_custom_libcxx = false | |
| 110 use_drfuzz = false | |
| 111 use_libfuzzer = false | |
| 112 use_prebuilt_instrumented_libraries = false | 132 use_prebuilt_instrumented_libraries = false |
| 113 use_locally_built_instrumented_libraries = false | 133 use_locally_built_instrumented_libraries = false |
| 134 is_cfi = false |
| 135 use_cfi_cast = false |
| 136 use_cfi_diag = false |
| 137 use_libfuzzer = false |
| 138 use_afl = false |
| 139 is_ubsan_security = false |
| 140 use_drfuzz = false |
| 141 disable_libfuzzer = false |
| 142 sanitizer_coverage_flags = "" |
| 143 use_custom_libcxx = false |
| 114 use_sanitizer_coverage = false | 144 use_sanitizer_coverage = false |
| 115 } | 145 } |
| 116 | 146 |
| 117 # Args that are in turn dependent on other args must be in a separate | |
| 118 # declare_args block. User overrides are only applied at the end of a | |
| 119 # declare_args block. | |
| 120 declare_args() { | |
| 121 # Use libc++ (buildtools/third_party/libc++ and | |
| 122 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library. | |
| 123 # This is intended to be used for instrumented builds. | |
| 124 use_custom_libcxx = | |
| 125 (is_asan && is_linux && !is_chromeos) || is_tsan || is_msan || is_ubsan || | |
| 126 is_ubsan_security || use_libfuzzer || use_afl | |
| 127 | |
| 128 # Enable -fsanitize-coverage. | |
| 129 use_sanitizer_coverage = | |
| 130 use_libfuzzer || use_afl || sanitizer_coverage_flags != "" | |
| 131 | |
| 132 # Detect overflow/underflow for global objects. | |
| 133 # | |
| 134 # Android build relies on -Wl,--gc-sections removing unreachable code. | |
| 135 # ASan instrumentation for globals inhibits this and results in a | |
| 136 # library with unresolvable relocations. | |
| 137 # TODO(eugenis): find a way to reenable this. | |
| 138 # | |
| 139 # Mac: http://crbug.com/352073 | |
| 140 asan_globals = !is_android && !is_mac | |
| 141 } | |
| 142 | |
| 143 if (use_afl && sanitizer_coverage_flags == "") { | 147 if (use_afl && sanitizer_coverage_flags == "") { |
| 144 sanitizer_coverage_flags = "trace-pc" | 148 sanitizer_coverage_flags = "trace-pc" |
| 145 } else if (use_sanitizer_coverage && sanitizer_coverage_flags == "") { | 149 } else if (use_sanitizer_coverage && sanitizer_coverage_flags == "") { |
| 146 sanitizer_coverage_flags = "edge,indirect-calls,8bit-counters" | 150 sanitizer_coverage_flags = "edge,indirect-calls,8bit-counters" |
| 147 } | 151 } |
| 148 | 152 |
| 149 using_sanitizer = | 153 using_sanitizer = |
| 150 is_asan || is_lsan || is_tsan || is_msan || is_ubsan || is_ubsan_null || | 154 is_asan || is_lsan || is_tsan || is_msan || is_ubsan || is_ubsan_null || |
| 151 is_ubsan_vptr || is_ubsan_security || use_sanitizer_coverage | 155 is_ubsan_vptr || is_ubsan_security || use_sanitizer_coverage |
| 152 | 156 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 167 # this condition. We may also be able to find another way to enable your case | 171 # this condition. We may also be able to find another way to enable your case |
| 168 # without having people accidentally get broken builds by compiling an | 172 # without having people accidentally get broken builds by compiling an |
| 169 # unsupported or unadvisable configurations. | 173 # unsupported or unadvisable configurations. |
| 170 # | 174 # |
| 171 # For one-off testing, just comment this assertion out. | 175 # For one-off testing, just comment this assertion out. |
| 172 assert(!is_debug || !(is_msan || is_ubsan || is_ubsan_null || is_ubsan_vptr), | 176 assert(!is_debug || !(is_msan || is_ubsan || is_ubsan_null || is_ubsan_vptr), |
| 173 "Sanitizers should generally be used in release (set is_debug=false).") | 177 "Sanitizers should generally be used in release (set is_debug=false).") |
| 174 | 178 |
| 175 assert(!is_msan || (is_linux && current_cpu == "x64"), | 179 assert(!is_msan || (is_linux && current_cpu == "x64"), |
| 176 "MSan currently only works on 64-bit Linux and ChromeOS builds.") | 180 "MSan currently only works on 64-bit Linux and ChromeOS builds.") |
| OLD | NEW |