Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: build/config/sanitizers/BUILD.gn

Issue 1917603002: third_party/mesa: turn off ubsan_vptr, since it's compiled without rtti. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/mesa/BUILD.gn » ('j') | third_party/mesa/README.chromium » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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/chrome_build.gni") 5 import("//build/config/chrome_build.gni")
6 import("//build/config/chromecast_build.gni") 6 import("//build/config/chromecast_build.gni")
7 import("//build/config/sanitizers/sanitizers.gni") 7 import("//build/config/sanitizers/sanitizers.gni")
8 8
9 # Contains the dependencies needed for sanitizers to link into executables and 9 # Contains the dependencies needed for sanitizers to link into executables and
10 # shared_libraries. Unconditionally depend upon this target as it is empty if 10 # shared_libraries. Unconditionally depend upon this target as it is empty if
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (use_cfi_diag) { 106 if (use_cfi_diag) {
107 ldflags += [ 107 ldflags += [
108 "-fno-sanitize-trap=cfi", 108 "-fno-sanitize-trap=cfi",
109 "-fsanitize-recover=cfi", 109 "-fsanitize-recover=cfi",
110 ] 110 ]
111 } 111 }
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 # This config is applied by default to all targets. It sets the compiler flags 116 config("common_sanitizer_flags") {
117 # for sanitizer usage, or, if no sanitizer is set, does nothing.
118 #
119 # This needs to be in a separate config so that targets can opt out of
120 # sanitizers (by removing the config) if they desire. Even if a target
121 # removes this config, executables & shared libraries should still depend on
122 # :deps if any of their dependencies have not opted out of sanitizers.
123 config("default_sanitizer_flags") {
124 cflags = [] 117 cflags = []
125 cflags_cc = [] 118 cflags_cc = []
126 defines = []
127 configs = [ ":default_sanitizer_ldflags" ]
128 119
129 # Sanitizers need line table info for stack traces. They don't need type info 120 # Sanitizers need line table info for stack traces. They don't need type info
130 # or variable info, so we can leave that out to speed up the build. 121 # or variable info, so we can leave that out to speed up the build.
131 if (using_sanitizer) { 122 if (using_sanitizer) {
132 assert(is_clang, "sanitizers only supported with clang") 123 assert(is_clang, "sanitizers only supported with clang")
133 cflags += [ "-gline-tables-only" ] 124 cflags += [ "-gline-tables-only" ]
134 } 125 }
135 126
136 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, 127 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer,
137 # MemorySanitizer and non-official CFI builds. 128 # MemorySanitizer and non-official CFI builds.
138 if (using_sanitizer || (is_cfi && !is_official_build)) { 129 if (using_sanitizer || (is_cfi && !is_official_build)) {
139 if (is_posix) { 130 if (is_posix) {
140 cflags += [ "-fno-omit-frame-pointer" ] 131 cflags += [ "-fno-omit-frame-pointer" ]
141 } else { 132 } else {
142 cflags += [ "/Oy-" ] 133 cflags += [ "/Oy-" ]
143 } 134 }
144 } 135 }
136
137 if (use_custom_libcxx) {
138 prefix = "//buildtools/third_party"
139 include = "trunk/include"
140 cflags_cc += [
141 "-nostdinc++",
142 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir),
143 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir),
144 ]
145 }
146 }
147
148 config("asan_flags") {
149 cflags = []
145 if (is_asan) { 150 if (is_asan) {
146 cflags += [ "-fsanitize=address" ] 151 cflags += [ "-fsanitize=address" ]
147 if (is_win) { 152 if (is_win) {
148 cflags += [ "-fsanitize-blacklist=" + 153 cflags += [ "-fsanitize-blacklist=" +
149 rebase_path("//tools/memory/asan/blacklist_win.txt", 154 rebase_path("//tools/memory/asan/blacklist_win.txt",
150 root_build_dir) ] 155 root_build_dir) ]
151 } else { 156 } else {
152 # TODO(rnk): Remove this as discussed in http://crbug.com/427202. 157 # TODO(rnk): Remove this as discussed in http://crbug.com/427202.
153 cflags += 158 cflags +=
154 [ "-fsanitize-blacklist=" + 159 [ "-fsanitize-blacklist=" +
(...skipping 24 matching lines...) Expand all
179 "clang_rt.asan_dynamic-i386.lib", 184 "clang_rt.asan_dynamic-i386.lib",
180 "clang_rt.asan_dynamic_runtime_thunk-i386.lib", 185 "clang_rt.asan_dynamic_runtime_thunk-i386.lib",
181 ] 186 ]
182 } else { 187 } else {
183 # TODO(rnk): DLLs in the non-component build should link against 188 # TODO(rnk): DLLs in the non-component build should link against
184 # clang_rt.asan_dll_thunk-i386.lib instead. 189 # clang_rt.asan_dll_thunk-i386.lib instead.
185 libs = [ "clang_rt.asan-i386.lib" ] 190 libs = [ "clang_rt.asan-i386.lib" ]
186 } 191 }
187 } 192 }
188 } 193 }
194 }
195
196 config("cfi_flags") {
197 defines = []
brettw 2016/04/27 22:03:23 This needs a cflags = []
krasin 2016/04/27 22:54:37 Done. Thank you for the catch. I've removed += fro
198 if (is_cfi && !is_nacl) {
199 cfi_blacklist_path =
200 rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
201 cflags += [
202 "-fsanitize=cfi-vcall",
203 "-fsanitize=cfi-derived-cast",
204 "-fsanitize=cfi-unrelated-cast",
205 "-fsanitize-blacklist=$cfi_blacklist_path",
206 ]
207
208 if (use_cfi_diag) {
209 cflags += [
210 "-fno-sanitize-trap=cfi",
211 "-fsanitize-recover=cfi",
212 "-fno-inline-functions",
213 "-fno-inline",
214 "-fno-omit-frame-pointer",
215 "-O1",
216 ]
217 } else {
218 defines += [ "CFI_ENFORCEMENT" ]
219 }
220 }
221 }
222
223 config("lsan_flags") {
189 if (is_lsan) { 224 if (is_lsan) {
190 cflags += [ "-fsanitize=leak" ] 225 cflags = [ "-fsanitize=leak" ]
191 } 226 }
192 if (is_tsan) { 227 }
193 assert(is_linux, "tsan only supported on linux x86_64") 228
194 tsan_blacklist_path = 229 config("msan_flags") {
195 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) 230 cflags = []
brettw 2016/04/27 22:03:23 In this case and a few below when it's only set on
krasin 2016/04/27 22:54:37 Done. Thanks, that's a useful warning.
196 cflags += [
197 "-fsanitize=thread",
198 "-fsanitize-blacklist=$tsan_blacklist_path",
199 ]
200 }
201 if (is_msan) { 231 if (is_msan) {
202 assert(is_linux, "msan only supported on linux x86_64") 232 assert(is_linux, "msan only supported on linux x86_64")
203 msan_blacklist_path = 233 msan_blacklist_path =
204 rebase_path("//tools/msan/blacklist.txt", root_build_dir) 234 rebase_path("//tools/msan/blacklist.txt", root_build_dir)
205 cflags += [ 235 cflags += [
206 "-fsanitize=memory", 236 "-fsanitize=memory",
207 "-fsanitize-memory-track-origins=$msan_track_origins", 237 "-fsanitize-memory-track-origins=$msan_track_origins",
208 "-fsanitize-blacklist=$msan_blacklist_path", 238 "-fsanitize-blacklist=$msan_blacklist_path",
209 ] 239 ]
210 } 240 }
241 }
242
243 config("tsan_flags") {
244 cflags = []
245 if (is_tsan) {
246 assert(is_linux, "tsan only supported on linux x86_64")
247 tsan_blacklist_path =
248 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
249 cflags += [
brettw 2016/04/27 22:03:23 Ditto, just = and delete the empty list at the top
krasin 2016/04/27 22:54:37 Done.
250 "-fsanitize=thread",
251 "-fsanitize-blacklist=$tsan_blacklist_path",
252 ]
253 }
254 }
255
256 config("ubsan_flags") {
257 cflags = []
211 if (is_ubsan) { 258 if (is_ubsan) {
212 ubsan_blacklist_path = 259 ubsan_blacklist_path =
213 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) 260 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
214 cflags += [ 261 cflags += [
215 # Yasm dies with an "Illegal instruction" error when bounds checking is 262 # Yasm dies with an "Illegal instruction" error when bounds checking is
216 # enabled. See http://crbug.com/489901 263 # enabled. See http://crbug.com/489901
217 # "-fsanitize=bounds", 264 # "-fsanitize=bounds",
218 "-fsanitize=float-divide-by-zero", 265 "-fsanitize=float-divide-by-zero",
219 "-fsanitize=integer-divide-by-zero", 266 "-fsanitize=integer-divide-by-zero",
220 "-fsanitize=null", 267 "-fsanitize=null",
(...skipping 17 matching lines...) Expand all
238 "-mllvm", 285 "-mllvm",
239 "-regalloc=pbqp", 286 "-regalloc=pbqp",
240 287
241 # Speculatively use coalescing to slightly improve the code generated 288 # Speculatively use coalescing to slightly improve the code generated
242 # by PBQP regallocator. May increase compile time. 289 # by PBQP regallocator. May increase compile time.
243 "-mllvm", 290 "-mllvm",
244 "-pbqp-coalescing", 291 "-pbqp-coalescing",
245 ] 292 ]
246 } 293 }
247 } 294 }
248 if (is_ubsan_vptr) { 295 }
249 ubsan_vptr_blacklist_path = 296
250 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) 297 config("ubsan_security_flags") {
251 cflags += [
252 "-fsanitize=vptr",
253 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
254 ]
255 }
256 if (is_ubsan_security) { 298 if (is_ubsan_security) {
257 ubsan_blacklist_path = 299 ubsan_blacklist_path =
258 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) 300 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
259 cflags += [ 301 cflags += [
brettw 2016/04/27 22:03:23 This should be "="
krasin 2016/04/27 22:54:37 Done.
260 "-fsanitize=signed-integer-overflow,shift", 302 "-fsanitize=signed-integer-overflow,shift",
261 "-fsanitize-blacklist=$ubsan_blacklist_path", 303 "-fsanitize-blacklist=$ubsan_blacklist_path",
262 ] 304 ]
263 } 305 }
264 if (is_cfi && !is_nacl) {
265 cfi_blacklist_path =
266 rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
267 cflags += [
268 "-fsanitize=cfi-vcall",
269 "-fsanitize=cfi-derived-cast",
270 "-fsanitize=cfi-unrelated-cast",
271 "-fsanitize-blacklist=$cfi_blacklist_path",
272 ]
273
274 if (use_cfi_diag) {
275 cflags += [
276 "-fno-sanitize-trap=cfi",
277 "-fsanitize-recover=cfi",
278 "-fno-inline-functions",
279 "-fno-inline",
280 "-fno-omit-frame-pointer",
281 "-O1",
282 ]
283 } else {
284 defines += [ "CFI_ENFORCEMENT" ]
285 }
286 }
287
288 if (use_custom_libcxx) {
289 prefix = "//buildtools/third_party"
290 include = "trunk/include"
291 cflags_cc += [
292 "-nostdinc++",
293 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir),
294 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir),
295 ]
296 }
297 } 306 }
298 307
308 config("ubsan_vptr_flags") {
309 if (is_ubsan_vptr) {
310 ubsan_vptr_blacklist_path =
311 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
312 cflags = [
313 "-fsanitize=vptr",
314 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
315 ]
316 }
317 }
318
319 # This config is applied by default to all targets. It sets the compiler flags
320 # for sanitizer usage, or, if no sanitizer is set, does nothing.
321 #
322 # This needs to be in a separate config so that targets can opt out of
323 # sanitizers (by removing the config) if they desire. Even if a target
324 # removes this config, executables & shared libraries should still depend on
325 # :deps if any of their dependencies have not opted out of sanitizers.
326 # Keep this list in sync with default_sanitizer_flags_but_ubsan_vptr.
327 config("default_sanitizer_flags") {
328 configs = [
329 ":common_sanitizer_flags",
330 ":default_sanitizer_ldflags",
331 ":asan_flags",
332 ":cfi_flags",
333 ":lsan_flags",
334 ":msan_flags",
335 ":tsan_flags",
336 ":ubsan_flags",
337 ":ubsan_security_flags",
338 ":ubsan_vptr_flags",
339 ]
340 }
341
342 # This config is equivalent to default_sanitizer_flags, but excludes ubsan_vptr.
343 # This allows to opt out of ubsan_vptr, when needed. In particular,
344 # //third_party/mesa has some code compiled without rtti, which requires
brettw 2016/04/27 22:03:23 I'd actually not bother mentioning where this is n
krasin 2016/04/27 22:54:37 I've rephrased the comment.
345 # to disable ubsan_vptr.
346 config("default_sanitizer_flags_but_ubsan_vptr") {
347 configs = [
348 ":common_sanitizer_flags",
349 ":default_sanitizer_ldflags",
350 ":asan_flags",
351 ":cfi_flags",
352 ":lsan_flags",
353 ":msan_flags",
354 ":tsan_flags",
355 ":ubsan_flags",
356 ":ubsan_security_flags",
357 ]
358 }
359
299 config("default_sanitizer_coverage_flags") { 360 config("default_sanitizer_coverage_flags") {
300 cflags = [] 361 cflags = []
362 defines = []
brettw 2016/04/27 22:03:23 You can keep this config the way it was.
krasin 2016/04/27 22:54:37 Done.
301 363
302 if (use_sanitizer_coverage) { 364 if (use_sanitizer_coverage) {
303 cflags += [ 365 cflags += [
304 "-fsanitize-coverage=$sanitizer_coverage_flags", 366 "-fsanitize-coverage=$sanitizer_coverage_flags",
305 "-mllvm", 367 "-mllvm",
306 "-sanitizer-coverage-prune-blocks=1", 368 "-sanitizer-coverage-prune-blocks=1",
307 ] 369 ]
308 if (target_cpu == "arm") { 370 if (target_cpu == "arm") {
309 # http://crbug.com/517105 371 # http://crbug.com/517105
310 cflags += [ 372 cflags += [
311 "-mllvm", 373 "-mllvm",
312 "-sanitizer-coverage-block-threshold=0", 374 "-sanitizer-coverage-block-threshold=0",
313 ] 375 ]
314 } 376 }
315 defines = [ "SANITIZER_COVERAGE" ] 377 defines += [ "SANITIZER_COVERAGE" ]
316 } 378 }
317 } 379 }
OLDNEW
« no previous file with comments | « no previous file | third_party/mesa/BUILD.gn » ('j') | third_party/mesa/README.chromium » ('J')

Powered by Google App Engine
This is Rietveld 408576698