From 53ba09968741c48cd1ab2b7eb0911b906a8aa9c2 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Thu, 14 Oct 2021 09:23:35 -0500 Subject: [PATCH] Use newer split module flag with Swift 5.4 Uses the newer `-experimental-skip-non-inlinable-function-bodies-without-types` which was introduced here: https://github.com/apple/swift/pull/34612. This should improve LLDB usage in some cases. When using WMO, it has two downsides in Swift 5.5, both introduced by https://github.com/apple/swift/pull/38939: - The swiftmodules will have swiftdeps info embedded in them, which is only needed for incremental compilation - Interface hashing is enabled, which again is only needed for incremental compilation This is because the swift compiler only expects `-experimental-skip-non-inlinable-function-bodies-without-types` to be used with the new `emit-module-separately` incremental build. --- swift/internal/feature_names.bzl | 7 ++++++- swift/internal/features.bzl | 2 ++ swift/toolchains/config/compile_config.bzl | 9 +++++++++ test/split_derived_files_tests.bzl | 4 +++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/swift/internal/feature_names.bzl b/swift/internal/feature_names.bzl index 3242857a4..b01f227f7 100644 --- a/swift/internal/feature_names.bzl +++ b/swift/internal/feature_names.bzl @@ -316,9 +316,14 @@ SWIFT_FEATURE_GENERATE_PATH_TO_UNDERSCORES_FROM_PROTO_FILES = "swift.generate_pa SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION = "swift.split_derived_files_generation" # If enabled the skip function bodies frontend flag is passed when using derived -# files generation. This requires Swift 5.2 +# files generation. This requires Swift 5.2. SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES = "swift.skip_function_bodies_for_derived_files" +# If enabled the skip function bodies without types frontend flag is passed when +# using derived files generation. This takes precedence over +# swift.skip_function_bodies_for_derived_files. This requires Swift 5.4. +SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES = "swift.skip_function_bodies_without_types_for_derived_files" + # If enabled remap the absolute path to Xcode in debug info. When used with # swift.coverage_prefix_map also remap the path in coverage data. SWIFT_FEATURE_REMAP_XCODE_PATH = "swift.remap_xcode_path" diff --git a/swift/internal/features.bzl b/swift/internal/features.bzl index f088815e6..aa08f5d36 100644 --- a/swift/internal/features.bzl +++ b/swift/internal/features.bzl @@ -29,6 +29,7 @@ load( "SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX", "SWIFT_FEATURE_ENABLE_BATCH_MODE", "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES", + "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES", "SWIFT_FEATURE_ENABLE_TESTING", "SWIFT_FEATURE_ENABLE_V6", "SWIFT_FEATURE_FILE_PREFIX_MAP", @@ -257,6 +258,7 @@ def default_features_for_toolchain(target_triple): SWIFT_FEATURE_ENABLE_BARE_SLASH_REGEX, SWIFT_FEATURE_ENABLE_BATCH_MODE, SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES, + SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES, SWIFT_FEATURE_FILE_PREFIX_MAP, SWIFT_FEATURE_INTERNALIZE_AT_LINK, SWIFT_FEATURE_OPT_USES_WMO, diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index 588b36ae7..9c0b05c2c 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -55,6 +55,7 @@ load( "SWIFT_FEATURE_ENABLE_BATCH_MODE", "SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION", "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES", + "SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES", "SWIFT_FEATURE_ENABLE_TESTING", "SWIFT_FEATURE_ENABLE_V6", "SWIFT_FEATURE_FASTBUILD", @@ -1119,6 +1120,14 @@ def compile_action_configs( add_arg("-experimental-skip-non-inlinable-function-bodies"), ], features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES], + not_features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES], + ), + ActionConfigInfo( + actions = [SWIFT_ACTION_DERIVE_FILES], + configurators = [ + add_arg("-experimental-skip-non-inlinable-function-bodies-without-types"), + ], + features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES], ), # Configure index-while-building. diff --git a/test/split_derived_files_tests.bzl b/test/split_derived_files_tests.bzl index b53c7cbd6..3f7cd0f82 100644 --- a/test/split_derived_files_tests.bzl +++ b/test/split_derived_files_tests.bzl @@ -409,6 +409,7 @@ def split_derived_files_test_suite(name, tags = []): mnemonic = "SwiftCompile", not_expected_argv = [ "-experimental-skip-non-inlinable-function-bodies", + "-experimental-skip-non-inlinable-function-bodies-without-types", ], tags = all_tags, target_under_test = "//test/fixtures/debug_settings:simple", @@ -417,11 +418,12 @@ def split_derived_files_test_suite(name, tags = []): split_swiftmodule_skip_function_bodies_test( name = "{}_skip_function_bodies".format(name), expected_argv = [ - "-experimental-skip-non-inlinable-function-bodies", + "-experimental-skip-non-inlinable-function-bodies-without-types", ], mnemonic = "SwiftDeriveFiles", not_expected_argv = [ "-emit-object", + "-experimental-skip-non-inlinable-function-bodies", ], tags = all_tags, target_under_test = "//test/fixtures/debug_settings:simple",