|
|
@@ -484,8 +484,7 @@ def _impl(ctx):
|
|
|
|
|
|
sanitizer_common_flags = feature(
|
|
|
name = "sanitizer_common_flags",
|
|
|
- requires = [feature_set(["nonhost"])],
|
|
|
- implies = ["minimal_optimization_flags", "minimal_debug_info_flags", "preserve_call_stacks"],
|
|
|
+ implies = ["minimal_debug_info_flags", "preserve_call_stacks"],
|
|
|
)
|
|
|
|
|
|
# Separated from the feature above so it can only be included on platforms
|
|
|
@@ -505,16 +504,19 @@ def _impl(ctx):
|
|
|
|
|
|
asan = feature(
|
|
|
name = "asan",
|
|
|
- requires = [feature_set(["nonhost"])],
|
|
|
implies = ["sanitizer_common_flags"],
|
|
|
flag_sets = [flag_set(
|
|
|
actions = all_compile_actions + all_link_actions,
|
|
|
flag_groups = [flag_group(flags = [
|
|
|
"-fsanitize=address,undefined,nullability",
|
|
|
"-fsanitize-address-use-after-scope",
|
|
|
+ # Outlining is almost always the right tradeoff for our
|
|
|
+ # sanitizer usage where we're more pressured on generated code
|
|
|
+ # size than runtime performance.
|
|
|
+ "-fsanitize-address-outline-instrumentation",
|
|
|
# We don't need the recovery behavior of UBSan as we expect
|
|
|
# builds to be clean. Not recovering is a bit cheaper.
|
|
|
- "-fno-sanitize-recover=undefined",
|
|
|
+ "-fno-sanitize-recover=undefined,nullability",
|
|
|
# Don't embed the full path name for files. This limits the size
|
|
|
# and combined with line numbers is unlikely to result in many
|
|
|
# ambiguities.
|
|
|
@@ -526,6 +528,24 @@ def _impl(ctx):
|
|
|
)],
|
|
|
)
|
|
|
|
|
|
+ # A feature that further reduces the generated code size of our the ASan
|
|
|
+ # feature, but at the cost of lower quality diagnostics. This is enabled
|
|
|
+ # along with ASan in our fastbuild configuration, but can be disabled
|
|
|
+ # explicitly to get better error messages.
|
|
|
+ asan_min_size = feature(
|
|
|
+ name = "asan_min_size",
|
|
|
+ requires = [feature_set(["asan"])],
|
|
|
+ flag_sets = [flag_set(
|
|
|
+ actions = all_compile_actions + all_link_actions,
|
|
|
+ flag_groups = [flag_group(flags = [
|
|
|
+ # Force two UBSan checks that have especially large code size
|
|
|
+ # cost to use the minimal branch to a trapping instruction model
|
|
|
+ # instead of the full diagnostic.
|
|
|
+ "-fsanitize-trap=alignment,null",
|
|
|
+ ])],
|
|
|
+ )],
|
|
|
+ )
|
|
|
+
|
|
|
# Likely due to being unable to use the static-linked and up-to-date
|
|
|
# sanitizer runtimes, we have to disable a number of sanitizers on macOS.
|
|
|
macos_asan_workarounds = feature(
|
|
|
@@ -540,17 +560,23 @@ def _impl(ctx):
|
|
|
)],
|
|
|
)
|
|
|
|
|
|
- enable_asan_in_fastbuild = feature(
|
|
|
- name = "enable_asan_in_fastbuild",
|
|
|
+ # An enabled feature that requires the `fastbuild` compilation. This is used
|
|
|
+ # to toggle general features on by default, while allowing them to be
|
|
|
+ # directly enabled and disabled more generally as desired.
|
|
|
+ enable_in_fastbuild = feature(
|
|
|
+ name = "enable_in_fastbuild",
|
|
|
enabled = True,
|
|
|
- requires = [feature_set(["nonhost", "fastbuild"])],
|
|
|
- implies = ["asan"],
|
|
|
+ requires = [feature_set(["fastbuild"])],
|
|
|
+ implies = [
|
|
|
+ "asan",
|
|
|
+ "asan_min_size",
|
|
|
+ "minimal_optimization_flags",
|
|
|
+ "minimal_debug_info_flags",
|
|
|
+ ],
|
|
|
)
|
|
|
|
|
|
fuzzer = feature(
|
|
|
name = "fuzzer",
|
|
|
- requires = [feature_set(["nonhost"])],
|
|
|
- implies = ["asan"],
|
|
|
flag_sets = [flag_set(
|
|
|
actions = all_compile_actions + all_link_actions,
|
|
|
flag_groups = [flag_group(flags = [
|
|
|
@@ -999,7 +1025,6 @@ def _impl(ctx):
|
|
|
feature(name = "fastbuild"),
|
|
|
feature(name = "host"),
|
|
|
feature(name = "no_legacy_features"),
|
|
|
- feature(name = "nonhost"),
|
|
|
feature(name = "opt"),
|
|
|
feature(name = "supports_dynamic_linker", enabled = ctx.attr.target_os == "linux"),
|
|
|
feature(name = "supports_pic", enabled = True),
|
|
|
@@ -1018,7 +1043,8 @@ def _impl(ctx):
|
|
|
sysroot_feature,
|
|
|
sanitizer_common_flags,
|
|
|
asan,
|
|
|
- enable_asan_in_fastbuild,
|
|
|
+ asan_min_size,
|
|
|
+ enable_in_fastbuild,
|
|
|
fuzzer,
|
|
|
layering_check,
|
|
|
module_maps,
|