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

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') | no next file with comments »
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 cflags = []
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)
196 cflags += [
197 "-fsanitize=thread",
198 "-fsanitize-blacklist=$tsan_blacklist_path",
199 ]
200 }
201 if (is_msan) { 230 if (is_msan) {
202 assert(is_linux, "msan only supported on linux x86_64") 231 assert(is_linux, "msan only supported on linux x86_64")
203 msan_blacklist_path = 232 msan_blacklist_path =
204 rebase_path("//tools/msan/blacklist.txt", root_build_dir) 233 rebase_path("//tools/msan/blacklist.txt", root_build_dir)
205 cflags += [ 234 cflags = [
206 "-fsanitize=memory", 235 "-fsanitize=memory",
207 "-fsanitize-memory-track-origins=$msan_track_origins", 236 "-fsanitize-memory-track-origins=$msan_track_origins",
208 "-fsanitize-blacklist=$msan_blacklist_path", 237 "-fsanitize-blacklist=$msan_blacklist_path",
209 ] 238 ]
210 } 239 }
240 }
241
242 config("tsan_flags") {
243 if (is_tsan) {
244 assert(is_linux, "tsan only supported on linux x86_64")
245 tsan_blacklist_path =
246 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
247 cflags = [
248 "-fsanitize=thread",
249 "-fsanitize-blacklist=$tsan_blacklist_path",
250 ]
251 }
252 }
253
254 config("ubsan_flags") {
255 cflags = []
211 if (is_ubsan) { 256 if (is_ubsan) {
212 ubsan_blacklist_path = 257 ubsan_blacklist_path =
213 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) 258 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
214 cflags += [ 259 cflags += [
215 # Yasm dies with an "Illegal instruction" error when bounds checking is 260 # Yasm dies with an "Illegal instruction" error when bounds checking is
216 # enabled. See http://crbug.com/489901 261 # enabled. See http://crbug.com/489901
217 # "-fsanitize=bounds", 262 # "-fsanitize=bounds",
218 "-fsanitize=float-divide-by-zero", 263 "-fsanitize=float-divide-by-zero",
219 "-fsanitize=integer-divide-by-zero", 264 "-fsanitize=integer-divide-by-zero",
220 "-fsanitize=null", 265 "-fsanitize=null",
(...skipping 17 matching lines...) Expand all
238 "-mllvm", 283 "-mllvm",
239 "-regalloc=pbqp", 284 "-regalloc=pbqp",
240 285
241 # Speculatively use coalescing to slightly improve the code generated 286 # Speculatively use coalescing to slightly improve the code generated
242 # by PBQP regallocator. May increase compile time. 287 # by PBQP regallocator. May increase compile time.
243 "-mllvm", 288 "-mllvm",
244 "-pbqp-coalescing", 289 "-pbqp-coalescing",
245 ] 290 ]
246 } 291 }
247 } 292 }
293 }
294
295 config("ubsan_security_flags") {
296 if (is_ubsan_security) {
297 ubsan_blacklist_path =
298 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
299 cflags = [
300 "-fsanitize=signed-integer-overflow,shift",
301 "-fsanitize-blacklist=$ubsan_blacklist_path",
302 ]
303 }
304 }
305
306 config("ubsan_vptr_flags") {
248 if (is_ubsan_vptr) { 307 if (is_ubsan_vptr) {
249 ubsan_vptr_blacklist_path = 308 ubsan_vptr_blacklist_path =
250 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) 309 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
251 cflags += [ 310 cflags = [
252 "-fsanitize=vptr", 311 "-fsanitize=vptr",
253 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", 312 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
254 ] 313 ]
255 } 314 }
256 if (is_ubsan_security) { 315 }
257 ubsan_blacklist_path =
258 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
259 cflags += [
260 "-fsanitize=signed-integer-overflow,shift",
261 "-fsanitize-blacklist=$ubsan_blacklist_path",
262 ]
263 }
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 316
274 if (use_cfi_diag) { 317 # This config is applied by default to all targets. It sets the compiler flags
275 cflags += [ 318 # for sanitizer usage, or, if no sanitizer is set, does nothing.
276 "-fno-sanitize-trap=cfi", 319 #
277 "-fsanitize-recover=cfi", 320 # This needs to be in a separate config so that targets can opt out of
278 "-fno-inline-functions", 321 # sanitizers (by removing the config) if they desire. Even if a target
279 "-fno-inline", 322 # removes this config, executables & shared libraries should still depend on
280 "-fno-omit-frame-pointer", 323 # :deps if any of their dependencies have not opted out of sanitizers.
281 "-O1", 324 # Keep this list in sync with default_sanitizer_flags_but_ubsan_vptr.
282 ] 325 config("default_sanitizer_flags") {
283 } else { 326 configs = [
284 defines += [ "CFI_ENFORCEMENT" ] 327 ":common_sanitizer_flags",
285 } 328 ":default_sanitizer_ldflags",
286 } 329 ":asan_flags",
330 ":cfi_flags",
331 ":lsan_flags",
332 ":msan_flags",
333 ":tsan_flags",
334 ":ubsan_flags",
335 ":ubsan_security_flags",
336 ":ubsan_vptr_flags",
337 ]
338 }
287 339
288 if (use_custom_libcxx) { 340 # This config is equivalent to default_sanitizer_flags, but excludes ubsan_vptr.
289 prefix = "//buildtools/third_party" 341 # This allows to selectively disable ubsan_vptr, when needed. In particular,
290 include = "trunk/include" 342 # if some third_party code is required to be compiled without rtti, which
291 cflags_cc += [ 343 # is a requirement for ubsan_vptr.
292 "-nostdinc++", 344 config("default_sanitizer_flags_but_ubsan_vptr") {
293 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir), 345 configs = [
294 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir), 346 ":common_sanitizer_flags",
295 ] 347 ":default_sanitizer_ldflags",
296 } 348 ":asan_flags",
349 ":cfi_flags",
350 ":lsan_flags",
351 ":msan_flags",
352 ":tsan_flags",
353 ":ubsan_flags",
354 ":ubsan_security_flags",
355 ]
297 } 356 }
298 357
299 config("default_sanitizer_coverage_flags") { 358 config("default_sanitizer_coverage_flags") {
300 cflags = [] 359 cflags = []
301 360
302 if (use_sanitizer_coverage) { 361 if (use_sanitizer_coverage) {
303 cflags += [ 362 cflags += [
304 "-fsanitize-coverage=$sanitizer_coverage_flags", 363 "-fsanitize-coverage=$sanitizer_coverage_flags",
305 "-mllvm", 364 "-mllvm",
306 "-sanitizer-coverage-prune-blocks=1", 365 "-sanitizer-coverage-prune-blocks=1",
307 ] 366 ]
308 if (target_cpu == "arm") { 367 if (target_cpu == "arm") {
309 # http://crbug.com/517105 368 # http://crbug.com/517105
310 cflags += [ 369 cflags += [
311 "-mllvm", 370 "-mllvm",
312 "-sanitizer-coverage-block-threshold=0", 371 "-sanitizer-coverage-block-threshold=0",
313 ] 372 ]
314 } 373 }
315 defines = [ "SANITIZER_COVERAGE" ] 374 defines = [ "SANITIZER_COVERAGE" ]
316 } 375 }
317 } 376 }
OLDNEW
« no previous file with comments | « no previous file | third_party/mesa/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698