Skip to content

Commit fc0aca0

Browse files
committed
Use newer split module flag with Swift 5.4
Uses the newer `-experimental-skip-non-inlinable-function-bodies-without-types` which was introduced here: swiftlang/swift#34612. This should improve LLDB usage in some cases. When using WMO, it has two downsides in Swift 5.5, both introduced by swiftlang/swift#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.
1 parent b94e084 commit fc0aca0

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

swift/internal/compiling.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ load(
4242
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
4343
"SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION",
4444
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
45+
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES",
4546
"SWIFT_FEATURE_ENABLE_TESTING",
4647
"SWIFT_FEATURE_FASTBUILD",
4748
"SWIFT_FEATURE_FULL_DEBUG_INFO",
@@ -849,6 +850,16 @@ def compile_action_configs(
849850
),
850851
],
851852
features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES],
853+
not_features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES],
854+
),
855+
swift_toolchain_config.action_config(
856+
actions = [swift_action_names.DERIVE_FILES],
857+
configurators = [
858+
swift_toolchain_config.add_arg(
859+
"-experimental-skip-non-inlinable-function-bodies-without-types",
860+
),
861+
],
862+
features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES],
852863
),
853864
swift_toolchain_config.action_config(
854865
actions = [swift_action_names.COMPILE],

swift/internal/feature_names.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,14 @@ SWIFT_FEATURE_GENERATE_FROM_RAW_PROTO_FILES = "swift.generate_from_raw_proto_fil
254254
SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION = "swift.split_derived_files_generation"
255255

256256
# If enabled the skip function bodies frontend flag is passed when using derived
257-
# files generation. This requires Swift 5.2
257+
# files generation. This requires Swift 5.2.
258258
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES = "swift.skip_function_bodies_for_derived_files"
259259

260+
# If enabled the skip function bodies without types frontend flag is passed when
261+
# using derived files generation. This takes precedence over
262+
# swift.skip_function_bodies_for_derived_files. This requires Swift 5.4.
263+
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES = "swift.skip_function_bodies_without_types_for_derived_files"
264+
260265
# If enabled remap the absolute path to Xcode in debug info. When used with
261266
# swift.coverage_prefix_map also remap the path in coverage data.
262267
SWIFT_FEATURE_REMAP_XCODE_PATH = "swift.remap_xcode_path"

swift/internal/swift_autoconfiguration.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ load(
2929
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
3030
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
3131
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
32+
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES",
3233
"SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS",
3334
"SWIFT_FEATURE_SUPPORTS_PRIVATE_DEPS",
3435
"SWIFT_FEATURE_USE_RESPONSE_FILES",
@@ -84,6 +85,15 @@ def _check_skip_function_bodies(repository_ctx, swiftc_path, temp_dir):
8485
"-experimental-skip-non-inlinable-function-bodies",
8586
)
8687

88+
def _check_skip_function_bodies_without_types(repository_ctx, swiftc_path, temp_dir):
89+
"""Returns True if `swiftc` supports skip function bodies."""
90+
return _swift_succeeds(
91+
repository_ctx,
92+
swiftc_path,
93+
"-version",
94+
"-experimental-skip-non-inlinable-function-bodies-without-types",
95+
)
96+
8797
def _check_debug_prefix_map(repository_ctx, swiftc_path, temp_dir):
8898
"""Returns True if `swiftc` supports debug prefix mapping."""
8999
return _swift_succeeds(
@@ -197,6 +207,7 @@ _FEATURE_CHECKS = {
197207
SWIFT_FEATURE_DEBUG_PREFIX_MAP: _check_debug_prefix_map,
198208
SWIFT_FEATURE_ENABLE_BATCH_MODE: _check_enable_batch_mode,
199209
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES: _check_skip_function_bodies,
210+
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES: _check_skip_function_bodies_without_types,
200211
SWIFT_FEATURE_SUPPORTS_PRIVATE_DEPS: _check_supports_private_deps,
201212
SWIFT_FEATURE_USE_RESPONSE_FILES: _check_use_response_files,
202213
}

swift/internal/xcode_swift_toolchain.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ load(
3636
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
3737
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
3838
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
39+
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES",
3940
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
4041
"SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS",
4142
"SWIFT_FEATURE_REMAP_XCODE_PATH",
@@ -711,6 +712,7 @@ def _xcode_swift_toolchain_impl(ctx):
711712

712713
# Xcode 12.5 implies Swift 5.4.
713714
if _is_xcode_at_least_version(xcode_config, "12.5"):
715+
requested_features.append(SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES)
714716
requested_features.append(SWIFT_FEATURE_SUPPORTS_SYSTEM_MODULE_FLAG)
715717

716718
env = _xcode_env(platform = platform, xcode_config = xcode_config)

test/split_derived_files_tests.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def split_derived_files_test_suite(name = "split_derived_files"):
278278
mnemonic = "SwiftCompile",
279279
not_expected_argv = [
280280
"-experimental-skip-non-inlinable-function-bodies",
281+
"-experimental-skip-non-inlinable-function-bodies-without-types",
281282
],
282283
tags = [name],
283284
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
@@ -286,11 +287,12 @@ def split_derived_files_test_suite(name = "split_derived_files"):
286287
split_swiftmodule_skip_function_bodies_test(
287288
name = "{}_skip_function_bodies".format(name),
288289
expected_argv = [
289-
"-experimental-skip-non-inlinable-function-bodies",
290+
"-experimental-skip-non-inlinable-function-bodies-without-types",
290291
],
291292
mnemonic = "SwiftDeriveFiles",
292293
not_expected_argv = [
293294
"-emit-object",
295+
"-experimental-skip-non-inlinable-function-bodies",
294296
],
295297
tags = [name],
296298
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",

0 commit comments

Comments
 (0)