Skip to content

Commit a82e06f

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 5799772 commit a82e06f

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
@@ -2989,10 +2989,8 @@ that this target depends on.
29892989
],
29902990
)
29912991

2992-
_STATIC_FRAMEWORK_DEPS_CFG = transition_support.apple_platform_split_transition
2993-
29942992
ios_static_framework = rule_factory.create_apple_rule(
2995-
cfg = transition_support.apple_platforms_rule_base_transition,
2993+
cfg = transition_support.apple_rule_transition,
29962994
doc = """Builds and bundles an iOS static framework for third-party distribution.
29972995
29982996
A static framework is bundled like a dynamic framework except that the embedded
@@ -3035,7 +3033,7 @@ i.e. `--features=-swift.no_generated_header`).""",
30353033
attrs = [
30363034
apple_support.platform_constraint_attrs(),
30373035
rule_attrs.binary_linking_attrs(
3038-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3036+
deps_cfg = transition_support.apple_platform_split_transition,
30393037
extra_deps_aspects = [
30403038
apple_resource_aspect,
30413039
framework_provider_aspect,
@@ -3044,7 +3042,7 @@ i.e. `--features=-swift.no_generated_header`).""",
30443042
requires_legacy_cc_toolchain = True,
30453043
),
30463044
rule_attrs.common_bundle_attrs(
3047-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3045+
deps_cfg = transition_support.apple_platform_split_transition,
30483046
),
30493047
rule_attrs.common_tool_attrs(),
30503048
rule_attrs.device_family_attrs(
@@ -3062,7 +3060,7 @@ i.e. `--features=-swift.no_generated_header`).""",
30623060
doc = "Private attribute to generate Swift interfaces for static frameworks.",
30633061
),
30643062
"avoid_deps": attr.label_list(
3065-
cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3063+
cfg = transition_support.apple_platform_split_transition,
30663064
doc = """
30673065
A list of library targets on which this framework depends in order to compile, but the transitive
30683066
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
@@ -3696,10 +3696,8 @@ that this target depends on.
36963696
],
36973697
)
36983698

3699-
_STATIC_FRAMEWORK_DEPS_CFG = transition_support.apple_platform_split_transition
3700-
37013699
macos_static_framework = rule_factory.create_apple_rule(
3702-
cfg = transition_support.apple_platforms_rule_base_transition,
3700+
cfg = transition_support.apple_rule_transition,
37033701
doc = """Builds and bundles a macOS static framework for third-party distribution.
37043702
37053703
A static framework is bundled like a dynamic framework except that the embedded
@@ -3742,7 +3740,7 @@ i.e. `--features=-swift.no_generated_header`).""",
37423740
attrs = [
37433741
apple_support.platform_constraint_attrs(),
37443742
rule_attrs.binary_linking_attrs(
3745-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3743+
deps_cfg = transition_support.apple_platform_split_transition,
37463744
extra_deps_aspects = [
37473745
apple_resource_aspect,
37483746
framework_provider_aspect,
@@ -3751,7 +3749,7 @@ i.e. `--features=-swift.no_generated_header`).""",
37513749
requires_legacy_cc_toolchain = True,
37523750
),
37533751
rule_attrs.common_bundle_attrs(
3754-
deps_cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3752+
deps_cfg = transition_support.apple_platform_split_transition,
37553753
),
37563754
rule_attrs.common_tool_attrs(),
37573755
rule_attrs.device_family_attrs(
@@ -3768,7 +3766,7 @@ i.e. `--features=-swift.no_generated_header`).""",
37683766
doc = "Private attribute to generate Swift interfaces for static frameworks.",
37693767
),
37703768
"avoid_deps": attr.label_list(
3771-
cfg = _STATIC_FRAMEWORK_DEPS_CFG,
3769+
cfg = transition_support.apple_platform_split_transition,
37723770
doc = """
37733771
A list of library targets on which this framework depends in order to compile, but the transitive
37743772
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)