Skip to content

Commit c970cb8

Browse files
committed
Add support for parallel compilation
1 parent 16ac29c commit c970cb8

File tree

5 files changed

+145
-154
lines changed

5 files changed

+145
-154
lines changed

swift/internal/action_names.bzl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@
2020
SWIFT_ACTION_AUTOLINK_EXTRACT = "SwiftAutolinkExtract"
2121

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

27+
# Emits the object files and other per-source-file outputs for a a batch of
28+
# `.swift` source files in a module.
29+
SWIFT_ACTION_COMPILE_CODEGEN = "SwiftCompileCodegen"
30+
31+
# Compiles one or more `.swift` source files into a `.swiftmodule`.
32+
SWIFT_ACTION_COMPILE_MODULE = "SwiftCompileModule"
33+
2634
# Compiles a `.swiftinterface` file into a `.swiftmodule` file.
2735
SWIFT_ACTION_COMPILE_MODULE_INTERFACE = "SwiftCompileModuleInterface"
2836

@@ -54,6 +62,8 @@ def all_action_names():
5462
return (
5563
SWIFT_ACTION_AUTOLINK_EXTRACT,
5664
SWIFT_ACTION_COMPILE,
65+
SWIFT_ACTION_COMPILE_CODEGEN,
66+
SWIFT_ACTION_COMPILE_MODULE,
5767
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
5868
SWIFT_ACTION_DERIVE_FILES,
5969
SWIFT_ACTION_DUMP_AST,
@@ -67,5 +77,6 @@ def all_compile_action_names():
6777
"""Returns all actions that compile source files."""
6878
return [
6979
SWIFT_ACTION_COMPILE,
70-
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
80+
SWIFT_ACTION_COMPILE_CODEGEN,
81+
SWIFT_ACTION_COMPILE_MODULE,
7182
]

swift/internal/feature_names.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ SWIFT_FEATURE_INTERNALIZE_AT_LINK = "swift.internalize_at_link"
369369
# This disables checking for potentially unavailable APIs.
370370
SWIFT_FEATURE_DISABLE_AVAILABILITY_CHECKING = "swift.disable_availability_checking"
371371

372+
# If enabled, parallelize the compilation of Swift modules and their object
373+
# files by registering separate actions for each.
374+
SWIFT_FEATURE_COMPILE_IN_PARALLEL = "swift.compile_in_parallel"
375+
372376
# A private feature that is set by the toolchain if it supports the
373377
# `-enable-{experimental,upcoming}-feature` flag (Swift 5.8 and above). Users
374378
# should never manually, enable, disable, or query this feature.

swift/providers.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ C/Objective-C modules:
336336
337337
For ease of use, this field is never `None`; it will always be a valid `struct`
338338
containing the fields described above, even if those lists are empty.
339+
""",
340+
"codegen_batch_size": """\
341+
The number of files to pass to the compiler in a single code generation action
342+
(one that compiles object files from Swift source files).
339343
""",
340344
"const_protocols_to_gather": """\
341345
`File`. A JSON file specifying a list of protocols for extraction of

0 commit comments

Comments
 (0)