OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
6 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
7 import("//build/config/compiler/compiler.gni") | 7 import("//build/config/compiler/compiler.gni") |
8 import("//build/toolchain/ccache.gni") | 8 import("//build/toolchain/ccache.gni") |
9 | 9 |
10 if (current_cpu == "arm") { | 10 if (current_cpu == "arm") { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } else { | 137 } else { |
138 cflags += [ "-fstack-protector" ] | 138 cflags += [ "-fstack-protector" ] |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 # Linker warnings. | 142 # Linker warnings. |
143 if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) { | 143 if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) { |
144 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 | 144 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 |
145 ldflags += [ "-Wl,--fatal-warnings" ] | 145 ldflags += [ "-Wl,--fatal-warnings" ] |
146 } | 146 } |
147 | |
148 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, | |
149 # MemorySanitizer and non-official CFI builds. | |
150 if (using_sanitizer || (is_cfi && !is_official_build)) { | |
151 cflags += [ | |
152 "-fno-omit-frame-pointer", | |
153 "-gline-tables-only", | |
154 ] | |
155 } | |
156 if (is_asan) { | |
157 asan_blacklist_path = | |
158 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) | |
159 cflags += [ | |
160 "-fsanitize=address", | |
161 "-fsanitize-blacklist=$asan_blacklist_path", | |
162 ] | |
163 if (is_mac) { | |
164 cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073 | |
165 # TODO(GYP): deal with mac_bundles. | |
166 } | |
167 } | |
168 if (is_lsan) { | |
169 cflags += [ "-fsanitize=leak" ] | |
170 } | |
171 if (is_tsan) { | |
172 tsan_blacklist_path = | |
173 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) | |
174 cflags += [ | |
175 "-fsanitize=thread", | |
176 "-fsanitize-blacklist=$tsan_blacklist_path", | |
177 ] | |
178 } | |
179 if (is_msan) { | |
180 msan_blacklist_path = | |
181 rebase_path("//tools/msan/blacklist.txt", root_build_dir) | |
182 cflags += [ | |
183 "-fsanitize=memory", | |
184 "-fsanitize-memory-track-origins=$msan_track_origins", | |
185 "-fsanitize-blacklist=$msan_blacklist_path", | |
186 ] | |
187 } | |
188 if (is_cfi && !is_nacl) { | |
189 cfi_blacklist_path = | |
190 rebase_path("//tools/cfi/blacklist.txt", root_build_dir) | |
191 cflags += [ | |
192 "-flto", | |
193 "-fsanitize=cfi-vcall", | |
194 "-fsanitize=cfi-derived-cast", | |
195 "-fsanitize=cfi-unrelated-cast", | |
196 "-fsanitize-blacklist=$cfi_blacklist_path", | |
197 ] | |
198 ldflags += [ | |
199 "-flto", | |
200 "-fsanitize=cfi-vcall", | |
201 "-fsanitize=cfi-derived-cast", | |
202 "-fsanitize=cfi-unrelated-cast", | |
203 ] | |
204 | |
205 # Apply a lower LTO optimization level in non-official builds. | |
206 if (!is_official_build) { | |
207 if (is_linux) { | |
208 ldflags += [ "-Wl,-plugin-opt,O1" ] | |
209 } else if (is_mac) { | |
210 ldflags += [ "-Wl,-mllvm,-O1" ] | |
211 } | |
212 } | |
213 | |
214 # Work-around for http://openradar.appspot.com/20356002 | |
215 if (is_mac) { | |
216 ldflags += [ "-Wl,-all_load" ] | |
217 } | |
218 | |
219 # Without this flag, LTO produces a .text section that is larger | |
220 # than the maximum call displacement, preventing the linker from | |
221 # relocating calls (http://llvm.org/PR22999). | |
222 if (current_cpu == "arm") { | |
223 ldflags += [ "-Wl,-plugin-opt,-function-sections" ] | |
224 } | |
225 | |
226 if (use_cfi_diag) { | |
227 cflags += [ | |
228 "-fno-sanitize-trap=cfi", | |
229 "-fsanitize-recover=cfi", | |
230 ] | |
231 ldflags += [ | |
232 "-fno-sanitize-trap=cfi", | |
233 "-fsanitize-recover=cfi", | |
234 ] | |
235 } else { | |
236 defines += [ "CFI_ENFORCEMENT" ] | |
237 } | |
238 } | |
239 | |
240 if (use_custom_libcxx) { | |
241 cflags_cc += [ "-nostdinc++" ] | |
242 include_dirs = [ | |
243 "//buildtools/third_party/libc++/trunk/include", | |
244 "//buildtools/third_party/libc++abi/trunk/include", | |
245 ] | |
246 } | |
247 } | 147 } |
248 | 148 |
249 if (is_clang && is_debug) { | 149 if (is_clang && is_debug) { |
250 # Allow comparing the address of references and 'this' against 0 | 150 # Allow comparing the address of references and 'this' against 0 |
251 # in debug builds. Technically, these can never be null in | 151 # in debug builds. Technically, these can never be null in |
252 # well-defined C/C++ and Clang can optimize such checks away in | 152 # well-defined C/C++ and Clang can optimize such checks away in |
253 # release builds, but they may be used in asserts in debug builds. | 153 # release builds, but they may be used in asserts in debug builds. |
254 cflags_cc += [ | 154 cflags_cc += [ |
255 "-Wno-undefined-bool-conversion", | 155 "-Wno-undefined-bool-conversion", |
256 "-Wno-tautological-undefined-compare", | 156 "-Wno-tautological-undefined-compare", |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 if (symbol_level == 0) { | 1121 if (symbol_level == 0) { |
1222 configs = [ ":no_symbols" ] | 1122 configs = [ ":no_symbols" ] |
1223 } else if (symbol_level == 1) { | 1123 } else if (symbol_level == 1) { |
1224 configs = [ ":minimal_symbols" ] | 1124 configs = [ ":minimal_symbols" ] |
1225 } else if (symbol_level == 2) { | 1125 } else if (symbol_level == 2) { |
1226 configs = [ ":symbols" ] | 1126 configs = [ ":symbols" ] |
1227 } else { | 1127 } else { |
1228 assert(false) | 1128 assert(false) |
1229 } | 1129 } |
1230 } | 1130 } |
OLD | NEW |