From 311176bd3ad7f2b27cce3ac9d2ad2a939f4d5c4a Mon Sep 17 00:00:00 2001 From: Adin Cebic Date: Sun, 6 Sep 2026 14:34:35 +0200 Subject: [PATCH] stop --- swift/internal/feature_names.bzl | 4 +- swift/toolchains/config/compile_config.bzl | 18 ++------ test/split_derived_files_tests.bzl | 50 ++++++++++++++++++++++ tools/worker/output_file_map.cc | 8 ---- tools/worker/swift_runner.cc | 16 ------- tools/worker/swift_runner.h | 6 --- tools/worker/work_processor.cc | 15 ------- 7 files changed, 55 insertions(+), 62 deletions(-) diff --git a/swift/internal/feature_names.bzl b/swift/internal/feature_names.bzl index 9aef88ab1..bf1aa1bee 100644 --- a/swift/internal/feature_names.bzl +++ b/swift/internal/feature_names.bzl @@ -308,8 +308,8 @@ SWIFT_FEATURE_EMIT_PRIVATE_SWIFTINTERFACE = "swift.emit_private_swiftinterface" # any of the existing compiler flags. Only enable this feature if such # non-determinism does not negatively impact you. # -# Note: If opted out of this feature, .swiftsourceinfo are generated by the -# compiler but excluded from Bazel's tracking. +# If opted out of this feature, the compiler is instructed not to generate a +# `.swiftsourceinfo` file. SWIFT_FEATURE_DECLARE_SWIFTSOURCEINFO = "swift.emit_swiftsourceinfo" # If enabled, the .swiftmodule file for the affected target will not be diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index d9724b9ed..8c9a94eb2 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -580,22 +580,10 @@ def compile_action_configs( ], not_features = [SWIFT_FEATURE_COVERAGE_PREFIX_MAP, SWIFT_FEATURE_FILE_PREFIX_MAP], ), - - # Ensure that .swiftsourceinfo files are tracked and not deleted by the worker ActionConfigInfo( - actions = [ - SWIFT_ACTION_COMPILE, - ], - 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], + actions = all_compile_action_names(), + configurators = [add_arg("-avoid-emit-module-source-info")], + not_features = [SWIFT_FEATURE_DECLARE_SWIFTSOURCEINFO], ), ] diff --git a/test/split_derived_files_tests.bzl b/test/split_derived_files_tests.bzl index b53c7cbd6..1c4712ef7 100644 --- a/test/split_derived_files_tests.bzl +++ b/test/split_derived_files_tests.bzl @@ -25,6 +25,14 @@ default_no_split_emit_swiftsourceinfo_provider_test = make_provider_test_rule( }, ) +default_no_split_emit_swiftsourceinfo_test = make_action_command_line_test_rule( + config_settings = { + "//command_line_option:features": [ + "swift.emit_swiftsourceinfo", + ], + }, +) + split_swiftmodule_test = make_action_command_line_test_rule( config_settings = { "//command_line_option:features": [ @@ -61,6 +69,15 @@ split_emit_swiftsourceinfo_provider_test = make_provider_test_rule( }, ) +split_emit_swiftsourceinfo_test = make_action_command_line_test_rule( + config_settings = { + "//command_line_option:features": [ + "swift.emit_swiftsourceinfo", + "swift.split_derived_files_generation", + ], + }, +) + split_no_emit_swiftdoc_provider_test = make_provider_test_rule( config_settings = { "//command_line_option:features": [ @@ -135,6 +152,7 @@ def split_derived_files_test_suite(name, tags = []): default_no_split_test( name = "{}_default_no_split_args".format(name), expected_argv = [ + "-avoid-emit-module-source-info", "-emit-module-path", "-emit-object", "-enable-batch-mode", @@ -148,6 +166,16 @@ def split_derived_files_test_suite(name, tags = []): target_under_test = "//test/fixtures/debug_settings:simple", ) + default_no_split_emit_swiftsourceinfo_test( + name = "{}_default_no_split_emit_swiftsourceinfo_args".format(name), + mnemonic = "SwiftCompile", + not_expected_argv = [ + "-avoid-emit-module-source-info", + ], + tags = all_tags, + target_under_test = "//test/fixtures/debug_settings:simple", + ) + default_no_split_provider_test( name = "{}_default_no_split_provider_swiftmodule".format(name), expected_files = [ @@ -274,6 +302,7 @@ def split_derived_files_test_suite(name, tags = []): split_swiftmodule_test( name = "{}_object_only".format(name), expected_argv = [ + "-avoid-emit-module-source-info", "-emit-object", "-enable-batch-mode", "simple.output_file_map.json", @@ -290,6 +319,7 @@ def split_derived_files_test_suite(name, tags = []): split_swiftmodule_test( name = "{}_swiftmodule_only".format(name), expected_argv = [ + "-avoid-emit-module-source-info", "-emit-module-path", "-enable-batch-mode", "simple.derived_output_file_map.json", @@ -303,6 +333,26 @@ def split_derived_files_test_suite(name, tags = []): target_under_test = "//test/fixtures/debug_settings:simple", ) + split_emit_swiftsourceinfo_test( + name = "{}_object_only_emit_swiftsourceinfo".format(name), + mnemonic = "SwiftCompile", + not_expected_argv = [ + "-avoid-emit-module-source-info", + ], + tags = all_tags, + target_under_test = "//test/fixtures/debug_settings:simple", + ) + + split_emit_swiftsourceinfo_test( + name = "{}_swiftmodule_only_emit_swiftsourceinfo".format(name), + mnemonic = "SwiftDeriveFiles", + not_expected_argv = [ + "-avoid-emit-module-source-info", + ], + tags = all_tags, + target_under_test = "//test/fixtures/debug_settings:simple", + ) + split_swiftmodule_provider_test( name = "{}_split_provider".format(name), expected_files = [ diff --git a/tools/worker/output_file_map.cc b/tools/worker/output_file_map.cc index 5d0f5edbd..03339a7fb 100644 --- a/tools/worker/output_file_map.cc +++ b/tools/worker/output_file_map.cc @@ -163,14 +163,6 @@ void OutputFileMap::UpdateForIncremental( auto copied_swiftdoc_path = MakeIncrementalOutputPath(swiftdoc_path, derived); incremental_inputs[swiftdoc_path] = copied_swiftdoc_path; - - std::string swiftsourceinfo_path = - std::filesystem::path(swiftmodule_path) - .replace_extension(".swiftsourceinfo") - .string(); - auto copied_swiftsourceinfo_path = - MakeIncrementalOutputPath(swiftsourceinfo_path, derived); - incremental_inputs[swiftsourceinfo_path] = copied_swiftsourceinfo_path; } if (!emit_objc_header_path.empty()) { diff --git a/tools/worker/swift_runner.cc b/tools/worker/swift_runner.cc index 79722802f..5c96bb9a0 100644 --- a/tools/worker/swift_runner.cc +++ b/tools/worker/swift_runner.cc @@ -472,17 +472,6 @@ SwiftRunner::SwiftRunner(const std::vector& args, } int SwiftRunner::Run(std::ostream* stderr_stream, bool stdout_to_stderr) { - // In rules_swift < 3.x the .swiftsourceinfo files are unconditionally written - // to the module path. In rules_swift >= 3.x these same files are no longer - // tracked by Bazel unless explicitly requested. When using non-sandboxed - // mode, previous builds will contain these files and cause build failures - // when Swift tries to use them, in order to work around this compatibility - // issue, we check the module path for the presence of .swiftsourceinfo files - // and if they are present but not requested, we remove them. - if (swift_source_info_path_ != "" && !emit_swift_source_info_) { - std::filesystem::remove(swift_source_info_path_); - } - int exit_code = 0; // Do the layering check before compilation. This gives a better error @@ -759,8 +748,6 @@ std::vector SwiftRunner::ParseArguments(Iterator itr) { target_label_ = std::string(value); } else if (absl::ConsumePrefix(&value, "-layering-check-deps-modules=")) { deps_modules_path_ = std::string(value); - } else if (value == "-emit-swiftsourceinfo") { - emit_swift_source_info_ = true; } else if (value == "-hermetic-pcm") { hermetic_pcm_ = true; } else if (absl::ConsumePrefix( @@ -779,9 +766,6 @@ std::vector SwiftRunner::ParseArguments(Iterator itr) { } else if (arg == "-emit-module-path") { ++it; emit_module_path_ = *it; - std::filesystem::path module_path(*it); - swift_source_info_path_ = - module_path.replace_extension(".swiftsourceinfo").string(); out_args.push_back(*it); } else if (arg == "-module-name") { ++it; diff --git a/tools/worker/swift_runner.h b/tools/worker/swift_runner.h index 125a93397..5ea77af2b 100644 --- a/tools/worker/swift_runner.h +++ b/tools/worker/swift_runner.h @@ -223,12 +223,6 @@ class SwiftRunner { // index outputs into the `index_store_path` to integrate outputs with Bazel. std::string global_index_store_import_path_; - // The path where the module files will be written - std::string swift_source_info_path_; - - // Whether `.swiftsourceinfo` files are being generated. - bool emit_swift_source_info_; - // Whether `-Xwrapped-swift=-hermetic-pcm` was passed bool hermetic_pcm_; diff --git a/tools/worker/work_processor.cc b/tools/worker/work_processor.cc index 049f30b80..b0a93265b 100644 --- a/tools/worker/work_processor.cc +++ b/tools/worker/work_processor.cc @@ -89,7 +89,6 @@ void WorkProcessor::ProcessWorkRequest( std::string emit_objc_header_path; bool is_wmo = false; bool is_dump_ast = false; - bool emit_swift_source_info = false; std::string prev_arg; for (std::string arg : request.arguments) { @@ -114,8 +113,6 @@ void WorkProcessor::ProcessWorkRequest( emit_objc_header_path = arg; } else if (ArgumentEnablesWMO(arg)) { is_wmo = true; - } else if (prev_arg == "-Xwrapped-swift=-emit-swiftsourceinfo") { - emit_swift_source_info = true; } if (!arg.empty()) { @@ -167,18 +164,6 @@ void WorkProcessor::ProcessWorkRequest( const auto expected_object_path = std::filesystem::path(expected_object_pair.second); - // In rules_swift < 3.x the .swiftsourceinfo files are unconditionally - // written to the module path. In rules_swift >= 3.x these same files are - // no longer tracked by Bazel unless explicitly requested. When using - // non-sandboxed mode, previous builds will contain these files and cause - // build failures when Swift tries to use them, in order to work around - // this compatibility issue, we remove them if they are present but not - // requested. - if (!emit_swift_source_info && - expected_object_path.extension() == ".swiftsourceinfo") { - std::filesystem::remove(LongPath(expected_object_path)); - } - // Bazel creates the intermediate directories for the files declared at // analysis time, but not any any deeper directories, like one can have // with -emit-objc-header-path, so we need to create those.