Skip to content

Commit 83a56f6

Browse files
committed
Pass -enable-cmo-everything to frontend jobs.
Resolves rdar://128401284.
1 parent d14d614 commit 83a56f6

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Sources/SwiftDriver/Jobs/CompileJob.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ extension Driver {
296296
if Driver.canDoCrossModuleOptimization(parsedOptions: &parsedOptions) &&
297297
// For historical reasons, -cross-module-optimization turns on "aggressive" CMO
298298
// which is different from "default" CMO.
299-
!parsedOptions.hasArgument(.CrossModuleOptimization) {
299+
!parsedOptions.hasArgument(.CrossModuleOptimization) &&
300+
!parsedOptions.hasArgument(.EnableCMOEverything) {
300301
assert(!emitModuleSeparately, "Cannot emit module separately with cross-module-optimization")
301302
commandLine.appendFlag("-enable-default-cmo")
302303
}
@@ -370,6 +371,7 @@ extension Driver {
370371

371372
try commandLine.appendLast(.trackSystemDependencies, from: &parsedOptions)
372373
try commandLine.appendLast(.CrossModuleOptimization, from: &parsedOptions)
374+
try commandLine.appendLast(.EnableCMOEverything, from: &parsedOptions)
373375
try commandLine.appendLast(.ExperimentalPerformanceAnnotations, from: &parsedOptions)
374376

375377
try commandLine.appendLast(.runtimeCompatibilityVersion, from: &parsedOptions)

Tests/SwiftDriverTests/SwiftDriverTests.swift

+19-1
Original file line numberDiff line numberDiff line change
@@ -3643,6 +3643,24 @@ final class SwiftDriverTests: XCTestCase {
36433643
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-enable-default-cmo")))
36443644
}
36453645

3646+
do {
3647+
// -cross-module-optimization should supersede -enable-default-cmo
3648+
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test", "-emit-module-path", rebase("Test.swiftmodule", at: root), "-c", "-o", rebase("test.o", at: root), "-wmo", "-O", "-cross-module-optimization"])
3649+
let plannedJobs = try driver.planBuild()
3650+
XCTAssertEqual(plannedJobs.count, 1)
3651+
XCTAssertFalse(plannedJobs[0].commandLine.contains(.flag("-enable-default-cmo")))
3652+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-cross-module-optimization")))
3653+
}
3654+
3655+
do {
3656+
// -enable-cmo-everything should supersede -enable-default-cmo
3657+
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test", "-emit-module-path", rebase("Test.swiftmodule", at: root), "-c", "-o", rebase("test.o", at: root), "-wmo", "-O", "-enable-cmo-everything"])
3658+
let plannedJobs = try driver.planBuild()
3659+
XCTAssertEqual(plannedJobs.count, 1)
3660+
XCTAssertFalse(plannedJobs[0].commandLine.contains(.flag("-enable-default-cmo")))
3661+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-enable-cmo-everything")))
3662+
}
3663+
36463664
do {
36473665
// library-evolution builds can emit the module in a separate job.
36483666
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test", "-emit-module-path", rebase("Test.swiftmodule", at: root), "-c", "-o", rebase("test.o", at: root), "-wmo", "-O", "-enable-library-evolution" ])
@@ -3671,7 +3689,7 @@ final class SwiftDriverTests: XCTestCase {
36713689
}
36723690

36733691
do {
3674-
// Don't use emit-module-separetely as a linker.
3692+
// Don't use emit-module-separately as a linker.
36753693
var driver = try Driver(args: ["swiftc", "foo.sil", "bar.sil", "-module-name", "Test", "-emit-module-path", "/foo/bar/Test.swiftmodule", "-emit-library", "-target", "x86_64-apple-macosx10.15", "-wmo", "-emit-module-separately-wmo"],
36763694
env: envVars)
36773695
let plannedJobs = try driver.planBuild()

0 commit comments

Comments
 (0)