@@ -5475,6 +5475,29 @@ def _impl(ctx):
5475
5475
flag_group (
5476
5476
flags = [
5477
5477
"-D_FORTIFY_SOURCE=1" ,
5478
+ ],
5479
+ ),
5480
+ ],
5481
+ with_features = [with_feature_set (not_features = ["asan" ])],
5482
+ ),
5483
+ flag_set (
5484
+ actions = [
5485
+ ACTION_NAMES .assemble ,
5486
+ ACTION_NAMES .preprocess_assemble ,
5487
+ ACTION_NAMES .linkstamp_compile ,
5488
+ ACTION_NAMES .c_compile ,
5489
+ ACTION_NAMES .cpp_compile ,
5490
+ ACTION_NAMES .cpp_header_parsing ,
5491
+ ACTION_NAMES .cpp_module_compile ,
5492
+ ACTION_NAMES .cpp_module_codegen ,
5493
+ ACTION_NAMES .lto_backend ,
5494
+ ACTION_NAMES .clif_match ,
5495
+ ACTION_NAMES .objc_compile ,
5496
+ ACTION_NAMES .objcpp_compile ,
5497
+ ],
5498
+ flag_groups = [
5499
+ flag_group (
5500
+ flags = [
5478
5501
"-fstack-protector" ,
5479
5502
"-fcolor-diagnostics" ,
5480
5503
"-Wall" ,
@@ -5523,7 +5546,6 @@ def _impl(ctx):
5523
5546
flags = [
5524
5547
"-g0" ,
5525
5548
"-O2" ,
5526
- "-D_FORTIFY_SOURCE=1" ,
5527
5549
"-DNDEBUG" ,
5528
5550
"-DNS_BLOCK_ASSERTIONS=1" ,
5529
5551
],
@@ -5595,6 +5617,29 @@ def _impl(ctx):
5595
5617
flag_group (
5596
5618
flags = [
5597
5619
"-D_FORTIFY_SOURCE=1" ,
5620
+ ],
5621
+ ),
5622
+ ],
5623
+ with_features = [with_feature_set (not_features = ["asan" ])],
5624
+ ),
5625
+ flag_set (
5626
+ actions = [
5627
+ ACTION_NAMES .assemble ,
5628
+ ACTION_NAMES .preprocess_assemble ,
5629
+ ACTION_NAMES .linkstamp_compile ,
5630
+ ACTION_NAMES .c_compile ,
5631
+ ACTION_NAMES .cpp_compile ,
5632
+ ACTION_NAMES .cpp_header_parsing ,
5633
+ ACTION_NAMES .cpp_module_compile ,
5634
+ ACTION_NAMES .cpp_module_codegen ,
5635
+ ACTION_NAMES .lto_backend ,
5636
+ ACTION_NAMES .clif_match ,
5637
+ ACTION_NAMES .objc_compile ,
5638
+ ACTION_NAMES .objcpp_compile ,
5639
+ ],
5640
+ flag_groups = [
5641
+ flag_group (
5642
+ flags = [
5598
5643
"-fstack-protector" ,
5599
5644
"-fcolor-diagnostics" ,
5600
5645
"-Wall" ,
@@ -5643,7 +5688,6 @@ def _impl(ctx):
5643
5688
flags = [
5644
5689
"-g0" ,
5645
5690
"-O2" ,
5646
- "-D_FORTIFY_SOURCE=1" ,
5647
5691
"-DNDEBUG" ,
5648
5692
"-DNS_BLOCK_ASSERTIONS=1" ,
5649
5693
],
@@ -6080,6 +6124,141 @@ def _impl(ctx):
6080
6124
],
6081
6125
)
6082
6126
6127
+ asan_feature = feature (
6128
+ name = "asan" ,
6129
+ flag_sets = [
6130
+ flag_set (
6131
+ actions = [
6132
+ ACTION_NAMES .c_compile ,
6133
+ ACTION_NAMES .cpp_compile ,
6134
+ ACTION_NAMES .objc_compile ,
6135
+ ACTION_NAMES .objcpp_compile ,
6136
+ ],
6137
+ flag_groups = [
6138
+ flag_group (flags = ["-fsanitize=address" ]),
6139
+ ],
6140
+ with_features = [
6141
+ with_feature_set (features = ["asan" ]),
6142
+ ],
6143
+ ),
6144
+ flag_set (
6145
+ actions = [
6146
+ ACTION_NAMES .cpp_link_executable ,
6147
+ ACTION_NAMES .cpp_link_dynamic_library ,
6148
+ ACTION_NAMES .cpp_link_nodeps_dynamic_library ,
6149
+ ACTION_NAMES .objc_executable ,
6150
+ ACTION_NAMES .objcpp_executable ,
6151
+ ],
6152
+ flag_groups = [
6153
+ flag_group (flags = ["-fsanitize=address" ]),
6154
+ ],
6155
+ with_features = [
6156
+ with_feature_set (features = ["asan" ]),
6157
+ ],
6158
+ ),
6159
+ ],
6160
+ )
6161
+
6162
+ tsan_feature = feature (
6163
+ name = "tsan" ,
6164
+ flag_sets = [
6165
+ flag_set (
6166
+ actions = [
6167
+ ACTION_NAMES .c_compile ,
6168
+ ACTION_NAMES .cpp_compile ,
6169
+ ACTION_NAMES .objc_compile ,
6170
+ ACTION_NAMES .objcpp_compile ,
6171
+ ],
6172
+ flag_groups = [
6173
+ flag_group (flags = ["-fsanitize=thread" ]),
6174
+ ],
6175
+ with_features = [
6176
+ with_feature_set (features = ["tsan" ]),
6177
+ ],
6178
+ ),
6179
+ flag_set (
6180
+ actions = [
6181
+ ACTION_NAMES .cpp_link_executable ,
6182
+ ACTION_NAMES .cpp_link_dynamic_library ,
6183
+ ACTION_NAMES .cpp_link_nodeps_dynamic_library ,
6184
+ ACTION_NAMES .objc_executable ,
6185
+ ACTION_NAMES .objcpp_executable ,
6186
+ ],
6187
+ flag_groups = [
6188
+ flag_group (flags = ["-fsanitize=thread" ]),
6189
+ ],
6190
+ with_features = [
6191
+ with_feature_set (features = ["tsan" ]),
6192
+ ],
6193
+ ),
6194
+ ],
6195
+ )
6196
+
6197
+ ubsan_feature = feature (
6198
+ name = "ubsan" ,
6199
+ flag_sets = [
6200
+ flag_set (
6201
+ actions = [
6202
+ ACTION_NAMES .c_compile ,
6203
+ ACTION_NAMES .cpp_compile ,
6204
+ ACTION_NAMES .objc_compile ,
6205
+ ACTION_NAMES .objcpp_compile ,
6206
+ ],
6207
+ flag_groups = [
6208
+ flag_group (flags = ["-fsanitize=undefined" ]),
6209
+ ],
6210
+ with_features = [
6211
+ with_feature_set (features = ["ubsan" ]),
6212
+ ],
6213
+ ),
6214
+ flag_set (
6215
+ actions = [
6216
+ ACTION_NAMES .cpp_link_executable ,
6217
+ ACTION_NAMES .cpp_link_dynamic_library ,
6218
+ ACTION_NAMES .cpp_link_nodeps_dynamic_library ,
6219
+ ACTION_NAMES .objc_executable ,
6220
+ ACTION_NAMES .objcpp_executable ,
6221
+ ],
6222
+ flag_groups = [
6223
+ flag_group (flags = ["-fsanitize=undefined" ]),
6224
+ ],
6225
+ with_features = [
6226
+ with_feature_set (features = ["ubsan" ]),
6227
+ ],
6228
+ ),
6229
+ ],
6230
+ )
6231
+
6232
+ default_sanitizer_flags_feature = feature (
6233
+ name = "default_sanitizer_flags" ,
6234
+ enabled = True ,
6235
+ flag_sets = [
6236
+ flag_set (
6237
+ actions = [
6238
+ ACTION_NAMES .c_compile ,
6239
+ ACTION_NAMES .cpp_compile ,
6240
+ ACTION_NAMES .objc_compile ,
6241
+ ACTION_NAMES .objcpp_compile ,
6242
+ ],
6243
+ flag_groups = [
6244
+ flag_group (
6245
+ flags = [
6246
+ "-O1" ,
6247
+ "-gline-tables-only" ,
6248
+ "-fno-omit-frame-pointer" ,
6249
+ "-fno-sanitize-recover=all" ,
6250
+ ],
6251
+ ),
6252
+ ],
6253
+ with_features = [
6254
+ with_feature_set (features = ["asan" ]),
6255
+ with_feature_set (features = ["tsan" ]),
6256
+ with_feature_set (features = ["ubsan" ]),
6257
+ ],
6258
+ ),
6259
+ ],
6260
+ )
6261
+
6083
6262
if (ctx .attr .cpu == "ios_arm64" or
6084
6263
ctx .attr .cpu == "ios_arm64e" or
6085
6264
ctx .attr .cpu == "ios_armv7" or
@@ -6165,6 +6344,10 @@ def _impl(ctx):
6165
6344
compiler_output_flags_feature ,
6166
6345
objcopy_embed_flags_feature ,
6167
6346
set_install_name ,
6347
+ asan_feature ,
6348
+ tsan_feature ,
6349
+ ubsan_feature ,
6350
+ default_sanitizer_flags_feature ,
6168
6351
]
6169
6352
elif (ctx .attr .cpu == "darwin_x86_64" or
6170
6353
ctx .attr .cpu == "darwin_arm64" or
@@ -6244,6 +6427,10 @@ def _impl(ctx):
6244
6427
objcopy_embed_flags_feature ,
6245
6428
dynamic_linking_mode_feature ,
6246
6429
set_install_name ,
6430
+ asan_feature ,
6431
+ tsan_feature ,
6432
+ ubsan_feature ,
6433
+ default_sanitizer_flags_feature ,
6247
6434
]
6248
6435
elif (ctx .attr .cpu == "armeabi-v7a" ):
6249
6436
features = [
@@ -6321,6 +6508,10 @@ def _impl(ctx):
6321
6508
supports_pic_feature ,
6322
6509
objcopy_embed_flags_feature ,
6323
6510
set_install_name ,
6511
+ asan_feature ,
6512
+ tsan_feature ,
6513
+ ubsan_feature ,
6514
+ default_sanitizer_flags_feature ,
6324
6515
]
6325
6516
else :
6326
6517
fail ("Unreachable" )
0 commit comments