@@ -18,10 +18,17 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
1818load (
1919 "@build_bazel_rules_swift//test/rules:actions_created_test.bzl" ,
2020 "actions_created_test" ,
21+ "make_actions_created_test_rule" ,
2122)
2223
2324visibility ("private" )
2425
26+ opt_actions_create_test = make_actions_created_test_rule (
27+ config_settings = {
28+ "//command_line_option:compilation_mode" : "opt" ,
29+ },
30+ )
31+
2532def parallel_compilation_test_suite (name , tags = []):
2633 """Test suite for parallel compilation.
2734
@@ -47,25 +54,46 @@ def parallel_compilation_test_suite(name, tags = []):
4754 target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:no_opt_with_wmo" ,
4855 )
4956
50- # Optimized, non-WMO cannot be compiled in parallel.
51- # TODO: b/351801556 - This is actually incorrect based on further driver
52- # testing; update the rules to allow compiling these in parallel.
57+ # Optimized, non-WMO can be compiled in parallel.
5358 actions_created_test (
5459 name = "{}_with_opt_no_wmo" .format (name ),
55- mnemonics = ["- SwiftCompileModule" , "- SwiftCompileCodegen" , "SwiftCompile" ],
60+ mnemonics = ["SwiftCompileModule" , "SwiftCompileCodegen" , "- SwiftCompile" ],
5661 tags = all_tags ,
5762 target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_no_wmo" ,
5863 )
5964
60- # Optimized, with-WMO cannot be compiled in parallel.
61- # TODO: b/351801556 - This should be allowed if cross-module-optimization is
62- # disabled. Update the rules to allow this and add a new version of this
63- # target that disables CMO so we can test both situtations.
65+ # Optimized, with-WMO can be compiled in parallel if CMO is also disabled.
66+ actions_created_test (
67+ name = "{}_with_opt_with_wmo_no_cmo" .format (name ),
68+ mnemonics = ["SwiftCompileModule" , "SwiftCompileCodegen" , "-SwiftCompile" ],
69+ tags = all_tags ,
70+ target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo_no_cmo" ,
71+ )
72+
73+ # Optimized, with-WMO cannot be compiled in parallel if CMO is enabled.
6474 actions_created_test (
65- name = "{}_with_opt_with_wmo " .format (name ),
75+ name = "{}_with_opt_with_wmo_with_cmo " .format (name ),
6676 mnemonics = ["-SwiftCompileModule" , "-SwiftCompileCodegen" , "SwiftCompile" ],
6777 tags = all_tags ,
68- target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo" ,
78+ target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo_with_cmo" ,
79+ )
80+
81+ # Force `-c opt` on a non-optimized, with-WMO target and make sure we don't
82+ # plan parallel compilation there.
83+ opt_actions_create_test (
84+ name = "{}_no_opt_with_wmo_but_compilation_mode_opt" .format (name ),
85+ mnemonics = ["-SwiftCompileModule" , "-SwiftCompileCodegen" , "SwiftCompile" ],
86+ tags = all_tags ,
87+ target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:no_opt_with_wmo" ,
88+ )
89+
90+ # Optimized, with-WMO can be compiled in parallel if library evolution is
91+ # enabled (which implicitly disables CMO).
92+ actions_created_test (
93+ name = "{}_with_opt_with_wmo_with_library_evolution" .format (name ),
94+ mnemonics = ["SwiftCompileModule" , "SwiftCompileCodegen" , "-SwiftCompile" ],
95+ tags = all_tags ,
96+ target_under_test = "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo_with_library_evolution" ,
6997 )
7098
7199 # Make sure that when we look for optimizer flags, we don't treat `-Onone`
@@ -85,7 +113,9 @@ def parallel_compilation_test_suite(name, tags = []):
85113 "@build_bazel_rules_swift//test/fixtures/parallel_compilation:no_opt_no_wmo" ,
86114 "@build_bazel_rules_swift//test/fixtures/parallel_compilation:no_opt_with_wmo" ,
87115 "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_no_wmo" ,
88- "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo" ,
116+ "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo_no_cmo" ,
117+ "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo_with_cmo" ,
118+ "@build_bazel_rules_swift//test/fixtures/parallel_compilation:with_opt_with_wmo_with_library_evolution" ,
89119 "@build_bazel_rules_swift//test/fixtures/parallel_compilation:onone_with_wmo" ,
90120 ],
91121 tags = all_tags ,
0 commit comments