Skip to content

Commit 7b5abf2

Browse files
nglevinluispadron
authored andcommitted
Initial support for dropping arm64e when "pointer_authentication" is not established on top level targets (i.e. not frameworks). Currently behind the enable_wip_features flag.
This required standardizing on fewer transitions and removing arguments that hadn't advanced enough, as well as propagating through enable_wip_features to avoid dropping the arm64e architecture until clients of the rules are ready to adopt secure_features for Xcode 26. Cherry-pick: b526fc8
1 parent 6f47836 commit 7b5abf2

16 files changed

Lines changed: 371 additions & 415 deletions

apple/internal/ios_rules.bzl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,10 +2986,8 @@ that this target depends on.
29862986
],
29872987
)
29882988

2989-
_STATIC_FRAMEWORK_DEPS_CFG = transition_support.apple_platform_split_transition
2990-
29912989
ios_static_framework = rule_factory.create_apple_rule(
2992-
cfg = transition_support.apple_platforms_rule_base_transition,
2990+
cfg = transition_support.apple_rule_transition,
29932991
doc = """Builds and bundles an iOS static framework for third-party distribution.
29942992
29952993
A static framework is bundled like a dynamic framework except that the embedded
@@ -3032,7 +3030,7 @@ i.e. `--features=-swift.no_generated_header`).""",
30323030
attrs = [
30333031
apple_support.platform_constraint_attrs(),
30343032
rule_attrs.binary_linking_attrs(
3035-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3033+
deps_cfg = transition_support.apple_platform_split_transition,
30363034
extra_deps_aspects = [
30373035
apple_resource_aspect,
30383036
framework_provider_aspect,
@@ -3041,7 +3039,7 @@ i.e. `--features=-swift.no_generated_header`).""",
30413039
requires_legacy_cc_toolchain = True,
30423040
),
30433041
rule_attrs.common_bundle_attrs(
3044-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3042+
deps_cfg = transition_support.apple_platform_split_transition,
30453043
),
30463044
rule_attrs.common_tool_attrs(),
30473045
rule_attrs.device_family_attrs(
@@ -3059,7 +3057,7 @@ i.e. `--features=-swift.no_generated_header`).""",
30593057
doc = "Private attribute to generate Swift interfaces for static frameworks.",
30603058
),
30613059
"avoid_deps": attr.label_list(
3062-
cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3060+
cfg = transition_support.apple_platform_split_transition,
30633061
doc = """
30643062
A list of library targets on which this framework depends in order to compile, but the transitive
30653063
closure of which will not be linked into the framework's binary.

apple/internal/macos_rules.bzl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,10 +3699,8 @@ that this target depends on.
36993699
],
37003700
)
37013701

3702-
_STATIC_FRAMEWORK_DEPS_CFG = transition_support.apple_platform_split_transition
3703-
37043702
macos_static_framework = rule_factory.create_apple_rule(
3705-
cfg = transition_support.apple_platforms_rule_base_transition,
3703+
cfg = transition_support.apple_rule_transition,
37063704
doc = """Builds and bundles a macOS static framework for third-party distribution.
37073705
37083706
A static framework is bundled like a dynamic framework except that the embedded
@@ -3745,7 +3743,7 @@ i.e. `--features=-swift.no_generated_header`).""",
37453743
attrs = [
37463744
apple_support.platform_constraint_attrs(),
37473745
rule_attrs.binary_linking_attrs(
3748-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3746+
deps_cfg = transition_support.apple_platform_split_transition,
37493747
extra_deps_aspects = [
37503748
apple_resource_aspect,
37513749
framework_provider_aspect,
@@ -3754,7 +3752,7 @@ i.e. `--features=-swift.no_generated_header`).""",
37543752
requires_legacy_cc_toolchain = True,
37553753
),
37563754
rule_attrs.common_bundle_attrs(
3757-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3755+
deps_cfg = transition_support.apple_platform_split_transition,
37583756
),
37593757
rule_attrs.common_tool_attrs(),
37603758
rule_attrs.device_family_attrs(
@@ -3771,7 +3769,7 @@ i.e. `--features=-swift.no_generated_header`).""",
37713769
doc = "Private attribute to generate Swift interfaces for static frameworks.",
37723770
),
37733771
"avoid_deps": attr.label_list(
3774-
cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3772+
cfg = transition_support.apple_platform_split_transition,
37753773
doc = """
37763774
A list of library targets on which this framework depends in order to compile, but the transitive
37773775
closure of which will not be linked into the framework's binary.

apple/internal/secure_features_support.bzl

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ visibility([
2020
"//apple/internal/...",
2121
])
2222

23-
# TODO: b/449684779 - Stand up a solution for allowing arm64e as a target arch in a transition when
24-
# building for devices. Simulators don't have adequate support yet (FB20484613), so consider
25-
# fail-ing or warning until that's resolved.
26-
2723
# The name of the secure feature that's required for opting into any set of enhanced security
2824
# features on Xcode 26.0 or later.
2925
#
@@ -149,7 +145,7 @@ def _entitlements_from_secure_features(
149145
secure_features,
150146
xcode_version):
151147
if not secure_features:
152-
return []
148+
return {}
153149

154150
for feature_name in secure_features:
155151
if not feature_name.startswith("apple."):
@@ -179,7 +175,7 @@ attempting to explicitly disable the feature via minus prefixed feature names, s
179175
# Check that we're building with Xcode 26.0 or later. If not, return an empty list to signal
180176
# that no entitlements are supported or needed for this build.
181177
if not xcode_version >= apple_common.dotted_version("26.0"):
182-
return []
178+
return {}
183179

184180
# Build a set of all of the entitlements that are required by the requested secure features.
185181
required_entitlements = dict()
@@ -191,7 +187,33 @@ attempting to explicitly disable the feature via minus prefixed feature names, s
191187

192188
return required_entitlements
193189

190+
def _environment_archs_from_secure_features(
191+
*,
192+
enable_wip_features,
193+
environment_archs,
194+
secure_features):
195+
# TODO: b/449684779 - Migrate users to secure_features behind an allowlist when it's ready for
196+
# onboarding. Remove this "enable_wip_features" check once pointer_authentication is onboarded.
197+
if not enable_wip_features:
198+
return environment_archs
199+
200+
# Leave environment_archs as-is if pointer_authentication is explicitly requested, since we can
201+
# assume that arm64e does not need to be removed from the list of architectures to build for.
202+
if "pointer_authentication" in secure_features:
203+
return environment_archs
204+
205+
# TODO: b/449684779 - Simulators don't have adequate support yet (FB20484613), so further
206+
# consider fail-ing or warning if we have arm64e + simulator + pointer_authentication until
207+
# that's resolved.
208+
209+
return [
210+
environment_arch
211+
for environment_arch in environment_archs
212+
if not environment_arch.endswith("arm64e")
213+
]
214+
194215
secure_features_support = struct(
195216
crosstool_features_from_secure_features = _crosstool_features_from_secure_features,
196217
entitlements_from_secure_features = _entitlements_from_secure_features,
218+
environment_archs_from_secure_features = _environment_archs_from_secure_features,
197219
)

0 commit comments

Comments
 (0)