Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ed867ea
Breaking-change: remove support for incremental compilation mode
luispadron Sep 23, 2025
307108d
Breaking-change: remove support for persistent worker
luispadron Sep 23, 2025
05d08ea
Cherry-pick: sync swift_runner code with upstream
luispadron Sep 23, 2025
cca025a
Cherry-pick: remove remaining persistent worker support from the rule…
allevato Oct 26, 2023
f853330
Cherry-pick: add support for parallel compilation
luispadron Sep 24, 2025
8425381
Cherry-pick: Add initial parallel compilation support
luispadron Sep 24, 2025
a359ec6
Cherry-pick: Disable parallel compilation if an optimization flag in …
luispadron Sep 24, 2025
73f7559
Cherry-pick: simplify how we represent single-batch codegen jobs by p…
luispadron Sep 24, 2025
65dbe11
Fix: force swift.compile_in_parallel in the tests that depend on look…
luispadron Sep 24, 2025
9abec74
Cherry-pick: add tests for parallel compilation to make sure that the…
luispadron Sep 24, 2024
7687374
Cherry-pick: update parallel compilation to handle optimization corre…
luispadron Sep 26, 2024
3ae61f0
Fix: broken swift_runner progress messages
brentleyjones Sep 25, 2025
8f895bd
Cherry-pick: also detect `-O` flags being set via `--swiftcopt` when …
luispadron Oct 10, 2024
5299c39
Cherry-pick: fix another edge case in compile planning; this time if …
luispadron Oct 11, 2024
78e9a68
Breaking-change: fully remove split derived files feature
luispadron Dec 17, 2025
22aff3e
Fix: parallel compilation on Linux due to params file
luispadron Dec 19, 2025
3148da2
Chore: rebase and fix conflicts with latest main
luispadron Dec 17, 2025
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
4 changes: 3 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ bazel_dep(name = "apple_support", version = "1.24.2", repo_name = "build_bazel_a
bazel_dep(name = "rules_cc", version = "0.2.14")
bazel_dep(name = "rules_shell", version = "0.3.0")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "30.0", repo_name = "com_google_protobuf")
bazel_dep(name = "nlohmann_json", version = "3.12.0.bcr.1", repo_name = "com_github_nlohmann_json")
bazel_dep(name = "abseil-cpp", version = "20250127.0")
bazel_dep(name = "re2", version = "2025-11-05")
bazel_dep(
name = "swift_argument_parser",
version = "1.3.1.2",
Expand Down
14 changes: 8 additions & 6 deletions doc/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ Propagates Swift-specific information about a `proto_library`.

<pre>
SwiftToolchainInfo(<a href="#SwiftToolchainInfo-action_configs">action_configs</a>, <a href="#SwiftToolchainInfo-cc_language">cc_language</a>, <a href="#SwiftToolchainInfo-cc_toolchain_info">cc_toolchain_info</a>, <a href="#SwiftToolchainInfo-clang_implicit_deps_providers">clang_implicit_deps_providers</a>,
<a href="#SwiftToolchainInfo-const_protocols_to_gather">const_protocols_to_gather</a>, <a href="#SwiftToolchainInfo-cross_import_overlays">cross_import_overlays</a>, <a href="#SwiftToolchainInfo-debug_outputs_provider">debug_outputs_provider</a>,
<a href="#SwiftToolchainInfo-developer_dirs">developer_dirs</a>, <a href="#SwiftToolchainInfo-entry_point_linkopts_provider">entry_point_linkopts_provider</a>, <a href="#SwiftToolchainInfo-feature_allowlists">feature_allowlists</a>,
<a href="#SwiftToolchainInfo-generated_header_module_implicit_deps_providers">generated_header_module_implicit_deps_providers</a>, <a href="#SwiftToolchainInfo-implicit_deps_providers">implicit_deps_providers</a>,
<a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>, <a href="#SwiftToolchainInfo-requested_features">requested_features</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>,
<a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>, <a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
<a href="#SwiftToolchainInfo-codegen_batch_size">codegen_batch_size</a>, <a href="#SwiftToolchainInfo-const_protocols_to_gather">const_protocols_to_gather</a>, <a href="#SwiftToolchainInfo-cross_import_overlays">cross_import_overlays</a>,
<a href="#SwiftToolchainInfo-debug_outputs_provider">debug_outputs_provider</a>, <a href="#SwiftToolchainInfo-developer_dirs">developer_dirs</a>, <a href="#SwiftToolchainInfo-entry_point_linkopts_provider">entry_point_linkopts_provider</a>,
<a href="#SwiftToolchainInfo-feature_allowlists">feature_allowlists</a>, <a href="#SwiftToolchainInfo-generated_header_module_implicit_deps_providers">generated_header_module_implicit_deps_providers</a>,
<a href="#SwiftToolchainInfo-implicit_deps_providers">implicit_deps_providers</a>, <a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>,
<a href="#SwiftToolchainInfo-requested_features">requested_features</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>, <a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>,
<a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
</pre>

Propagates information about a Swift toolchain to compilation and linking rules
Expand All @@ -128,6 +129,7 @@ that use the toolchain.
| <a id="SwiftToolchainInfo-cc_language"></a>cc_language | The `language` that should be passed to `cc_common` APIs that take it as an argument. |
| <a id="SwiftToolchainInfo-cc_toolchain_info"></a>cc_toolchain_info | The `cc_common.CcToolchainInfo` provider from the Bazel C++ toolchain that this Swift toolchain depends on. |
| <a id="SwiftToolchainInfo-clang_implicit_deps_providers"></a>clang_implicit_deps_providers | A `struct` with the following fields, which represent providers from targets that should be added as implicit dependencies of any precompiled explicit C/Objective-C modules:<br><br>* `cc_infos`: A list of `CcInfo` providers from targets specified as the toolchain's implicit dependencies.<br><br>* `swift_infos`: A list of `SwiftInfo` providers from targets specified as the toolchain's implicit dependencies.<br><br>For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. |
| <a id="SwiftToolchainInfo-codegen_batch_size"></a>codegen_batch_size | The number of files to pass to the compiler in a single code generation action (one that compiles object files from Swift source files). |
| <a id="SwiftToolchainInfo-const_protocols_to_gather"></a>const_protocols_to_gather | `File`. A JSON file specifying a list of protocols for extraction of conformances' const values. |
| <a id="SwiftToolchainInfo-cross_import_overlays"></a>cross_import_overlays | A list of `SwiftCrossImportOverlayInfo` providers whose `SwiftInfo` providers will be automatically injected into the dependencies of Swift compilations if their declaring module and bystanding module are both already declared as dependencies. |
| <a id="SwiftToolchainInfo-debug_outputs_provider"></a>debug_outputs_provider | An optional function that provides toolchain-specific logic around the handling of additional debug outputs for `swift_binary` and `swift_test` targets.<br><br>If specified, this function must take the following keyword arguments:<br><br>* `ctx`: The rule context of the calling binary or test rule.<br><br>It must return a `struct` with the following fields:<br><br>* `additional_outputs`: Additional outputs expected from the linking action.<br><br>* `variables_extension`: A dictionary of additional crosstool variables to pass to the linking action. |
Expand All @@ -140,7 +142,7 @@ that use the toolchain.
| <a id="SwiftToolchainInfo-package_configurations"></a>package_configurations | A list of `SwiftPackageConfigurationInfo` providers that specify additional compilation configuration options that are applied to targets on a per-package basis. |
| <a id="SwiftToolchainInfo-requested_features"></a>requested_features | `List` of `string`s. Features that should be implicitly enabled by default for targets built using this toolchain, unless overridden by the user by listing their negation in the `features` attribute of a target/package or in the `--features` command line flag.<br><br>These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). |
| <a id="SwiftToolchainInfo-root_dir"></a>root_dir | `String`. The workspace-relative root directory of the toolchain. |
| <a id="SwiftToolchainInfo-swift_worker"></a>swift_worker | `File`. The executable representing the worker executable used to invoke the compiler and other Swift tools (for both incremental and non-incremental compiles). |
| <a id="SwiftToolchainInfo-swift_worker"></a>swift_worker | `File`. The executable that wraps Swift compiler invocations. |
| <a id="SwiftToolchainInfo-test_configuration"></a>test_configuration | `Struct` containing the following fields:<br><br>* `binary_name`: A template string used to compute the name of the output binary for `swift_test` rules. Any occurrences of the string `"{name}"` will be substituted by the name of the target.<br><br>* `env`: A `dict` of environment variables to be set when running tests that were built with this toolchain.<br><br>* `execution_requirements`: A `dict` of execution requirements for tests that were built with this toolchain.<br><br>* `objc_test_discovery`: A Boolean value indicating whether test targets should discover tests dynamically using the Objective-C runtime.<br><br>* `test_linking_contexts`: A list of `CcLinkingContext`s that provide additional flags to use when linking test binaries.<br><br>This is used, for example, with Xcode-based toolchains to ensure that the `xctest` helper and coverage tools are found in the correct developer directory when running tests. |
| <a id="SwiftToolchainInfo-tool_configs"></a>tool_configs | This field is an internal implementation detail of the build rules. |
| <a id="SwiftToolchainInfo-unsupported_features"></a>unsupported_features | `List` of `string`s. Features that should be implicitly disabled by default for targets built using this toolchain, unless overridden by the user by listing them in the `features` attribute of a target/package or in the `--features` command line flag.<br><br>These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). |
Expand Down
6 changes: 3 additions & 3 deletions swift/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ bzl_library(
":feature_names",
":features",
":module_maps",
":optimization",
":utils",
":vfsoverlay",
":wmo",
"//swift:providers",
"@bazel_skylib//lib:paths",
"@bazel_skylib//lib:sets",
Expand Down Expand Up @@ -314,8 +314,8 @@ bzl_library(
)

bzl_library(
name = "wmo",
srcs = ["wmo.bzl"],
name = "optimization",
srcs = ["optimization.bzl"],
visibility = ["//swift:__subpackages__"],
deps = [
":feature_names",
Expand Down
20 changes: 13 additions & 7 deletions swift/internal/action_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@
SWIFT_ACTION_AUTOLINK_EXTRACT = "SwiftAutolinkExtract"

# Compiles one or more `.swift` source files into a `.swiftmodule` and
# object files.
# object files. This is the legacy mode that emits all outputs from a single
# driver invocation.
SWIFT_ACTION_COMPILE = "SwiftCompile"

# Emits the object files and other per-source-file outputs for a a batch of
# `.swift` source files in a module.
SWIFT_ACTION_COMPILE_CODEGEN = "SwiftCompileCodegen"

# Compiles one or more `.swift` source files into a `.swiftmodule`.
SWIFT_ACTION_COMPILE_MODULE = "SwiftCompileModule"

# Compiles a `.swiftinterface` file into a `.swiftmodule` file.
SWIFT_ACTION_COMPILE_MODULE_INTERFACE = "SwiftCompileModuleInterface"

# Produces files that are usually fallout of the compilation such as
# .swiftmodule, -Swift.h and more.
SWIFT_ACTION_DERIVE_FILES = "SwiftDeriveFiles"

# Produces an AST file for each swift source file in a module.
SWIFT_ACTION_DUMP_AST = "SwiftDumpAST"

Expand All @@ -54,8 +58,9 @@ def all_action_names():
return (
SWIFT_ACTION_AUTOLINK_EXTRACT,
SWIFT_ACTION_COMPILE,
SWIFT_ACTION_COMPILE_CODEGEN,
SWIFT_ACTION_COMPILE_MODULE,
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
SWIFT_ACTION_DERIVE_FILES,
SWIFT_ACTION_DUMP_AST,
SWIFT_ACTION_MODULEWRAP,
SWIFT_ACTION_PRECOMPILE_C_MODULE,
Expand All @@ -67,5 +72,6 @@ def all_compile_action_names():
"""Returns all actions that compile source files."""
return [
SWIFT_ACTION_COMPILE,
SWIFT_ACTION_DERIVE_FILES,
SWIFT_ACTION_COMPILE_CODEGEN,
SWIFT_ACTION_COMPILE_MODULE,
]
12 changes: 1 addition & 11 deletions swift/internal/actions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,7 @@ def run_toolchain_action(
# tool as the executable directly.
tools = []
tool_executable_args = actions.args()
if tool_config.worker_mode:
# Only enable persistent workers if the toolchain supports response
# files, because the worker unconditionally writes its arguments into
# one to prevent command line overflow in this mode.
if (
tool_config.worker_mode == "persistent" and
tool_config.use_param_file
):
execution_requirements["supports-workers"] = "1"
execution_requirements["requires-worker-protocol"] = "json"

if tool_config.wrapped_by_worker:
executable = swift_toolchain.swift_worker
tool_executable_args.add(tool_config.executable)
if not types.is_string(tool_config.executable):
Expand Down
Loading