From a78166a94d750a2191ae14f93441cd00edd0eda8 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 4 Oct 2024 13:06:49 -0500 Subject: [PATCH] Align `swift.supports_bare_slash_regex` code with upstream Makes cherry-picks easier Signed-off-by: Brentley Jones --- swift/internal/feature_names.bzl | 9 ++++----- swift/internal/swift_autoconfiguration.bzl | 4 ++-- swift/toolchains/config/compile_config.bzl | 6 ++---- swift/toolchains/xcode_swift_toolchain.bzl | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/swift/internal/feature_names.bzl b/swift/internal/feature_names.bzl index f71de1983..de1d1fc18 100644 --- a/swift/internal/feature_names.bzl +++ b/swift/internal/feature_names.bzl @@ -307,11 +307,6 @@ SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS = "swift._num_threads_0_in_swiftcopts # This is a directory to persist automatically created precompiled bridging headers SWIFT_FEATURE_USE_PCH_OUTPUT_DIR = "swift.use_pch_output_dir" -# If enabled, Swift compilation actions will pass -# `-enable-bare-slash-regex` to `swiftc`. This is a new flag as of -# Swift 5.7 that enables `/.../` syntax regular-expression literals. -SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX = "swift.supports_bare_slash_regex" - # Workaround this issue https://github.com/apple/swift/issues/60406, disable # this feature if you have a version of Swift that fixes it and you care about # minor binary size improvements @@ -330,6 +325,10 @@ SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE = "swift._force_alwayslink_true" # enables runtime checking of exclusive memory access on mutation. SWIFT_FEATURE_CHECKED_EXCLUSIVITY = "swift.checked_exclusivity" +# If enabled, requests the `-enable-bare-slash-regex` swiftc flag which is +# required for forward slash regex expression literals. +SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX = "swift.supports_bare_slash_regex" + # If enabled, requests the `-disable-clang-spi` swiftc flag. Disables importing # Clang SPIs as Swift SPIs. SWIFT_FEATURE_DISABLE_CLANG_SPI = "swift.disable_clang_spi" diff --git a/swift/internal/swift_autoconfiguration.bzl b/swift/internal/swift_autoconfiguration.bzl index df90a0cee..b4670e343 100644 --- a/swift/internal/swift_autoconfiguration.bzl +++ b/swift/internal/swift_autoconfiguration.bzl @@ -30,13 +30,13 @@ load( "SWIFT_FEATURE_DEBUG_PREFIX_MAP", "SWIFT_FEATURE_EMIT_SWIFTDOC", "SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO", + "SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX", "SWIFT_FEATURE_ENABLE_BATCH_MODE", "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES", "SWIFT_FEATURE_FILE_PREFIX_MAP", "SWIFT_FEATURE_LLD_GC_WORKAROUND", "SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS", "SWIFT_FEATURE_NO_EMBED_DEBUG_MODULE", - "SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX", "SWIFT_FEATURE_USE_AUTOLINK_EXTRACT", "SWIFT_FEATURE_USE_MODULE_WRAP", ) @@ -201,11 +201,11 @@ def _compute_feature_values(repository_ctx, swiftc_path): # the `swiftc` executable and a scratch directory, respectively. The function # should return True if the feature is supported. _FEATURE_CHECKS = { + SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX: _check_enable_bare_slash_regex, SWIFT_FEATURE_ENABLE_BATCH_MODE: _check_enable_batch_mode, SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES: _check_skip_function_bodies, SWIFT_FEATURE_FILE_PREFIX_MAP: _check_file_prefix_map, SWIFT_FEATURE_LLD_GC_WORKAROUND: _check_supports_lld_gc_workaround, - SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX: _check_enable_bare_slash_regex, } def _normalized_linux_cpu(cpu): diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index 6cd224641..9ad67c575 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -47,6 +47,7 @@ load( "SWIFT_FEATURE_EMIT_PRIVATE_SWIFTINTERFACE", "SWIFT_FEATURE_EMIT_SWIFTDOC", "SWIFT_FEATURE_EMIT_SWIFTINTERFACE", + "SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX", "SWIFT_FEATURE_ENABLE_BATCH_MODE", "SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION", "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES", @@ -67,7 +68,6 @@ load( "SWIFT_FEATURE_OPT_USES_WMO", "SWIFT_FEATURE_REWRITE_GENERATED_HEADER", "SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION", - "SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX", "SWIFT_FEATURE_SYSTEM_MODULE", "SWIFT_FEATURE_THIN_LTO", "SWIFT_FEATURE_TREAT_WARNINGS_AS_ERRORS", @@ -1121,15 +1121,13 @@ def compile_action_configs( ], configurators = [_conditional_compilation_flag_configurator], ), - - # Enable bare slash regexes. ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, SWIFT_ACTION_COMPILE_MODULE_INTERFACE, ], configurators = [add_arg("-enable-bare-slash-regex")], - features = [SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX], + features = [SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX], ), ActionConfigInfo( actions = [ diff --git a/swift/toolchains/xcode_swift_toolchain.bzl b/swift/toolchains/xcode_swift_toolchain.bzl index 94fd3c870..4572ef6f5 100644 --- a/swift/toolchains/xcode_swift_toolchain.bzl +++ b/swift/toolchains/xcode_swift_toolchain.bzl @@ -57,6 +57,7 @@ load( "SWIFT_FEATURE_DISABLE_SYSTEM_INDEX", "SWIFT_FEATURE_EMIT_SWIFTDOC", "SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO", + "SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX", "SWIFT_FEATURE_ENABLE_BATCH_MODE", "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES", "SWIFT_FEATURE_FILE_PREFIX_MAP", @@ -64,7 +65,6 @@ load( "SWIFT_FEATURE_OBJC_LINK_FLAGS", "SWIFT_FEATURE_OPT_USES_WMO", "SWIFT_FEATURE_REMAP_XCODE_PATH", - "SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX", "SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE", "SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE", ) @@ -707,13 +707,13 @@ def _xcode_swift_toolchain_impl(ctx): SWIFT_FEATURE_DISABLE_SYSTEM_INDEX, SWIFT_FEATURE_EMIT_SWIFTDOC, SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO, + SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX, SWIFT_FEATURE_ENABLE_BATCH_MODE, SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES, SWIFT_FEATURE_FILE_PREFIX_MAP, SWIFT_FEATURE_OBJC_LINK_FLAGS, SWIFT_FEATURE_OPT_USES_WMO, SWIFT_FEATURE_REMAP_XCODE_PATH, - SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX, SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE, ])