Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,18 @@ extension ExplicitDependencyBuildPlanner {
/// is to be constructed with.
public static func targetEncodedClangModuleName(for moduleName: String,
pcmArgs: [String]) throws -> String {
var hasher = Hasher()
pcmArgs.forEach { hasher.combine($0) }
return moduleName + String(hasher.finalize())
let hashInput = pcmArgs.sorted().joined()
let hashedArguments: String
#if os(macOS)
if #available(macOS 10.15, iOS 13, *) {
hashedArguments = CryptoKitSHA256().hash(hashInput).hexadecimalRepresentation
Comment on lines +455 to +456
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is failing on Linux because the true branch of the #available condition is taken. I'm not sure if there's a better way to write this than something like:

#if os(macOS)
if #available(macOS 10.15, iOS 13, *) {
        hashedArguments = CryptoKitSHA256().hash(hashInput).hexadecimalRepresentation
} else {
       hashedArguments = SHA256().hash(hashInput).hexadecimalRepresentation
}
#else 
hashedArguments = SHA256().hash(hashInput).hexadecimalRepresentation
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the wildcard...
I can't think of a better way either.
Thanks, @owenv.

} else {
hashedArguments = SHA256().hash(hashInput).hexadecimalRepresentation
}
#else
hashedArguments = SHA256().hash(hashInput).hexadecimalRepresentation
#endif
return moduleName + hashedArguments
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,10 @@ fileprivate extension InterModuleDependencyGraph {
// For all dependencies of this placeholder (direct and transitive), insert them
// into this module's graph.
// - Swift dependencies are inserted as-is
// - Clang dependencies, because PCM modules file names encode the specific pcmArguments
// of their dependees, we cannot use pre-built files here because we do not always know
// which target they corrspond to, nor do we have a way to map from a certain target to a
// specific pcm file. Because of this, all PCM dependencies, direct and transitive, have to
// be built for all modules. We merge moduleInfos of such dependencies with ones that are
// already in the current graph, in order to obtain a super-set of their dependencies
// at all possible PCMArgs variants.
// FIXME: Implement a stable hash for generated .pcm filenames in order to be able to re-use
// modules built by external dependencies here.

// - Clang dependencies are inserted as-is, if a matching Clang module is already found
// in this module's graph, we merge moduleInfos of the two modules, in order to obtain
// a super-set of their dependencies at all possible PCMArgs variants.
//
// The placeholder is resolved into a .swiftPrebuiltExternal module in the dependency graph.
// The placeholder's corresponding module may appear in the externalModuleInfoMap as either
// a .swift module or a .swiftPrebuiltExternal module if it had been resolved earlier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ import SwiftOptions
.map { $0.option.spelling }
.sorted()
.joined()
#if os(macOS)
if #available(macOS 10.15, iOS 13, *) {
return CryptoKitSHA256().hash(hashInput).hexadecimalRepresentation
} else {
return SHA256().hash(hashInput).hexadecimalRepresentation
}
#else
return SHA256().hash(hashInput).hexadecimalRepresentation
#endif
}

/// Determine the input and output path for the build record
Expand Down