Skip to content

Commit 9e79864

Browse files
committed
Force swift.compile_in_parallel in the tests that depend on looking up specific mnemonics.
Updates test using the `//test/fixtures/debug_settings:simple` target to check for parallel compilation mnemonic. NOTE: we dont seem to support batch mode correctly when parallel compilation is used without WMO Cherry-pick: 080e111
1 parent f846709 commit 9e79864

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

swift/internal/compiling.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,20 @@ def _should_plan_parallel_compilation(
770770
feature_name = SWIFT_FEATURE_COMPILE_IN_PARALLEL,
771771
)
772772

773+
# TODO: are we able to support split derived file generation in parallel, this feature is not in upstream.
774+
# For now, force non-parallel compilation when split derived file generation is enabled.
775+
split_derived_file_generation = is_feature_enabled(
776+
feature_configuration = feature_configuration,
777+
feature_name = SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION,
778+
)
779+
773780
# The Swift driver will not emit separate jobs to compile the module and to
774781
# perform codegen if optimization is requested. See
775782
# https://github.com/swiftlang/swift-driver/blob/c647e91574122f2b104d294ab1ec5baadaa1aa95/Sources/SwiftDriver/Jobs/EmitModuleJob.swift#L156-L181.
776783
opt_requested = is_optimization_manually_requested(
777784
user_compile_flags = user_compile_flags,
778785
)
779-
return parallel_requested and not opt_requested
786+
return parallel_requested and not opt_requested and not split_derived_file_generation
780787

781788
def _execute_compile_plan(
782789
actions,

test/fixtures/debug_settings/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ swift_library(
2323
],
2424
tags = FIXTURE_TAGS,
2525
)
26+
27+
# TODO: The `default_no_split_args` split_derived_files_generation is not supported in parallel.
28+
# We need to handle falling back to non-parallel compilation when this feature is enabled, but dont currently.
29+
swift_library(
30+
name = "simple_batch_mode",
31+
srcs = ["Empty.swift"],
32+
tags = FIXTURE_TAGS,
33+
)

test/split_derived_files_tests.bzl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ def split_derived_files_test_suite(name, tags = []):
138138
"-emit-module-path",
139139
"-emit-object",
140140
"-enable-batch-mode",
141-
"simple.output_file_map.json",
141+
"simple_batch_mode.output_file_map.json",
142142
],
143143
not_expected_argv = [
144-
"simple.derived_output_file_map.json",
144+
"simple_batch_mode.derived_output_file_map.json",
145145
],
146-
mnemonic = "SwiftCompileModule",
146+
mnemonic = "SwiftCompile",
147147
tags = all_tags,
148-
target_under_test = "//test/fixtures/debug_settings:simple",
148+
target_under_test = "//test/fixtures/debug_settings:simple_batch_mode",
149149
)
150150

151151
default_no_split_provider_test(
@@ -278,7 +278,7 @@ def split_derived_files_test_suite(name, tags = []):
278278
"-enable-batch-mode",
279279
"simple.output_file_map.json",
280280
],
281-
mnemonic = "SwiftCompileModule",
281+
mnemonic = "SwiftCompile",
282282
not_expected_argv = [
283283
"-emit-module-path",
284284
"simple.derived_output_file_map.json",
@@ -344,7 +344,7 @@ def split_derived_files_test_suite(name, tags = []):
344344
"-emit-object",
345345
"-whole-module-optimization",
346346
],
347-
mnemonic = "SwiftCompileModule",
347+
mnemonic = "SwiftCompile",
348348
not_expected_argv = [
349349
"-emit-module-path",
350350
],
@@ -406,7 +406,7 @@ def split_derived_files_test_suite(name, tags = []):
406406
expected_argv = [
407407
"-emit-object",
408408
],
409-
mnemonic = "SwiftCompileModule",
409+
mnemonic = "SwiftCompile",
410410
not_expected_argv = [
411411
"-experimental-skip-non-inlinable-function-bodies",
412412
],
@@ -433,7 +433,7 @@ def split_derived_files_test_suite(name, tags = []):
433433
"-emit-object",
434434
"-index-store-path",
435435
],
436-
mnemonic = "SwiftCompileModule",
436+
mnemonic = "SwiftCompile",
437437
not_expected_argv = [
438438
"-emit-module-path",
439439
],
@@ -458,7 +458,7 @@ def split_derived_files_test_suite(name, tags = []):
458458
split_swiftmodule_bitcode_test(
459459
name = "{}_bitcode_compile".format(name),
460460
expected_argv = ["-emit-bc"],
461-
mnemonic = "SwiftCompileModule",
461+
mnemonic = "SwiftCompile",
462462
tags = all_tags,
463463
target_under_test = "//test/fixtures/debug_settings:simple",
464464
)
@@ -480,7 +480,7 @@ def split_derived_files_test_suite(name, tags = []):
480480
"-Xcc -DWORLD=1",
481481
],
482482
target_compatible_with = ["@platforms//os:macos"],
483-
mnemonic = "SwiftCompileModule",
483+
mnemonic = "SwiftCompile",
484484
tags = all_tags,
485485
target_under_test = "//test/fixtures/debug_settings:simple",
486486
)

0 commit comments

Comments
 (0)