Skip to content

Commit 9d48ae6

Browse files
authored
Remove upstream get_cpu usage (#2670)
Manual cherry pick of 0410c02 Fixes past bazelbuild/bazel@4f40b7f
1 parent 325c4e3 commit 9d48ae6

13 files changed

+171
-162
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ tasks:
5050

5151
macos_last_green:
5252
name: "Last Green Bazel"
53-
bazel: 4c2d91e762ab6e492853b021408129dd93fb5904 # TODO: Switch back to last_green once get_cpu has been removed
53+
bazel: last_green
5454
<<: *common
5555

5656
doc_tests:

apple/apple_binary.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Resolved Xcode is version {xcode_version}.
6565

6666
binary_type = ctx.attr.binary_type
6767
bundle_loader = ctx.attr.bundle_loader
68+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
6869

6970
extra_linkopts = []
7071

@@ -91,6 +92,7 @@ Resolved Xcode is version {xcode_version}.
9192

9293
link_result = linking_support.register_binary_linking_action(
9394
ctx,
95+
cc_toolchains = cc_toolchain_forwarder,
9496
bundle_loader = bundle_loader,
9597
exported_symbols_lists = ctx.files.exported_symbols_lists,
9698
extra_linkopts = extra_linkopts,

apple/apple_static_library.bzl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ Expected Apple platform type of "{platform_type}", but that was not found in {to
6464
toolchain_key = toolchain_key,
6565
))
6666

67-
link_result = linking_support.register_static_library_linking_action(ctx = ctx)
67+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
68+
archive_result = linking_support.register_static_library_archive_action(
69+
ctx = ctx,
70+
cc_toolchains = cc_toolchain_forwarder,
71+
)
6872

69-
files_to_build = [link_result.library]
73+
files_to_build = [archive_result.library]
7074
runfiles = ctx.runfiles(
7175
files = files_to_build,
7276
collect_default = True,
@@ -76,14 +80,14 @@ Expected Apple platform type of "{platform_type}", but that was not found in {to
7680
providers = [
7781
DefaultInfo(files = depset(files_to_build), runfiles = runfiles),
7882
new_applebinaryinfo(
79-
binary = link_result.library,
83+
binary = archive_result.library,
8084
infoplist = None,
8185
),
82-
link_result.output_groups,
86+
archive_result.output_groups,
8387
]
8488

85-
if link_result.objc:
86-
providers.append(link_result.objc)
89+
if archive_result.objc:
90+
providers.append(archive_result.objc)
8791

8892
return providers
8993

@@ -108,10 +112,7 @@ implementation of `apple_static_library` in Bazel core so that it can be removed
108112
},
109113
attrs = [
110114
rule_attrs.common_tool_attrs(),
111-
rule_attrs.cc_toolchain_forwarder_attrs(
112-
deps_cfg = transition_support.apple_platform_split_transition,
113-
),
114-
rule_attrs.static_library_linking_attrs(
115+
rule_attrs.static_library_archive_attrs(
115116
deps_cfg = transition_support.apple_platform_split_transition,
116117
),
117118
{

apple/internal/ios_rules.bzl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def _ios_application_impl(ctx):
240240

241241
link_result = linking_support.register_binary_linking_action(
242242
ctx,
243+
cc_toolchains = cc_toolchain_forwarder,
243244
avoid_deps = ctx.attr.frameworks,
244245
entitlements = entitlements.linking,
245246
exported_symbols_lists = ctx.files.exported_symbols_lists,
@@ -557,6 +558,7 @@ def _ios_app_clip_impl(ctx):
557558
suffix_default = ctx.attr._bundle_id_suffix_default,
558559
shared_capabilities = ctx.attr.shared_capabilities,
559560
)
561+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
560562
bundle_verification_targets = [struct(target = ext) for ext in ctx.attr.extensions]
561563
embeddable_targets = (
562564
ctx.attr.frameworks +
@@ -613,6 +615,7 @@ def _ios_app_clip_impl(ctx):
613615

614616
link_result = linking_support.register_binary_linking_action(
615617
ctx,
618+
cc_toolchains = cc_toolchain_forwarder,
616619
avoid_deps = ctx.attr.frameworks,
617620
entitlements = entitlements.linking,
618621
exported_symbols_lists = ctx.files.exported_symbols_lists,
@@ -877,6 +880,7 @@ def _ios_framework_impl(ctx):
877880
suffix_default = ctx.attr._bundle_id_suffix_default,
878881
)
879882
cc_toolchain = find_cpp_toolchain(ctx)
883+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
880884
cc_features = cc_common.configure_features(
881885
ctx = ctx,
882886
cc_toolchain = cc_toolchain,
@@ -935,6 +939,7 @@ def _ios_framework_impl(ctx):
935939

936940
link_result = linking_support.register_binary_linking_action(
937941
ctx,
942+
cc_toolchains = cc_toolchain_forwarder,
938943
avoid_deps = ctx.attr.frameworks,
939944
# Frameworks do not have entitlements.
940945
entitlements = None,
@@ -1149,6 +1154,7 @@ def _ios_extension_impl(ctx):
11491154
suffix_default = ctx.attr._bundle_id_suffix_default,
11501155
shared_capabilities = ctx.attr.shared_capabilities,
11511156
)
1157+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
11521158
features = features_support.compute_enabled_features(
11531159
requested_features = ctx.features,
11541160
unsupported_features = ctx.disabled_features,
@@ -1210,6 +1216,7 @@ def _ios_extension_impl(ctx):
12101216

12111217
link_result = linking_support.register_binary_linking_action(
12121218
ctx,
1219+
cc_toolchains = cc_toolchain_forwarder,
12131220
avoid_deps = ctx.attr.frameworks,
12141221
entitlements = entitlements.linking,
12151222
exported_symbols_lists = ctx.files.exported_symbols_lists,
@@ -1461,6 +1468,7 @@ def _ios_dynamic_framework_impl(ctx):
14611468
)
14621469
executable_name = ctx.attr.executable_name
14631470
cc_toolchain = find_cpp_toolchain(ctx)
1471+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
14641472
cc_features = cc_common.configure_features(
14651473
ctx = ctx,
14661474
cc_toolchain = cc_toolchain,
@@ -1525,6 +1533,7 @@ def _ios_dynamic_framework_impl(ctx):
15251533

15261534
link_result = linking_support.register_binary_linking_action(
15271535
ctx,
1536+
cc_toolchains = cc_toolchain_forwarder,
15281537
avoid_deps = ctx.attr.frameworks,
15291538
# Frameworks do not have entitlements.
15301539
entitlements = None,
@@ -1774,8 +1783,11 @@ def _ios_static_framework_impl(ctx):
17741783
)
17751784
resource_deps = ctx.attr.deps + ctx.attr.resources
17761785

1777-
link_result = linking_support.register_static_library_linking_action(ctx = ctx)
1778-
binary_artifact = link_result.library
1786+
archive_result = linking_support.register_static_library_archive_action(
1787+
ctx = ctx,
1788+
cc_toolchains = cc_toolchain_forwarder,
1789+
)
1790+
binary_artifact = archive_result.library
17791791

17801792
processor_partials = [
17811793
partials.apple_bundle_info_partial(
@@ -2101,6 +2113,7 @@ def _ios_imessage_extension_impl(ctx):
21012113
shared_capabilities = ctx.attr.shared_capabilities,
21022114
)
21032115
executable_name = ctx.attr.executable_name
2116+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
21042117
features = features_support.compute_enabled_features(
21052118
requested_features = ctx.features,
21062119
unsupported_features = ctx.disabled_features,
@@ -2156,6 +2169,7 @@ def _ios_imessage_extension_impl(ctx):
21562169

21572170
link_result = linking_support.register_binary_linking_action(
21582171
ctx,
2172+
cc_toolchains = cc_toolchain_forwarder,
21592173
avoid_deps = ctx.attr.frameworks,
21602174
entitlements = entitlements.linking,
21612175
exported_symbols_lists = ctx.files.exported_symbols_lists,
@@ -2565,9 +2579,6 @@ ios_application = rule_factory.create_apple_rule(
25652579
is_test_supporting_rule = False,
25662580
requires_legacy_cc_toolchain = True,
25672581
),
2568-
rule_attrs.cc_toolchain_forwarder_attrs(
2569-
deps_cfg = transition_support.apple_platform_split_transition,
2570-
),
25712582
rule_attrs.common_bundle_attrs(deps_cfg = transition_support.apple_platform_split_transition),
25722583
rule_attrs.common_tool_attrs(),
25732584
rule_attrs.device_family_attrs(
@@ -2756,9 +2767,6 @@ However, iOS 14 introduced Widget Extensions that use a traditional `main` entry
27562767
is_test_supporting_rule = False,
27572768
requires_legacy_cc_toolchain = True,
27582769
),
2759-
rule_attrs.cc_toolchain_forwarder_attrs(
2760-
deps_cfg = transition_support.apple_platform_split_transition,
2761-
),
27622770
rule_attrs.common_bundle_attrs(
27632771
deps_cfg = transition_support.apple_platform_split_transition,
27642772
),
@@ -2989,9 +2997,6 @@ i.e. `--features=-swift.no_generated_header`).""",
29892997
is_test_supporting_rule = False,
29902998
requires_legacy_cc_toolchain = True,
29912999
),
2992-
rule_attrs.cc_toolchain_forwarder_attrs(
2993-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
2994-
),
29953000
rule_attrs.common_bundle_attrs(
29963001
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
29973002
),

0 commit comments

Comments
 (0)