Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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_FASTBUILD",
"SWIFT_FEATURE_FULL_DEBUG_INFO",
Expand Down Expand Up @@ -849,6 +850,16 @@ def compile_action_configs(
),
],
features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES],
not_features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES],
),
swift_toolchain_config.action_config(
actions = [swift_action_names.DERIVE_FILES],
configurators = [
swift_toolchain_config.add_arg(
"-experimental-skip-non-inlinable-function-bodies-without-types",
),
],
features = [SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES],
),
swift_toolchain_config.action_config(
actions = [swift_action_names.COMPILE],
Expand Down
7 changes: 6 additions & 1 deletion swift/internal/feature_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,14 @@ SWIFT_FEATURE_GENERATE_FROM_RAW_PROTO_FILES = "swift.generate_from_raw_proto_fil
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"
Expand Down
11 changes: 11 additions & 0 deletions swift/internal/swift_autoconfiguration.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ load(
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES",
"SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS",
"SWIFT_FEATURE_SUPPORTS_PRIVATE_DEPS",
"SWIFT_FEATURE_USE_RESPONSE_FILES",
Expand Down Expand Up @@ -84,6 +85,15 @@ def _check_skip_function_bodies(repository_ctx, swiftc_path, temp_dir):
"-experimental-skip-non-inlinable-function-bodies",
)

def _check_skip_function_bodies_without_types(repository_ctx, swiftc_path, temp_dir):
"""Returns True if `swiftc` supports skip function bodies."""
return _swift_succeeds(
repository_ctx,
swiftc_path,
"-version",
"-experimental-skip-non-inlinable-function-bodies-without-types",
)

def _check_debug_prefix_map(repository_ctx, swiftc_path, temp_dir):
"""Returns True if `swiftc` supports debug prefix mapping."""
return _swift_succeeds(
Expand Down Expand Up @@ -197,6 +207,7 @@ _FEATURE_CHECKS = {
SWIFT_FEATURE_DEBUG_PREFIX_MAP: _check_debug_prefix_map,
SWIFT_FEATURE_ENABLE_BATCH_MODE: _check_enable_batch_mode,
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES: _check_skip_function_bodies,
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES: _check_skip_function_bodies_without_types,
SWIFT_FEATURE_SUPPORTS_PRIVATE_DEPS: _check_supports_private_deps,
SWIFT_FEATURE_USE_RESPONSE_FILES: _check_use_response_files,
}
Expand Down
2 changes: 2 additions & 0 deletions swift/internal/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ load(
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES",
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
"SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS",
"SWIFT_FEATURE_REMAP_XCODE_PATH",
Expand Down Expand Up @@ -711,6 +712,7 @@ def _xcode_swift_toolchain_impl(ctx):

# Xcode 12.5 implies Swift 5.4.
if _is_xcode_at_least_version(xcode_config, "12.5"):
requested_features.append(SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES_WITHOUT_TYPES)
requested_features.append(SWIFT_FEATURE_SUPPORTS_SYSTEM_MODULE_FLAG)

env = _xcode_env(platform = platform, xcode_config = xcode_config)
Expand Down
4 changes: 3 additions & 1 deletion test/split_derived_files_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def split_derived_files_test_suite(name = "split_derived_files"):
mnemonic = "SwiftCompile",
not_expected_argv = [
"-experimental-skip-non-inlinable-function-bodies",
"-experimental-skip-non-inlinable-function-bodies-without-types",
],
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
Expand All @@ -286,11 +287,12 @@ def split_derived_files_test_suite(name = "split_derived_files"):
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 = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
Expand Down