@@ -2162,11 +2162,6 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2162
2162
return ( inputs, outputs)
2163
2163
} ( )
2164
2164
2165
- if cbc. scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_MODULEWRAP) && cbc. scope. evaluate ( BuiltinMacros . GCC_GENERATE_DEBUGGING_SYMBOLS) {
2166
- let moduleWrapOutput = Path ( moduleFilePath. withoutSuffix + " .o " )
2167
- moduleOutputPaths. append ( moduleWrapOutput)
2168
- }
2169
-
2170
2165
// Add const metadata outputs to extra compilation outputs
2171
2166
if await supportConstSupplementaryMetadata ( cbc, delegate, compilationMode: compilationMode) {
2172
2167
// If using whole module optimization then we use the -primary.swiftconstvalues file from the sole compilation task.
@@ -2254,6 +2249,7 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2254
2249
return nil
2255
2250
} ( )
2256
2251
2252
+ let emittingModuleSeparately : Bool
2257
2253
if eagerCompilationEnabled ( args: args, scope: cbc. scope, compilationMode: compilationMode, isUsingWholeModuleOptimization: isUsingWholeModuleOptimization) {
2258
2254
if isUsingWholeModuleOptimization {
2259
2255
args += [ " -emit-module-separately-wmo " ]
@@ -2262,8 +2258,24 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2262
2258
}
2263
2259
// Cross-module optimization is not supported when emitting the swiftmodule separately.
2264
2260
args += [ " -disable-cmo " ]
2261
+ emittingModuleSeparately = true
2265
2262
} else if isUsingWholeModuleOptimization && !usingLegacyDriver {
2266
2263
args += [ " -no-emit-module-separately-wmo " ]
2264
+ emittingModuleSeparately = false
2265
+ } else {
2266
+ // Conservatively assume we're not emitting a module separately in the fallback case.
2267
+ emittingModuleSeparately = false
2268
+ }
2269
+
2270
+ // Conditions which all must be met to enable module wrapping:
2271
+ // 1. The platform must require it
2272
+ // 2. We must be compiling with debug info
2273
+ // 3. We must be emitting a module separately
2274
+ if cbc. scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_MODULEWRAP) &&
2275
+ cbc. scope. evaluate ( BuiltinMacros . GCC_GENERATE_DEBUGGING_SYMBOLS) &&
2276
+ emittingModuleSeparately {
2277
+ let moduleWrapOutput = Path ( moduleFilePath. withoutSuffix + " .o " )
2278
+ moduleOutputPaths. append ( moduleWrapOutput)
2267
2279
}
2268
2280
2269
2281
// The rule info.
0 commit comments