Skip to content

Commit 0c30ead

Browse files
luispadronallevato
andauthored
Un-conditionalize logic for features that require Xcode 15.0 or higher (dropping support for Xcode 14) (#1311)
PiperOrigin-RevId: 640116533 Cherry picks: f235362 Submitting to the App Store requires Xcode 15+ so this cherry pick (and some other changes to < Xcode 15 logic I made) drops support for Xcodes less than 15 --------- Co-authored-by: Tony Allevato <[email protected]>
1 parent 86dc0f0 commit 0c30ead

File tree

7 files changed

+5
-101
lines changed

7 files changed

+5
-101
lines changed

swift/internal/compiling.bzl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ load(
4949
"SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP",
5050
"SWIFT_FEATURE_VFSOVERLAY",
5151
"SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS",
52-
"SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION",
53-
"SWIFT_FEATURE__SUPPORTS_MACROS",
5452
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
5553
)
5654
load(
@@ -493,13 +491,7 @@ def compile(
493491
feature_name = SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO,
494492
)
495493

496-
if is_feature_enabled(
497-
feature_configuration = feature_configuration,
498-
feature_name = SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION,
499-
):
500-
const_protocols_to_gather_file = swift_toolchain.const_protocols_to_gather
501-
else:
502-
const_protocols_to_gather_file = []
494+
const_protocols_to_gather_file = swift_toolchain.const_protocols_to_gather
503495

504496
compile_outputs, other_outputs = _declare_compile_outputs(
505497
srcs = srcs,
@@ -1313,10 +1305,7 @@ def _declare_compile_outputs(
13131305
else:
13141306
indexstore_directory = None
13151307

1316-
if is_feature_enabled(
1317-
feature_configuration = feature_configuration,
1318-
feature_name = SWIFT_FEATURE__SUPPORTS_MACROS,
1319-
) and not is_feature_enabled(
1308+
if not is_feature_enabled(
13201309
feature_configuration = feature_configuration,
13211310
feature_name = SWIFT_FEATURE_OPT,
13221311
):

swift/internal/feature_names.bzl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,6 @@ SWIFT_FEATURE_OBJC_LINK_FLAGS = "swift.objc_link_flag"
314314
# all Swift compilations to always be linked.
315315
SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE = "swift._force_alwayslink_true"
316316

317-
# A private feature that is set by the toolchain if it supports macros (Swift
318-
# 5.9 and above). Users should never manually enable, disable, or query this
319-
# feature.
320-
SWIFT_FEATURE__SUPPORTS_MACROS = "swift._supports_macros"
321-
322317
# Disables Swift sandbox which prevents issues with nested sandboxing when Swift code contains system-provided macros.
323318
# If enabled '#Preview' macro provided by SwiftUI fails to build and probably other system-provided macros.
324319
# Enabled by default for Swift 5.10+ on macOS.
@@ -341,11 +336,6 @@ SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO = "swift.emit_swiftsourceinfo"
341336
# multiple frameworks with different target name, but same module name.
342337
SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT = "swift.add_target_name_to_output"
343338

344-
# A private feature that is set by the toolchain if it supports constant values
345-
# extraction (Swift 5.8 and above). Users should never manually enable, disable, or query this
346-
# feature.
347-
SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION = "swift._supports_const_value_extraction"
348-
349339
# Enable thin LTO and update output-file-map correctly
350340
SWIFT_FEATURE_THIN_LTO = "swift.thin_lto"
351341

swift/internal/swift_autoconfiguration.bzl

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ load(
4040
"SWIFT_FEATURE_USE_AUTOLINK_EXTRACT",
4141
"SWIFT_FEATURE_USE_MODULE_WRAP",
4242
"SWIFT_FEATURE_USE_OLD_DRIVER",
43-
"SWIFT_FEATURE__SUPPORTS_MACROS",
4443
)
4544

4645
def _scratch_file(repository_ctx, temp_dir, name, content = ""):
@@ -154,30 +153,6 @@ def _write_swift_version(repository_ctx, swiftc_path):
154153
repository_ctx.file(filename, contents, executable = False)
155154
return filename
156155

157-
def _fetch_supported_features(repository_ctx, swiftc_path):
158-
"""Fetch the json config of supported features from Swift
159-
160-
This can be used to flip rules specific features
161-
162-
Args:
163-
repository_ctx: The repository context.
164-
swiftc_path: The `path` to the `swiftc` executable.
165-
166-
Returns:
167-
The list of supported features, or an empty array if it fails
168-
"""
169-
repository_ctx.file("empty.swift")
170-
result = repository_ctx.execute([
171-
swiftc_path,
172-
"-frontend",
173-
"-emit-supported-features",
174-
"empty.swift",
175-
])
176-
if result.return_code == 0:
177-
return json.decode(result.stdout.strip()).get("SupportedArguments", [])
178-
179-
return []
180-
181156
def _compute_feature_values(repository_ctx, swiftc_path):
182157
"""Computes a list of supported/unsupported features by running checks.
183158
@@ -259,10 +234,6 @@ def _create_linux_toolchain(repository_ctx):
259234
feature_values.append(SWIFT_FEATURE_USE_AUTOLINK_EXTRACT)
260235
feature_values.append(SWIFT_FEATURE_USE_MODULE_WRAP)
261236

262-
swift_features_config = _fetch_supported_features(repository_ctx, path_to_swiftc)
263-
if "load-plugin-executable" in swift_features_config:
264-
feature_values.append(SWIFT_FEATURE__SUPPORTS_MACROS)
265-
266237
repository_ctx.file(
267238
"BUILD",
268239
"""

swift/swift_compiler_plugin.bzl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ load(
2424
load(
2525
"@build_bazel_rules_swift//swift/internal:feature_names.bzl",
2626
"SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT",
27-
"SWIFT_FEATURE__SUPPORTS_MACROS",
2827
)
2928
load("//swift/internal:features.bzl", "is_feature_enabled")
3029
load(
@@ -59,12 +58,6 @@ def _swift_compiler_plugin_impl(ctx):
5958
unsupported_features = ctx.disabled_features,
6059
)
6160

62-
if not is_feature_enabled(
63-
feature_configuration = feature_configuration,
64-
feature_name = SWIFT_FEATURE__SUPPORTS_MACROS,
65-
):
66-
fail("Swift compiler plugins require Swift 5.9+")
67-
6861
deps = ctx.attr.deps
6962
srcs = ctx.files.srcs
7063
module_contexts = []

swift/toolchains/config/compile_config.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ load(
7575
"SWIFT_FEATURE_USE_PCH_OUTPUT_DIR",
7676
"SWIFT_FEATURE_VFSOVERLAY",
7777
"SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS",
78-
"SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION",
79-
"SWIFT_FEATURE__SUPPORTS_MACROS",
8078
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
8179
)
8280
load(":action_config.bzl", "ActionConfigInfo", "ConfigResultInfo", "add_arg")
@@ -254,7 +252,6 @@ def compile_action_configs(
254252
ActionConfigInfo(
255253
actions = [SWIFT_ACTION_COMPILE],
256254
configurators = [_constant_value_extraction_configurator],
257-
features = [SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION],
258255
),
259256

260257
# Link Time Optimization (LTO).
@@ -811,7 +808,6 @@ def compile_action_configs(
811808
SWIFT_ACTION_DERIVE_FILES,
812809
],
813810
configurators = [_macro_expansion_configurator],
814-
features = [SWIFT_FEATURE__SUPPORTS_MACROS],
815811
),
816812

817813
# swift-symbolgraph-extract doesn't yet support explicit Swift module

swift/toolchains/xcode_swift_toolchain.bzl

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ load(
6464
"SWIFT_FEATURE_REMAP_XCODE_PATH",
6565
"SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX",
6666
"SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE",
67-
"SWIFT_FEATURE_USE_OLD_DRIVER",
6867
"SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE",
69-
"SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION",
70-
"SWIFT_FEATURE__SUPPORTS_MACROS",
7168
)
7269
load("//swift/internal:features.bzl", "features_for_build_modes")
7370
load("//swift/internal:target_triples.bzl", "target_triples")
@@ -699,34 +696,23 @@ def _xcode_swift_toolchain_impl(ctx):
699696
SWIFT_FEATURE_CACHEABLE_SWIFTMODULES,
700697
SWIFT_FEATURE_COVERAGE_PREFIX_MAP,
701698
SWIFT_FEATURE_DEBUG_PREFIX_MAP,
699+
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
702700
SWIFT_FEATURE_EMIT_SWIFTDOC,
703701
SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO,
704702
SWIFT_FEATURE_ENABLE_BATCH_MODE,
705703
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES,
706-
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
704+
SWIFT_FEATURE_FILE_PREFIX_MAP,
707705
SWIFT_FEATURE_OBJC_LINK_FLAGS,
708706
SWIFT_FEATURE_OPT_USES_WMO,
709707
SWIFT_FEATURE_REMAP_XCODE_PATH,
708+
SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX,
710709
SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE,
711710
])
712711

713712
# The new driver had response file bugs in Xcode 13.x that are fixed in
714-
# Xcode 14.
715-
if not _is_xcode_at_least_version(xcode_config, "14.0"):
716-
requested_features.append(SWIFT_FEATURE_USE_OLD_DRIVER)
717-
718-
# Xcode 14 implies Swift 5.7.
719-
if _is_xcode_at_least_version(xcode_config, "14.0"):
720-
requested_features.append(SWIFT_FEATURE_FILE_PREFIX_MAP)
721-
requested_features.append(SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX)
722-
723713
if getattr(ctx.fragments.objc, "alwayslink_by_default", False):
724714
requested_features.append(SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE)
725715

726-
if _is_xcode_at_least_version(xcode_config, "15.0"):
727-
requested_features.append(SWIFT_FEATURE__SUPPORTS_MACROS)
728-
requested_features.append(SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION)
729-
730716
if _is_xcode_at_least_version(xcode_config, "15.3"):
731717
requested_features.append(SWIFT_FEATURE_DISABLE_SWIFT_SANDBOX)
732718

test/const_values_tests.bzl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ load(
2626

2727
const_values_test = make_action_command_line_test_rule()
2828

29-
no_const_values_test = make_action_command_line_test_rule(
30-
config_settings = {
31-
"//command_line_option:features": [
32-
"-swift._supports_const_value_extraction",
33-
],
34-
},
35-
)
36-
3729
const_values_wmo_test = make_provider_test_rule(
3830
config_settings = {
3931
str(Label("@build_bazel_rules_swift//swift:copt")): [
@@ -98,19 +90,6 @@ def const_values_test_suite(name, tags = []):
9890
target_under_test = "@build_bazel_rules_swift//test/fixtures/basic:first",
9991
)
10092

101-
no_const_values_test(
102-
name = "{}_not_expected_argv".format(name),
103-
not_expected_argv = [
104-
"-Xfrontend -const-gather-protocols-file",
105-
"-Xfrontend swift/toolchains/config/const_protocols_to_gather.json",
106-
"-emit-const-values-path",
107-
"first.swift.swiftconstvalues",
108-
],
109-
mnemonic = "SwiftCompile",
110-
tags = all_tags,
111-
target_under_test = "@build_bazel_rules_swift//test/fixtures/basic:first",
112-
)
113-
11493
native.test_suite(
11594
name = name,
11695
tags = all_tags,

0 commit comments

Comments
 (0)