1- diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
2- --- a/cc_toolchain_config.bzl 2023-01-06 15:34:50.000000000 -0800
3- +++ b/cc_toolchain_config.bzl 2023-01-22 15:33:16.794758043 -0800
4- @@ -27,6 +27,7 @@
5- "with_feature_set",
6- )
1+ diff --git a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
2+ index 1dd0e7a6e7..29b59c6325 100644
3+ --- a/cc_toolchain_config.bzl
4+ +++ b/cc_toolchain_config.bzl
5+ @@ -15,6 +15,7 @@
6+ """A Starlark cc_toolchain configuration rule"""
7+
78 load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
89+ load(":toolchain_features.bzl", "pl_toolchain_pre_features", "PL_EXTRA_CC_CONFIG_ATTRS", "pl_toolchain_post_features", "pl_action_configs")
9-
10- def layering_check_features(compiler):
11- if compiler != "clang":
12- @@ -147 ,7 +148 ,7 @@
10+ load(
11+ "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
12+ "action_config",
13+ @@ -228 ,7 +229 ,7 @@ def _impl(ctx):
1314 tool_path(name = name, path = path)
1415 for name, path in ctx.attr.tool_paths.items()
1516 ]
@@ -18,7 +19,7 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
1819
1920 llvm_cov_action = action_config(
2021 action_name = ACTION_NAMES.llvm_cov,
21- @@ -168 ,6 +169 ,10 @@
22+ @@ -278 ,6 +279 ,10 @@ def _impl(ctx):
2223 name = "supports_start_end_lib",
2324 enabled = True,
2425 )
@@ -27,9 +28,9 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
2728+ enabled = True,
2829+ )
2930
30- default_compile_flags_feature = feature(
31- name = "default_compile_flags ",
32- @@ -203 ,7 +208 ,7 @@
31+ gcc_quoting_for_param_files_feature = feature(
32+ name = "gcc_quoting_for_param_files ",
33+ @@ -323 ,7 +328 ,7 @@ def _impl(ctx):
3334 flags = ctx.attr.dbg_compile_flags,
3435 ),
3536 ] if ctx.attr.dbg_compile_flags else []),
@@ -38,49 +39,89 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
3839 ),
3940 flag_set(
4041 actions = all_compile_actions,
41- @@ -212 ,7 +217 ,7 @@
42+ @@ -332 ,7 +337 ,7 @@ def _impl(ctx):
4243 flags = ctx.attr.opt_compile_flags,
4344 ),
4445 ] if ctx.attr.opt_compile_flags else []),
4546- with_features = [with_feature_set(features = ["opt"])],
4647+ with_features = [with_feature_set(features = ["opt", "default_opt_level_flags"])],
4748 ),
4849 flag_set(
49- actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend ],
50- @@ -244 ,7 +249 ,7 @@
50+ actions = [ACTION_NAMES.c_compile ],
51+ @@ -372 ,7 +377 ,7 @@ def _impl(ctx):
5152 flags = ctx.attr.opt_link_flags,
5253 ),
5354 ] if ctx.attr.opt_link_flags else []),
5455- with_features = [with_feature_set(features = ["opt"])],
5556+ with_features = [with_feature_set(features = ["opt", "default_opt_level_flags"])],
5657 ),
5758 ],
59+ env_sets = [
60+ @@ -1473,27 +1478,6 @@ def _impl(ctx):
61+ enabled = True,
5862 )
59- @@ -1255,6 +1260,7 @@
63+
64+ - asan_feature = _sanitizer_feature(
65+ - name = "asan",
66+ - specific_compile_flags = [
67+ - "-fsanitize=address",
68+ - "-fno-common",
69+ - ],
70+ - specific_link_flags = [
71+ - "-fsanitize=address",
72+ - ],
73+ - )
74+ -
75+ - tsan_feature = _sanitizer_feature(
76+ - name = "tsan",
77+ - specific_compile_flags = [
78+ - "-fsanitize=thread",
79+ - ],
80+ - specific_link_flags = [
81+ - "-fsanitize=thread",
82+ - ],
83+ - )
84+ -
85+ ubsan_feature = _sanitizer_feature(
86+ name = "ubsan",
87+ specific_compile_flags = [
88+ @@ -1569,11 +1553,10 @@ def _impl(ctx):
6089 strip_debug_symbols_feature,
6190 coverage_feature,
6291 supports_pic_feature,
92+ - asan_feature,
93+ - tsan_feature,
94+ ubsan_feature,
95+ gcc_quoting_for_param_files_feature,
96+ static_link_cpp_runtimes_feature,
6397+ default_opt_level_flags_feature,
6498 ] + (
6599 [
66100 supports_start_end_lib_feature,
67- @@ -1276,6 +1282,7 @@
68- else:
69- features = [
70- supports_pic_feature,
101+ @@ -1613,11 +1596,10 @@ def _impl(ctx):
102+ set_install_name_feature,
103+ libtool_feature,
104+ archiver_flags_feature,
105+ - asan_feature,
106+ - tsan_feature,
107+ ubsan_feature,
108+ gcc_quoting_for_param_files_feature,
109+ static_link_cpp_runtimes_feature,
71110+ default_opt_level_flags_feature,
72111 ] + (
73112 [
74113 supports_start_end_lib_feature,
75- @@ -1294,6 +1301,7 @@
76- unfiltered_compile_flags_feature,
77- ] + layering_check_features(ctx.attr.compiler)
114+ @@ -1643,8 +1625,8 @@ def _impl(ctx):
115+ parse_headers_action_configs, parse_headers_features = parse_headers_support(
116+ parse_headers_tool_path = ctx.attr.tool_paths.get("parse_headers"),
117+ )
118+ + features = pl_toolchain_pre_features(ctx) + features + parse_headers_features + pl_toolchain_post_features(ctx)
119+ action_configs += parse_headers_action_configs
120+ - features += parse_headers_features
78121
79- + features = pl_toolchain_pre_features(ctx) + features + pl_toolchain_post_features(ctx)
80- return cc_common.create_cc_toolchain_config_info(
81- ctx = ctx,
82- features = features,
83- @@ -1313,7 +1321,7 @@
122+ if symbol_check:
123+ features.append(symbol_check)
124+ @@ -1669,7 +1651,7 @@ def _impl(ctx):
84125
85126 cc_toolchain_config = rule(
86127 implementation = _impl,
@@ -89,11 +130,12 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
89130 "cpu": attr.string(mandatory = True),
90131 "compiler": attr.string(mandatory = True),
91132 "toolchain_identifier": attr.string(mandatory = True),
92- @@ -1336,6 +1344,6 @@
93- "coverage_link_flags": attr.string_list() ,
94- "supports_start_end_lib": attr.bool() ,
95- "builtin_sysroot": attr.string( ),
133+ @@ -1699,7 +1681,7 @@ cc_toolchain_config = rule(
134+ fragment = "apple" ,
135+ name = "xcode_config_label" ,
136+ ) ),
96137- },
97138+ }, **PL_EXTRA_CC_CONFIG_ATTRS),
139+ fragments = ["apple", "cpp"],
98140 provides = [CcToolchainConfigInfo],
99141 )
0 commit comments