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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 # GCS. | 32 # GCS. |
33 use_prebuilt_instrumented_libraries = false | 33 use_prebuilt_instrumented_libraries = false |
34 | 34 |
35 # Enable building with SyzyAsan which can find certain types of memory | 35 # Enable building with SyzyAsan which can find certain types of memory |
36 # errors. Only works on Windows. See | 36 # errors. Only works on Windows. See |
37 # https://github.com/google/syzygy/wiki/SyzyASanHowTo | 37 # https://github.com/google/syzygy/wiki/SyzyASanHowTo |
38 is_syzyasan = false | 38 is_syzyasan = false |
39 | 39 |
40 # Compile with Control Flow Integrity to protect virtual calls and casts. | 40 # Compile with Control Flow Integrity to protect virtual calls and casts. |
41 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html | 41 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html |
| 42 # |
| 43 # TODO(pcc): Remove this flag if/when CFI is enabled in official builds. |
42 is_cfi = false | 44 is_cfi = false |
43 | 45 |
44 # 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 |
45 # violation. Set this to true to print detailed diagnostics instead. | 47 # violation. Set this to true to print detailed diagnostics instead. |
46 use_cfi_diag = false | 48 use_cfi_diag = false |
47 | 49 |
48 # Compile for fuzzing with LLVM LibFuzzer. | 50 # Compile for fuzzing with LLVM LibFuzzer. |
49 # See http://www.chromium.org/developers/testing/libfuzzer | 51 # See http://www.chromium.org/developers/testing/libfuzzer |
50 use_libfuzzer = false | 52 use_libfuzzer = false |
51 | 53 |
52 # Compile for fuzzing with Dr. Fuzz | 54 # Compile for fuzzing with Dr. Fuzz |
53 # See http://www.chromium.org/developers/testing/dr-fuzz | 55 # See http://www.chromium.org/developers/testing/dr-fuzz |
54 use_drfuzz = false | 56 use_drfuzz = false |
55 | 57 |
56 # Helper variable for testing builds with disabled libfuzzer. | 58 # Helper variable for testing builds with disabled libfuzzer. |
57 # Not for client use. | 59 # Not for client use. |
58 disable_libfuzzer = false | 60 disable_libfuzzer = false |
59 } | 61 } |
60 | 62 |
61 # Args that are in turn dependent on other args must be in a separate | 63 # Args that are in turn dependent on other args must be in a separate |
62 # declare_args block. User overrides are only applied at the end of a | 64 # declare_args block. User overrides are only applied at the end of a |
63 # declare_args block. | 65 # declare_args block. |
64 declare_args() { | 66 declare_args() { |
65 # Use libc++ (buildtools/third_party/libc++ and | 67 # Use libc++ (buildtools/third_party/libc++ and |
66 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library. | 68 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library. |
67 # This is intended to be used for instrumented builds. | 69 # This is intended to be used for instrumented builds. |
68 use_custom_libcxx = | 70 use_custom_libcxx = |
69 (is_asan && is_linux) || is_tsan || is_msan || is_ubsan || use_libfuzzer | 71 (is_asan && is_linux) || is_tsan || is_msan || is_ubsan || use_libfuzzer |
70 | 72 |
71 # Enable Link Time Optimization (output programs runs faster, | |
72 # but linking is up to 5-20x slower. | |
73 is_lto = is_cfi | |
74 | |
75 use_sanitizer_coverage = use_libfuzzer | 73 use_sanitizer_coverage = use_libfuzzer |
76 } | 74 } |
77 | 75 |
78 using_sanitizer = | 76 using_sanitizer = |
79 is_asan || is_lsan || is_tsan || is_msan || is_ubsan || is_ubsan_vptr | 77 is_asan || is_lsan || is_tsan || is_msan || is_ubsan || is_ubsan_vptr |
80 | 78 |
81 assert(!using_sanitizer || is_clang, | 79 assert(!using_sanitizer || is_clang, |
82 "Sanitizers (is_*san) require setting is_clang = true in 'gn args'") | 80 "Sanitizers (is_*san) require setting is_clang = true in 'gn args'") |
83 | 81 |
84 # MSan only links Chrome properly in release builds (brettw -- 9/1/2015). The | 82 # MSan only links Chrome properly in release builds (brettw -- 9/1/2015). The |
85 # same is possibly true for the other non-ASan sanitizers. But regardless of | 83 # same is possibly true for the other non-ASan sanitizers. But regardless of |
86 # whether it links, one would normally never run a sanitizer in debug mode. | 84 # whether it links, one would normally never run a sanitizer in debug mode. |
87 # Running in debug mode probably indicates you forgot to set the "is_debug = | 85 # Running in debug mode probably indicates you forgot to set the "is_debug = |
88 # false" flag in the build args. ASan seems to run fine in debug mode. | 86 # false" flag in the build args. ASan seems to run fine in debug mode. |
89 # | 87 # |
90 # If you find a use-case where you want to compile a sanitizer in debug mode | 88 # If you find a use-case where you want to compile a sanitizer in debug mode |
91 # and have verified it works, ask brettw and we can consider removing it from | 89 # and have verified it works, ask brettw and we can consider removing it from |
92 # this condition. We may also be able to find another way to enable your case | 90 # this condition. We may also be able to find another way to enable your case |
93 # without having people accidentally get broken builds by compiling an | 91 # without having people accidentally get broken builds by compiling an |
94 # unsupported or unadvisable configurations. | 92 # unsupported or unadvisable configurations. |
95 # | 93 # |
96 # For one-off testing, just comment this assertion out. | 94 # For one-off testing, just comment this assertion out. |
97 assert( | 95 assert( |
98 !is_debug || !(is_msan || is_lsan || is_tsan || is_ubsan || is_ubsan_vptr), | 96 !is_debug || !(is_msan || is_lsan || is_tsan || is_ubsan || is_ubsan_vptr), |
99 "Sanitizers should generally be used in release (set is_debug=false).") | 97 "Sanitizers should generally be used in release (set is_debug=false).") |
OLD | NEW |