From 9efcc2a2beaf332531ff4f023ac89569b3320ad4 Mon Sep 17 00:00:00 2001 From: Tony Allevato Date: Mon, 10 Apr 2023 07:03:39 -0700 Subject: [PATCH] Remove checks for Xcode versions prior to 14.0 and unconditionally enable features that require 14.0 or greater PiperOrigin-RevId: 523108542 (cherry picked from commit dc20ca5800e42675fd5ac249bc8e1569606a60b4) Signed-off-by: Brentley Jones --- swift/internal/feature_names.bzl | 5 ----- swift/internal/swift_autoconfiguration.bzl | 5 +---- swift/toolchains/config/compile_config.bzl | 19 +--------------- swift/toolchains/swift_toolchain.bzl | 4 +++- swift/toolchains/xcode_swift_toolchain.bzl | 25 ++++------------------ 5 files changed, 9 insertions(+), 49 deletions(-) diff --git a/swift/internal/feature_names.bzl b/swift/internal/feature_names.bzl index f19b52295..254671576 100644 --- a/swift/internal/feature_names.bzl +++ b/swift/internal/feature_names.bzl @@ -200,11 +200,6 @@ SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE = "swift.use_global_module_cache" # This feature requires `swift.use_global_module_cache` to be enabled. SWIFT_FEATURE_GLOBAL_MODULE_CACHE_USES_TMPDIR = "swift.global_module_cache_uses_tmpdir" -# 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, Swift linking actions will use `swift-autolink-extract` to extract # the linker arguments. This is required for ELF targets. This is used # internally to determine the behaviour of the actions across different diff --git a/swift/internal/swift_autoconfiguration.bzl b/swift/internal/swift_autoconfiguration.bzl index 96dc72e0b..df90a0cee 100644 --- a/swift/internal/swift_autoconfiguration.bzl +++ b/swift/internal/swift_autoconfiguration.bzl @@ -39,7 +39,6 @@ load( "SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX", "SWIFT_FEATURE_USE_AUTOLINK_EXTRACT", "SWIFT_FEATURE_USE_MODULE_WRAP", - "SWIFT_FEATURE_USE_OLD_DRIVER", ) load(":toolchain_utils.bzl", "SWIFT_TOOLCHAIN_TYPE") @@ -368,9 +367,7 @@ def _create_windows_toolchain(repository_ctx): SWIFT_FEATURE_NO_EMBED_DEBUG_MODULE, SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS, ] - disabled_features = [ - SWIFT_FEATURE_USE_OLD_DRIVER, - ] + disabled_features = [] version_file = _write_swift_version(repository_ctx, path_to_swiftc) xctest_version = repository_ctx.execute([ diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index d5be70b43..82bb9d062 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -72,7 +72,6 @@ load( "SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP", "SWIFT_FEATURE_USE_GLOBAL_INDEX_STORE", "SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE", - "SWIFT_FEATURE_USE_OLD_DRIVER", "SWIFT_FEATURE_USE_PCH_OUTPUT_DIR", "SWIFT_FEATURE_VFSOVERLAY", "SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS", @@ -120,24 +119,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_COMPILE_MODULE_INTERFACE, - SWIFT_ACTION_DERIVE_FILES, - SWIFT_ACTION_DUMP_AST, - 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], diff --git a/swift/toolchains/swift_toolchain.bzl b/swift/toolchains/swift_toolchain.bzl index 1655c4d1e..450357e00 100644 --- a/swift/toolchains/swift_toolchain.bzl +++ b/swift/toolchains/swift_toolchain.bzl @@ -530,7 +530,9 @@ def _swift_toolchain_impl(ctx): generated_header_module_implicit_deps_providers = ( collect_implicit_deps_providers([]) ), - module_aliases = ctx.attr._module_mapping[SwiftModuleAliasesInfo].aliases, + module_aliases = ( + ctx.attr._module_mapping[SwiftModuleAliasesInfo].aliases + ), implicit_deps_providers = collect_implicit_deps_providers( [], additional_cc_infos = [swift_linkopts_cc_info], diff --git a/swift/toolchains/xcode_swift_toolchain.bzl b/swift/toolchains/xcode_swift_toolchain.bzl index 8e0139816..93c8ed86e 100644 --- a/swift/toolchains/xcode_swift_toolchain.bzl +++ b/swift/toolchains/xcode_swift_toolchain.bzl @@ -487,8 +487,7 @@ def _all_tool_configs( execution_requirements, generated_header_rewriter, swift_executable, - toolchain_root, - xcode_config): + toolchain_root): """Returns the tool configurations for the Swift toolchain. Args: @@ -501,7 +500,6 @@ def _all_tool_configs( swift_executable: A custom Swift driver executable to be used during the build, if provided. toolchain_root: The root directory of the toolchain, if provided. - xcode_config: The `apple_common.XcodeVersionConfig` provider. Returns: A dictionary mapping action name to tool configuration. @@ -514,15 +512,6 @@ def _all_tool_configs( env = dict(env) env["TOOLCHAINS"] = custom_toolchain - # In Xcode 13.3 and 13.4 (Swift 5.6), the legacy driver prints a warning - # if it is used. Suppress it, since we still have to use it on those - # specific versions due to response file bugs. - if ( - _is_xcode_at_least_version(xcode_config, "13.3") and - not _is_xcode_at_least_version(xcode_config, "14.0") - ): - env["SWIFT_AVOID_WARNING_USING_OLD_DRIVER"] = "1" - def _driver_config(*, mode): return { "mode": mode, @@ -747,7 +736,6 @@ def _xcode_swift_toolchain_impl(ctx): generated_header_rewriter = generated_header_rewriter, swift_executable = swift_executable, toolchain_root = toolchain_root, - xcode_config = xcode_config, ) all_action_configs = _all_action_configs( additional_objc_copts = _command_line_objc_copts( @@ -786,13 +774,6 @@ def _xcode_swift_toolchain_impl(ctx): ), ) - 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, @@ -820,7 +801,9 @@ def _xcode_swift_toolchain_impl(ctx): additional_cc_infos = [swift_linkopts_providers.cc_info], additional_objc_infos = [swift_linkopts_providers.objc_info], ), - module_aliases = module_aliases, + module_aliases = ( + ctx.attr._module_mapping[SwiftModuleAliasesInfo].aliases + ), package_configurations = [ target[SwiftPackageConfigurationInfo] for target in ctx.attr.package_configurations