From 166a3b864d33a01ee82012e2e6ff2414a69606bb Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Thu, 25 Sep 2025 13:58:22 -0500 Subject: [PATCH 1/2] Fix `swift.split_derived_files_generation` Signed-off-by: Brentley Jones --- swift/internal/action_names.bzl | 2 +- swift/internal/compiling.bzl | 8 +- swift/toolchains/config/compile_config.bzl | 109 ++++++++++++++++++--- 3 files changed, 99 insertions(+), 20 deletions(-) diff --git a/swift/internal/action_names.bzl b/swift/internal/action_names.bzl index c14ad507c..3e2ae54c8 100644 --- a/swift/internal/action_names.bzl +++ b/swift/internal/action_names.bzl @@ -67,5 +67,5 @@ def all_compile_action_names(): """Returns all actions that compile source files.""" return [ SWIFT_ACTION_COMPILE, - SWIFT_ACTION_COMPILE_MODULE_INTERFACE, + SWIFT_ACTION_DERIVE_FILES, ] diff --git a/swift/internal/compiling.bzl b/swift/internal/compiling.bzl index 5c23da2be..a80c1420d 100644 --- a/swift/internal/compiling.bzl +++ b/swift/internal/compiling.bzl @@ -520,10 +520,7 @@ def compile( if split_derived_file_generation: all_compile_outputs = compact([ - compile_outputs.swiftinterface_file, - compile_outputs.private_swiftinterface_file, compile_outputs.indexstore_directory, - compile_outputs.macro_expansion_directory, ]) + compile_outputs.object_files + compile_outputs.const_values_files all_derived_outputs = compact([ # The `.swiftmodule` file is explicitly listed as the first output @@ -531,9 +528,12 @@ def compile( # various things (such as the filename prefix for param files generated # for that action). This guarantees some predictability. compile_outputs.swiftmodule_file, + compile_outputs.generated_header_file, + compile_outputs.macro_expansion_directory, compile_outputs.swiftdoc_file, + compile_outputs.swiftinterface_file, + compile_outputs.private_swiftinterface_file, compile_outputs.swiftsourceinfo_file, - compile_outputs.generated_header_file, ]) else: all_compile_outputs = compact([ diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index 588b36ae7..76cc87afb 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -177,7 +177,10 @@ def compile_action_configs( # Don't embed Clang module breadcrumbs in debug info. ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [ add_arg("-Xfrontend", "-no-clang-module-breadcrumbs"), ], @@ -224,6 +227,13 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + ], + configurators = [_emit_module_interface_path_configurator], + features = [SWIFT_FEATURE_EMIT_SWIFTINTERFACE], + not_features = [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION], + ), + ActionConfigInfo( + actions = [ SWIFT_ACTION_DERIVE_FILES, ], configurators = [_emit_module_interface_path_configurator], @@ -232,6 +242,13 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + ], + configurators = [_emit_private_module_interface_path_configurator], + features = [SWIFT_FEATURE_EMIT_PRIVATE_SWIFTINTERFACE], + not_features = [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION], + ), + ActionConfigInfo( + actions = [ SWIFT_ACTION_DERIVE_FILES, ], configurators = [_emit_private_module_interface_path_configurator], @@ -251,7 +268,10 @@ def compile_action_configs( # Configure enforce exclusivity checks if enabled. ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [add_arg("-enforce-exclusivity=checked")], features = [SWIFT_FEATURE_CHECKED_EXCLUSIVITY], ), @@ -264,12 +284,18 @@ def compile_action_configs( # Link Time Optimization (LTO). ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [add_arg("-lto=llvm-thin")], features = [SWIFT_FEATURE_THIN_LTO], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [add_arg("-lto=llvm-full")], features = [SWIFT_FEATURE_FULL_LTO], ), @@ -294,7 +320,10 @@ def compile_action_configs( action_configs.append( ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [generated_header_rewriter_configurator], features = [SWIFT_FEATURE_REWRITE_GENERATED_HEADER], ), @@ -376,7 +405,10 @@ def compile_action_configs( # Improve dead-code stripping. ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [add_arg("-Xfrontend", "-internalize-at-link")], features = [SWIFT_FEATURE_INTERNALIZE_AT_LINK], ), @@ -572,6 +604,14 @@ def compile_action_configs( ], configurators = [add_arg("-Xwrapped-swift=-emit-swiftsourceinfo")], features = [SWIFT_FEATURE_DECLARE_SWIFTSOURCEINFO], + not_features = [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION], + ), + ActionConfigInfo( + actions = [ + SWIFT_ACTION_DERIVE_FILES, + ], + configurators = [add_arg("-Xwrapped-swift=-emit-swiftsourceinfo")], + features = [SWIFT_FEATURE_DECLARE_SWIFTSOURCEINFO], ), ] @@ -614,12 +654,18 @@ def compile_action_configs( ], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [add_arg("-sanitize=thread")], features = ["tsan"], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [ add_arg("-sanitize=undefined"), ], @@ -631,7 +677,10 @@ def compile_action_configs( action_configs.append( # Support for order-file instrumentation. ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [ add_arg("-sanitize=undefined"), add_arg("-sanitize-coverage=func"), @@ -859,7 +908,10 @@ def compile_action_configs( features = [SWIFT_FEATURE_VFSOVERLAY], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [_module_aliases_configurator], ), ActionConfigInfo( @@ -872,6 +924,18 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + ], + configurators = [_macro_expansion_configurator], + # The compiler only generates these in debug builds, unless we pass + # additional frontend flags. At the current time, we only want to + # capture these for debug builds. + not_features = [ + [SWIFT_FEATURE_OPT], + [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION], + ], + ), + ActionConfigInfo( + actions = [ SWIFT_ACTION_DERIVE_FILES, ], configurators = [_macro_expansion_configurator], @@ -1123,12 +1187,16 @@ def compile_action_configs( # Configure index-while-building. ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + ], configurators = [_index_while_building_configurator], features = [SWIFT_FEATURE_INDEX_WHILE_BUILDING], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + ], configurators = [add_arg("-index-include-locals")], features = [ SWIFT_FEATURE_INDEX_WHILE_BUILDING, @@ -1136,7 +1204,9 @@ def compile_action_configs( ], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + ], configurators = [add_arg("-index-ignore-system-modules")], features = [ SWIFT_FEATURE_INDEX_WHILE_BUILDING, @@ -1144,7 +1214,9 @@ def compile_action_configs( ], ), ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + ], configurators = [ add_arg("-index-ignore-clang-modules"), ], @@ -1181,7 +1253,10 @@ def compile_action_configs( # Disable auto-linking for prebuilt static frameworks. ActionConfigInfo( - actions = [SWIFT_ACTION_COMPILE], + actions = [ + SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [_frameworks_disable_autolink_configurator], ), @@ -1207,6 +1282,7 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, ], configurators = [add_arg("-Xfrontend", "-disable-clang-spi")], features = [ @@ -1216,6 +1292,7 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, ], configurators = [add_arg("-Xfrontend", "-disable-availability-checking")], features = [ @@ -1225,6 +1302,7 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, ], configurators = [_upcoming_and_experimental_features_configurator], features = [ @@ -1234,6 +1312,7 @@ def compile_action_configs( ActionConfigInfo( actions = [ SWIFT_ACTION_COMPILE, + SWIFT_ACTION_DERIVE_FILES, ], configurators = [add_arg("-swift-version", "6")], features = [ From 08211cb56d058e26bfffa45d39c9a4f08cd0041e Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Thu, 25 Sep 2025 15:28:25 -0500 Subject: [PATCH 2/2] More Signed-off-by: Brentley Jones --- swift/toolchains/config/compile_config.bzl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index 76cc87afb..771eeec5a 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -320,10 +320,19 @@ def compile_action_configs( action_configs.append( ActionConfigInfo( - actions = [ - SWIFT_ACTION_COMPILE, - SWIFT_ACTION_DERIVE_FILES, - ], + actions = [ + SWIFT_ACTION_COMPILE, + ], + configurators = [generated_header_rewriter_configurator], + features = [SWIFT_FEATURE_REWRITE_GENERATED_HEADER], + not_features = [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION], + ), + ) + action_configs.append( + ActionConfigInfo( + actions = [ + SWIFT_ACTION_DERIVE_FILES, + ], configurators = [generated_header_rewriter_configurator], features = [SWIFT_FEATURE_REWRITE_GENERATED_HEADER], ),