Skip to content

Commit 6ab4bec

Browse files
committed
Fix another edge case in compile planning; this time if -c opt is used and -wmo is passed on the command line.
Cherry-pick: 66a6a6b
1 parent 399a52f commit 6ab4bec

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

swift/internal/compiling.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,9 @@ def _should_plan_parallel_compilation(
802802
) or are_all_features_enabled(
803803
feature_configuration = feature_configuration,
804804
feature_names = [SWIFT_FEATURE_OPT, SWIFT_FEATURE_OPT_USES_WMO],
805+
) or is_feature_enabled(
806+
feature_configuration = feature_configuration,
807+
feature_name = SWIFT_FEATURE__WMO_IN_SWIFTCOPTS,
805808
)
806809
):
807810
return True

test/parallel_compilation_tests.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ opt_via_swiftcopt_actions_create_test = make_actions_created_test_rule(
3535
},
3636
)
3737

38+
opt_with_wmo_via_swiftcopt_actions_create_test = make_actions_created_test_rule(
39+
config_settings = {
40+
"//command_line_option:compilation_mode": "opt",
41+
str(Label("//swift:copt")): [
42+
"-whole-module-optimization",
43+
],
44+
},
45+
)
46+
3847
def parallel_compilation_test_suite(name, tags = []):
3948
"""Test suite for parallel compilation.
4049
@@ -120,6 +129,15 @@ def parallel_compilation_test_suite(name, tags = []):
120129
target_under_test = "//test/fixtures/parallel_compilation:onone_with_wmo",
121130
)
122131

132+
# Optimized (via `-c opt`) with-WMO cannot be compiled in parallel if CMO is
133+
# enabled (the default).
134+
opt_with_wmo_via_swiftcopt_actions_create_test(
135+
name = "{}_with_opt_via_compilation_mode_opt_with_wmo".format(name),
136+
mnemonics = ["-SwiftCompileModule", "-SwiftCompileCodegen", "SwiftCompile"],
137+
tags = all_tags,
138+
target_under_test = "//test/fixtures/parallel_compilation:no_opt_no_wmo",
139+
)
140+
123141
# The analysis tests verify that we register the actions we expect. Use a
124142
# `build_test` to make sure the actions execute successfully.
125143
build_test(

0 commit comments

Comments
 (0)