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 declare_args() { |
6 # Compile for Address Sanitizer to find memory bugs. | 6 # Compile for Address Sanitizer to find memory bugs. |
7 is_asan = false | 7 is_asan = false |
8 | 8 |
9 # Compile for Leak Sanitizer to find leaks. | 9 # Compile for Leak Sanitizer to find leaks. |
10 is_lsan = false | 10 is_lsan = false |
11 | 11 |
12 # Compile for Memory Sanitizer to find uninitialized reads. | 12 # Compile for Memory Sanitizer to find uninitialized reads. |
13 is_msan = false | 13 is_msan = false |
14 | 14 |
15 # Compile for Thread Sanitizer to find threading bugs. | 15 # Compile for Thread Sanitizer to find threading bugs. |
16 is_tsan = false | 16 is_tsan = false |
17 | 17 |
| 18 # Compile for Undefined Behaviour Sanitizer to find various types of |
| 19 # undefined behaviour. |
| 20 is_ubsan = false |
| 21 |
18 # Use libc++ (buildtools/third_party/libc++ and | 22 # Use libc++ (buildtools/third_party/libc++ and |
19 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library. | 23 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library. |
20 # This is intended to be used for instrumented builds. | 24 # This is intended to be used for instrumented builds. |
21 use_custom_libcxx = (is_asan && is_linux) || is_tsan || is_msan | 25 use_custom_libcxx = (is_asan && is_linux) || is_tsan || is_msan || is_ubsan |
22 | 26 |
23 # Track where uninitialized memory originates from. From fastest to slowest: | 27 # Track where uninitialized memory originates from. From fastest to slowest: |
24 # 0 - no tracking, 1 - track only the initial allocation site, 2 - track the | 28 # 0 - no tracking, 1 - track only the initial allocation site, 2 - track the |
25 # chain of stores leading from allocation site to use site. | 29 # chain of stores leading from allocation site to use site. |
26 msan_track_origins = 2 | 30 msan_track_origins = 2 |
27 | 31 |
28 # Use dynamic libraries instrumented by one of the sanitizers instead of the | 32 # Use dynamic libraries instrumented by one of the sanitizers instead of the |
29 # standard system libraries. Set this flag to download prebuilt binaries from | 33 # standard system libraries. Set this flag to download prebuilt binaries from |
30 # GCS. | 34 # GCS. |
31 use_prebuilt_instrumented_libraries = false | 35 use_prebuilt_instrumented_libraries = false |
32 | 36 |
33 # Enable building with SyzyAsan which can find certain types of memory | 37 # Enable building with SyzyAsan which can find certain types of memory |
34 # errors. Only works on Windows. See | 38 # errors. Only works on Windows. See |
35 # https://code.google.com/p/sawbuck/wiki/SyzyASanHowTo | 39 # https://code.google.com/p/sawbuck/wiki/SyzyASanHowTo |
36 is_syzyasan = false | 40 is_syzyasan = false |
37 | 41 |
38 # Compile with Control Flow Integrity to protect virtual calls and casts. | 42 # Compile with Control Flow Integrity to protect virtual calls and casts. |
39 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html | 43 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html |
40 is_cfi = false | 44 is_cfi = false |
41 | 45 |
42 # By default, Control Flow Integrity will crash the program if it detects a | 46 # By default, Control Flow Integrity will crash the program if it detects a |
43 # violation. Set this to true to print detailed diagnostics instead. | 47 # violation. Set this to true to print detailed diagnostics instead. |
44 use_cfi_diag = false | 48 use_cfi_diag = false |
45 } | 49 } |
46 | 50 |
47 # TODO(GYP) bug 527515: is_ubsan, is_ubsan_vptr | 51 # TODO(GYP) bug 527515: is_ubsan, is_ubsan_vptr |
48 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan | 52 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan || is_ubsan |
49 | 53 |
50 assert(!using_sanitizer || is_clang, | 54 assert(!using_sanitizer || is_clang, |
51 "Sanitizers (is_*san) require setting is_clang = true in 'gn args'") | 55 "Sanitizers (is_*san) require setting is_clang = true in 'gn args'") |
52 | 56 |
53 # MSan only links Chrome properly in release builds (brettw -- 9/1/2015). The | 57 # MSan only links Chrome properly in release builds (brettw -- 9/1/2015). The |
54 # same is possibly true for the other non-ASan sanitizers. But regardless of | 58 # same is possibly true for the other non-ASan sanitizers. But regardless of |
55 # whether it links, one would normally never run a sanitizer in debug mode. | 59 # whether it links, one would normally never run a sanitizer in debug mode. |
56 # Running in debug mode probably indicates you forgot to set the "is_debug = | 60 # Running in debug mode probably indicates you forgot to set the "is_debug = |
57 # false" flag in the build args. ASan seems to run fine in debug mode. | 61 # false" flag in the build args. ASan seems to run fine in debug mode. |
58 # | 62 # |
59 # If you find a use-case where you want to compile a sanitizer in debug mode | 63 # If you find a use-case where you want to compile a sanitizer in debug mode |
60 # and have verified it works, ask brettw and we can consider removing it from | 64 # and have verified it works, ask brettw and we can consider removing it from |
61 # this condition. We may also be able to find another way to enable your case | 65 # this condition. We may also be able to find another way to enable your case |
62 # without having people accidentally get broken builds by compiling an | 66 # without having people accidentally get broken builds by compiling an |
63 # unsupported or unadvisable configurations. | 67 # unsupported or unadvisable configurations. |
64 # | 68 # |
65 # For one-off testing, just comment this assertion out. | 69 # For one-off testing, just comment this assertion out. |
66 assert(!is_debug || !(is_msan || is_lsan || is_tsan), | 70 assert(!is_debug || !(is_msan || is_lsan || is_tsan || is_ubsan), |
67 "Sanitizers should generally be used in release (set is_debug=false).") | 71 "Sanitizers should generally be used in release (set is_debug=false).") |
OLD | NEW |