mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #71586 from cachemeifyoucan/eng/PR-122814823
[Caching] Do not mix swift modules built from CAS vs. from FileSystem
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#define SWIFT_BASIC_CASOPTIONS_H
|
#define SWIFT_BASIC_CASOPTIONS_H
|
||||||
|
|
||||||
#include "clang/CAS/CASOptions.h"
|
#include "clang/CAS/CASOptions.h"
|
||||||
|
#include "llvm/ADT/Hashing.h"
|
||||||
|
|
||||||
namespace swift {
|
namespace swift {
|
||||||
|
|
||||||
@@ -58,6 +59,21 @@ public:
|
|||||||
(!CASFSRootIDs.empty() || !ClangIncludeTrees.empty() ||
|
(!CASFSRootIDs.empty() || !ClangIncludeTrees.empty() ||
|
||||||
!InputFileKey.empty() || !BridgingHeaderPCHCacheKey.empty());
|
!InputFileKey.empty() || !BridgingHeaderPCHCacheKey.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return a hash code of any components from these options that should
|
||||||
|
/// contribute to a Swift Bridging PCH hash.
|
||||||
|
llvm::hash_code getPCHHashComponents() const {
|
||||||
|
// The CASIDs are generated from scanner, thus not part of the hash since
|
||||||
|
// they will always be empty when requested.
|
||||||
|
// TODO: Add frozen clang::CASOptions to the hash.
|
||||||
|
return llvm::hash_combine(EnableCaching);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return a hash code of any components from these options that should
|
||||||
|
/// contribute to a Swift Dependency Scanning hash.
|
||||||
|
llvm::hash_code getModuleScanningHashComponents() const {
|
||||||
|
return getPCHHashComponents();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace swift
|
} // namespace swift
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ std::string CompilerInvocation::getPCHHash() const {
|
|||||||
SearchPathOpts.getPCHHashComponents(),
|
SearchPathOpts.getPCHHashComponents(),
|
||||||
DiagnosticOpts.getPCHHashComponents(),
|
DiagnosticOpts.getPCHHashComponents(),
|
||||||
SILOpts.getPCHHashComponents(),
|
SILOpts.getPCHHashComponents(),
|
||||||
IRGenOpts.getPCHHashComponents());
|
IRGenOpts.getPCHHashComponents(),
|
||||||
|
CASOpts.getPCHHashComponents());
|
||||||
|
|
||||||
return llvm::toString(llvm::APInt(64, Code), 36, /*Signed=*/false);
|
return llvm::toString(llvm::APInt(64, Code), 36, /*Signed=*/false);
|
||||||
}
|
}
|
||||||
@@ -85,7 +86,8 @@ std::string CompilerInvocation::getModuleScanningHash() const {
|
|||||||
SearchPathOpts.getModuleScanningHashComponents(),
|
SearchPathOpts.getModuleScanningHashComponents(),
|
||||||
DiagnosticOpts.getModuleScanningHashComponents(),
|
DiagnosticOpts.getModuleScanningHashComponents(),
|
||||||
SILOpts.getModuleScanningHashComponents(),
|
SILOpts.getModuleScanningHashComponents(),
|
||||||
IRGenOpts.getModuleScanningHashComponents());
|
IRGenOpts.getModuleScanningHashComponents(),
|
||||||
|
CASOpts.getModuleScanningHashComponents());
|
||||||
|
|
||||||
return llvm::toString(llvm::APInt(64, Code), 36, /*Signed=*/false);
|
return llvm::toString(llvm::APInt(64, Code), 36, /*Signed=*/false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1932,6 +1932,10 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
|
|||||||
// invalidation behavior of this cache item.
|
// invalidation behavior of this cache item.
|
||||||
genericSubInvocation.getFrontendOptions().shouldTrackSystemDependencies(),
|
genericSubInvocation.getFrontendOptions().shouldTrackSystemDependencies(),
|
||||||
|
|
||||||
|
// Whether or not caching is enabled affects if the instance is able to
|
||||||
|
// correctly load the dependencies.
|
||||||
|
genericSubInvocation.getCASOptions().getModuleScanningHashComponents(),
|
||||||
|
|
||||||
// Whether or not OSSA modules are enabled.
|
// Whether or not OSSA modules are enabled.
|
||||||
//
|
//
|
||||||
// If OSSA modules are enabled, we use a separate namespace of modules to
|
// If OSSA modules are enabled, we use a separate namespace of modules to
|
||||||
|
|||||||
13
test/CAS/module_hash.swift
Normal file
13
test/CAS/module_hash.swift
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: mkdir -p %t/clang-module-cache
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -module-name Test
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps_cache.json -module-name Test \
|
||||||
|
// RUN: -cache-compile-job -cas-path %t/cas
|
||||||
|
|
||||||
|
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json Swift modulePath > %t/path1
|
||||||
|
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps_cache.json Swift modulePath > %t/path2
|
||||||
|
// RUN: not diff %t/path1 %t/path2
|
||||||
|
|
||||||
|
func test() {}
|
||||||
Reference in New Issue
Block a user