Skip to content

Commit

Permalink
Remove checks for Xcode versions prior to 14.0 and unconditionally en…
Browse files Browse the repository at this point in the history
…able features that require 14.0 or greater.

PiperOrigin-RevId: 523108542
  • Loading branch information
allevato authored and swiple-rules-gardener committed Apr 10, 2023
1 parent b680bfc commit dc20ca5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 54 deletions.
10 changes: 0 additions & 10 deletions swift/internal/feature_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP = "swift.use_explicit_swift_module_m
# crashes.
SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE = "swift.use_global_module_cache"

# If enabled, actions invoking the Swift driver will use the legacy driver
# instead of the new driver (https://github.com/apple/swift-driver) that
# launched in Xcode 13/Swift 5.5.
SWIFT_FEATURE_USE_OLD_DRIVER = "swift.use_old_driver"

# If enabled, builds using the "dbg" compilation mode will explicitly disable
# swiftc from producing swiftmodules containing embedded file paths, which are
# inherently non-portable across machines.
Expand All @@ -181,11 +176,6 @@ SWIFT_FEATURE_USE_OLD_DRIVER = "swift.use_old_driver"
# target.swift-extra-clang-flags
SWIFT_FEATURE_CACHEABLE_SWIFTMODULES = "swift.cacheable_swiftmodules"

# This feature is enabled in Xcode 14.0 and later, which have support for the
# `-Xfrontend -prefix-serialized-debugging-options` flag to remap paths
# serialized into `.swiftmodule` files.
SWIFT_FEATURE_SUPPORTS_REMAP_SWIFTMODULES = "swift.supports_remap_swiftmodules"

# If enabled, requests the `-enable-library-evolution` swiftc flag which is
# required for newer features like swiftinterface file generation. If the
# `SWIFT_FEATURES_SUPPORTS_LIBRARY_EVOLUTION` feature is not enabled, this
Expand Down
22 changes: 1 addition & 21 deletions swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ load(
"SWIFT_FEATURE_OPT_USES_OSIZE",
"SWIFT_FEATURE_OPT_USES_WMO",
"SWIFT_FEATURE_REWRITE_GENERATED_HEADER",
"SWIFT_FEATURE_SUPPORTS_REMAP_SWIFTMODULES",
"SWIFT_FEATURE_SYSTEM_MODULE",
"SWIFT_FEATURE_USE_C_MODULES",
"SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP",
"SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE",
"SWIFT_FEATURE_USE_OLD_DRIVER",
"SWIFT_FEATURE__NUM_THREADS_1_IN_SWIFTCOPTS",
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
)
Expand Down Expand Up @@ -109,21 +107,8 @@ def compile_action_configs(
The list of action configs needed to perform compilation.
"""

#### Flags that control the driver
action_configs = [
# Use the legacy driver if requested.
ActionConfigInfo(
actions = [
SWIFT_ACTION_COMPILE,
SWIFT_ACTION_PRECOMPILE_C_MODULE,
],
configurators = [add_arg("-disallow-use-new-driver")],
features = [SWIFT_FEATURE_USE_OLD_DRIVER],
),
]

#### Flags that control compilation outputs
action_configs += [
action_configs = [
# Emit object file(s).
ActionConfigInfo(
actions = [SWIFT_ACTION_COMPILE],
Expand All @@ -143,10 +128,6 @@ def compile_action_configs(
configurators = [
add_arg("-Xfrontend", "-no-clang-module-breadcrumbs"),
],
features = [
[SWIFT_FEATURE_SUPPORTS_REMAP_SWIFTMODULES],
[SWIFT_FEATURE_CACHEABLE_SWIFTMODULES],
],
),

# Emit precompiled Clang modules, and embed all files that were read
Expand Down Expand Up @@ -311,7 +292,6 @@ def compile_action_configs(
configurators = [
add_arg("-Xfrontend", "-prefix-serialized-debugging-options"),
],
features = [SWIFT_FEATURE_SUPPORTS_REMAP_SWIFTMODULES],
not_features = [
[SWIFT_FEATURE_OPT],
[SWIFT_FEATURE_CACHEABLE_SWIFTMODULES],
Expand Down
28 changes: 5 additions & 23 deletions swift/toolchains/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ load(
"SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
"SWIFT_FEATURE_SUPPORTS_REMAP_SWIFTMODULES",
"SWIFT_FEATURE_USE_OLD_DRIVER",
"SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE",
)
load(
Expand Down Expand Up @@ -732,22 +730,11 @@ def _xcode_swift_toolchain_impl(ctx):
)
requested_features.extend([
SWIFT_FEATURE_CHECKED_EXCLUSIVITY,
SWIFT_FEATURE_ENABLE_BATCH_MODE,
SWIFT_FEATURE_DEBUG_PREFIX_MAP,
SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX,
SWIFT_FEATURE_ENABLE_BATCH_MODE,
])

if _is_xcode_at_least_version(xcode_config, "14.0"):
# Xcode 14 and higher support remapping paths serialized into
# .swiftmodules.
requested_features.append(SWIFT_FEATURE_SUPPORTS_REMAP_SWIFTMODULES)

# Xcode 14 and higher support forward slash regex literals.
requested_features.append(SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX)
else:
# The new driver had response file bugs in Xcode 13.x that are fixed in
# Xcode 14.
requested_features.append(SWIFT_FEATURE_USE_OLD_DRIVER)

if ctx.fragments.objc.alwayslink_by_default:
requested_features.append(SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE)

Expand Down Expand Up @@ -781,13 +768,6 @@ def _xcode_swift_toolchain_impl(ctx):
xcode_config = xcode_config,
)

module_aliases = ctx.attr._module_mapping[SwiftModuleAliasesInfo].aliases
if module_aliases and not _is_xcode_at_least_version(xcode_config, "14.0"):
fail(
"Module mappings are only supported by Swift 5.7 (Xcode 14.0) " +
"and higher.",
)

swift_toolchain_info = SwiftToolchainInfo(
action_configs = all_action_configs,
cc_toolchain_info = cc_toolchain,
Expand Down Expand Up @@ -816,7 +796,9 @@ def _xcode_swift_toolchain_impl(ctx):
ctx.attr.implicit_deps + ctx.attr.clang_implicit_deps,
additional_cc_infos = [swift_linkopts_cc_info],
),
module_aliases = module_aliases,
module_aliases = (
ctx.attr._module_mapping[SwiftModuleAliasesInfo].aliases
),
package_configurations = [
target[SwiftPackageConfigurationInfo]
for target in ctx.attr.package_configurations
Expand Down

1 comment on commit dc20ca5

@brentleyjones
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.