@@ -230,18 +230,14 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
230230 commandLine: & commandLine)
231231
232232 let moduleMapPath = moduleDetails. moduleMapPath. path
233- // Encode the target triple pcm args into the output `.pcm` filename
234- let targetEncodedModulePath =
235- try targetEncodedClangModuleFilePath ( for: moduleInfo,
236- hashParts: getPCMHashParts ( pcmArgs: pcmArgs,
237- contextHash: moduleDetails. contextHash) )
238- outputs. append ( TypedVirtualPath ( file: targetEncodedModulePath, type: . pcm) )
233+ let modulePCMPath = moduleInfo. modulePath
234+ outputs. append ( TypedVirtualPath ( file: modulePCMPath. path, type: . pcm) )
239235 commandLine. appendFlags ( " -emit-pcm " , " -module-name " , moduleId. moduleName,
240- " -o " , targetEncodedModulePath . description)
236+ " -o " , modulePCMPath . path . description)
241237
242238 // Fixup "-o -Xcc '<replace-me>'"
243239 if let outputIndex = commandLine. firstIndex ( of: . flag( " <replace-me> " ) ) {
244- commandLine [ outputIndex] = . path( VirtualPath . lookup ( targetEncodedModulePath ) )
240+ commandLine [ outputIndex] = . path( VirtualPath . lookup ( modulePCMPath . path ) )
245241 }
246242
247243 // The only required input is the .modulemap for this module.
@@ -300,21 +296,23 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
300296 let clangModulePath =
301297 TypedVirtualPath ( file: moduleArtifactInfo. modulePath. path,
302298 type: . pcm)
299+ let clangModuleMapPath =
300+ TypedVirtualPath ( file: moduleArtifactInfo. moduleMapPath. path,
301+ type: . clangModuleMap)
302+ inputs. append ( clangModulePath)
303+ inputs. append ( clangModuleMapPath)
304+
303305 // If an existing dependency module path stub exists, replace it.
304306 if let existingIndex = commandLine. firstIndex ( of: . flag( " -fmodule-file= " + moduleArtifactInfo. moduleName + " =<replace-me> " ) ) {
305307 commandLine [ existingIndex] = . flag( " -fmodule-file= \( moduleArtifactInfo. moduleName) = \( clangModulePath. file. description) " )
306- } else {
308+ } else if case . swift ( _ ) = moduleId {
307309 commandLine. appendFlags ( " -Xcc " ,
308310 " -fmodule-file= \( moduleArtifactInfo. moduleName) = \( clangModulePath. file. description) " )
309311 }
310-
311- let clangModuleMapPath =
312- TypedVirtualPath ( file: moduleArtifactInfo. moduleMapPath. path,
313- type: . clangModuleMap)
314- commandLine. appendFlags ( " -Xcc " ,
315- " -fmodule-map-file= \( clangModuleMapPath. file. description) " )
316- inputs. append ( clangModulePath)
317- inputs. append ( clangModuleMapPath)
312+ if case . swift( _) = moduleId {
313+ commandLine. appendFlags ( " -Xcc " ,
314+ " -fmodule-map-file= \( clangModuleMapPath. file. description) " )
315+ }
318316 }
319317 }
320318
@@ -346,14 +344,10 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
346344 let dependencyInfo = try dependencyGraph. moduleInfo ( of: dependencyId)
347345 let dependencyClangModuleDetails =
348346 try dependencyGraph. clangModuleDetails ( of: dependencyId)
349- let clangModulePath =
350- try targetEncodedClangModuleFilePath ( for: dependencyInfo,
351- hashParts: getPCMHashParts ( pcmArgs: pcmArgs,
352- contextHash: dependencyClangModuleDetails. contextHash) )
353347 // Accumulate the required information about this dependency
354348 clangDependencyArtifacts. append (
355349 ClangModuleArtifactInfo ( name: dependencyId. moduleName,
356- modulePath: TextualVirtualPath ( path: clangModulePath ) ,
350+ modulePath: TextualVirtualPath ( path: dependencyInfo . modulePath . path ) ,
357351 moduleMapPath: dependencyClangModuleDetails. moduleMapPath) )
358352 case . swiftPrebuiltExternal:
359353 let prebuiltModuleDetails = try dependencyGraph. swiftPrebuiltDetails ( of: dependencyId)
@@ -435,41 +429,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
435429 }
436430}
437431
438- /// Utility methods for encoding PCM's target triple into its name.
439- extension ExplicitDependencyBuildPlanner {
440- /// Compute a full path to the resulting .pcm file for a given Clang module, with the
441- /// target triple encoded in the name.
442- public mutating func targetEncodedClangModuleFilePath( for moduleInfo: ModuleInfo ,
443- hashParts: [ String ] ) throws -> VirtualPath . Handle {
444- let plainModulePath = VirtualPath . lookup ( moduleInfo. modulePath. path)
445- let targetEncodedBaseName =
446- try targetEncodedClangModuleName ( for: plainModulePath. basenameWithoutExt,
447- hashParts: hashParts)
448- let modifiedModulePath =
449- moduleInfo. modulePath. path. description
450- . replacingOccurrences ( of: plainModulePath. basenameWithoutExt,
451- with: targetEncodedBaseName)
452- return try VirtualPath . intern ( path: modifiedModulePath)
453- }
454-
455- /// Compute the name of a given Clang module, along with a hash of extra PCM build arguments it
456- /// is to be constructed with.
457- @_spi ( Testing) public mutating func targetEncodedClangModuleName( for moduleName: String ,
458- hashParts: [ String ] )
459- throws -> String {
460- let hashInput = hashParts. sorted ( ) . joined ( )
461- // Hash based on "moduleName + hashInput"
462- let cacheQuery = moduleName + hashInput
463- if let previouslyHashsedName = hashedModuleNameCache [ cacheQuery] {
464- return previouslyHashsedName
465- }
466- let hashedArguments = SHA256 ( ) . hash ( hashInput) . hexadecimalRepresentation
467- let resultingName = moduleName + " - " + hashedArguments
468- hashedModuleNameCache [ cacheQuery] = resultingName
469- return resultingName
470- }
471- }
472-
473432/// Encapsulates some of the common queries of the ExplicitDependencyBuildPlanner with error-checking
474433/// on the dependency graph's structure.
475434@_spi ( Testing) public extension InterModuleDependencyGraph {
0 commit comments