@@ -24,10 +24,40 @@ if (current_os == "mac" || current_os == "ios") {
24
24
import (" ${ build_root } /config/mac/mac_sdk.gni" )
25
25
}
26
26
27
+ # To use different sanitizer options, use `gn args .` in the out folder and
28
+ # use settings like:
29
+ #
30
+ # is_clang=true
31
+ # is_debug=true
32
+ # optimize_for_size=false
33
+ # is_asan=true
34
+ # is_sanitize_fatal=false
35
+ #
36
+
27
37
declare_args () {
28
38
# Enable -Werror. This can be disabled if using a different compiler
29
39
# with unfixed or unsupported wanings.
30
40
treat_warnings_as_errors = true
41
+
42
+ # Enable Thread sanitizer
43
+ is_tsan = false
44
+
45
+ # Enable memory sanitizer
46
+ is_msan = false
47
+
48
+ # enable undefined behavior sanitizer
49
+ is_ubsan = false
50
+
51
+ # Exit on sanitize error. Generally standard libraries may get errors
52
+ # so not stopping on the first error is often useful
53
+ is_sanitize_fatal = true
54
+
55
+ # Enable or disable Runtime Type Information (RTTI).
56
+ # Defaults true on darwin because Darwin.framework uses it.
57
+ enable_rtti = current_os == " mac" || current_os == " ios"
58
+
59
+ # Enable or disable support for C++ exceptions.
60
+ enable_exceptions = false
31
61
}
32
62
33
63
if (current_cpu == " arm" || current_cpu == " arm64" ) {
@@ -397,21 +427,6 @@ config("runtime_default") {
397
427
# is_sanitize_fatal=false
398
428
#
399
429
400
- declare_args () {
401
- # Enable Thread sanitizer
402
- is_tsan = false
403
-
404
- # Enable memory sanitizer
405
- is_msan = false
406
-
407
- # enable undefined behavior sanitizer
408
- is_ubsan = false
409
-
410
- # Exit on sanitize error. Generally standard libraries may get errors
411
- # so not stopping on the first error is often useful
412
- is_sanitize_fatal = true
413
- }
414
-
415
430
config (" sanitize_address" ) {
416
431
defines = []
417
432
cflags = [
@@ -452,10 +467,14 @@ config("sanitize_undefined_behavior") {
452
467
" -fsanitize=unsigned-integer-overflow" ,
453
468
" -fsanitize=implicit-conversion" ,
454
469
" -fsanitize=nullability" ,
455
- " -fno-sanitize=vptr,function" ,
456
470
]
457
471
}
458
472
473
+ # According to the LLVM UBSan documentation, sanitizing vptr is incompatible with the -fno-rtti flag.
474
+ if (! enable_rtti ) {
475
+ cflags += [ " -fno-sanitize=vptr" ]
476
+ }
477
+
459
478
ldflags = cflags
460
479
}
461
480
@@ -522,15 +541,6 @@ config("coverage_default") {
522
541
}
523
542
}
524
543
525
- declare_args () {
526
- # Enable or disable Runtime Type Information (RTTI).
527
- # Defaults true on darwin because Darwin.framework uses it.
528
- enable_rtti = current_os == " mac" || current_os == " ios"
529
-
530
- # Enable or disable support for C++ exceptions.
531
- enable_exceptions = false
532
- }
533
-
534
544
config (" no_rtti" ) {
535
545
cflags_cc = [ " -fno-rtti" ]
536
546
}
0 commit comments