Skip to content

Commit 6cfe366

Browse files
Merge pull request #4588 from swiftwasm/release/5.7
[pull] swiftwasm-release/5.7 from release/5.7
2 parents ab940da + 16974a4 commit 6cfe366

File tree

16 files changed

+96
-46
lines changed

16 files changed

+96
-46
lines changed

include/swift/AST/SearchPathOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,6 @@ class SearchPathOptions {
327327
/// would for a non-system header.
328328
bool DisableModulesValidateSystemDependencies = false;
329329

330-
/// Enforce loading only serialized modules built with the same SDK
331-
/// as the context loading it.
332-
bool EnableSameSDKCheck = true;
333-
334330
/// A set of compiled modules that may be ready to use.
335331
std::vector<std::string> CandidateCompiledModules;
336332

include/swift/Basic/Version.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ std::string getSwiftFullVersion(Version effectiveLanguageVersion =
184184
/// this Swift was built.
185185
StringRef getSwiftRevision();
186186

187+
/// Is the running compiler built with a version tag for distribution?
188+
/// When true, \c Version::getCurrentCompilerVersion returns a valid version
189+
/// and \c getSwiftRevision returns the version tuple in string format.
190+
bool isCurrentCompilerTagged();
191+
187192
} // end namespace version
188193
} // end namespace swift
189194

include/swift/Serialization/Validation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ class ExtendedValidationInfo {
196196
/// refers directly into this buffer.
197197
/// \param requiresOSSAModules If true, necessitates the module to be
198198
/// compiled with -enable-ossa-modules.
199+
/// \param requiredSDK If not empty, only accept modules built with
200+
/// a compatible SDK. The StringRef represents the canonical SDK name.
199201
/// \param[out] extendedInfo If present, will be populated with additional
200202
/// compilation options serialized into the AST at build time that may be
201203
/// necessary to load it properly.
202204
/// \param[out] dependencies If present, will be populated with list of
203205
/// input files the module depends on, if present in INPUT_BLOCK.
204206
ValidationInfo validateSerializedAST(
205-
StringRef data, bool requiresOSSAModules,
207+
StringRef data, bool requiresOSSAModules, StringRef requiredSDK,
206208
ExtendedValidationInfo *extendedInfo = nullptr,
207209
SmallVectorImpl<SerializationOptions::FileDependency> *dependencies =
208210
nullptr);

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,10 +2419,6 @@ swift::ide::api::getSDKNodeRoot(SDKContext &SDKCtx,
24192419

24202420
auto &Ctx = CI.getASTContext();
24212421

2422-
// Don't check if the stdlib was build with the same SDK as what is loaded
2423-
// here as some tests rely on using a different stdlib.
2424-
Ctx.SearchPathOpts.EnableSameSDKCheck = false;
2425-
24262422
// Load standard library so that Clang importer can use it.
24272423
auto *Stdlib = Ctx.getStdlibModule(/*loadIfAbsent=*/true);
24282424
if (!Stdlib) {

lib/ASTSectionImporter/ASTSectionImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ bool swift::parseASTSection(MemoryBufferSerializedModuleLoader &Loader,
3636
// headers. Iterate over all AST modules.
3737
while (!buf.empty()) {
3838
auto info = serialization::validateSerializedAST(
39-
buf, Loader.isRequiredOSSAModules());
39+
buf, Loader.isRequiredOSSAModules(), /*requiredSDK*/StringRef());
4040

4141
assert(info.name.size() < (2 << 10) && "name failed sanity check");
4242

lib/Basic/Version.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,5 +446,13 @@ StringRef getSwiftRevision() {
446446
#endif
447447
}
448448

449+
bool isCurrentCompilerTagged() {
450+
#ifdef SWIFT_COMPILER_VERSION
451+
return true;
452+
#else
453+
return false;
454+
#endif
455+
}
456+
449457
} // end namespace version
450458
} // end namespace swift

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,7 @@ serialization::Status
25712571
CompilerInvocation::loadFromSerializedAST(StringRef data) {
25722572
serialization::ExtendedValidationInfo extendedInfo;
25732573
serialization::ValidationInfo info = serialization::validateSerializedAST(
2574-
data, getSILOptions().EnableOSSAModules, &extendedInfo);
2574+
data, getSILOptions().EnableOSSAModules, LangOpts.SDKName, &extendedInfo);
25752575

25762576
if (info.status != serialization::Status::Valid)
25772577
return info.status;
@@ -2607,7 +2607,7 @@ CompilerInvocation::setUpInputForSILTool(
26072607

26082608
auto result = serialization::validateSerializedAST(
26092609
fileBufOrErr.get()->getBuffer(), getSILOptions().EnableOSSAModules,
2610-
&extendedInfo);
2610+
LangOpts.SDKName, &extendedInfo);
26112611
bool hasSerializedAST = result.status == serialization::Status::Valid;
26122612

26132613
if (hasSerializedAST) {

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,11 @@ class DiscoveredModule {
200200
namespace path = llvm::sys::path;
201201

202202
static bool serializedASTLooksValid(const llvm::MemoryBuffer &buf,
203-
bool requiresOSSAModules) {
203+
bool requiresOSSAModules,
204+
StringRef requiredSDK) {
204205
auto VI = serialization::validateSerializedAST(buf.getBuffer(),
205-
requiresOSSAModules);
206+
requiresOSSAModules,
207+
requiredSDK);
206208
return VI.status == serialization::Status::Valid;
207209
}
208210

@@ -500,7 +502,7 @@ class ModuleInterfaceLoaderImpl {
500502

501503
LLVM_DEBUG(llvm::dbgs() << "Validating deps of " << path << "\n");
502504
auto validationInfo = serialization::validateSerializedAST(
503-
buf.getBuffer(), requiresOSSAModules,
505+
buf.getBuffer(), requiresOSSAModules, ctx.LangOpts.SDKName,
504506
/*ExtendedValidationInfo=*/nullptr, &allDeps);
505507

506508
if (validationInfo.status != serialization::Status::Valid) {
@@ -542,7 +544,8 @@ class ModuleInterfaceLoaderImpl {
542544

543545
// First, make sure the underlying module path exists and is valid.
544546
auto modBuf = fs.getBufferForFile(fwd.underlyingModulePath);
545-
if (!modBuf || !serializedASTLooksValid(*modBuf.get(), requiresOSSAModules))
547+
if (!modBuf || !serializedASTLooksValid(*modBuf.get(), requiresOSSAModules,
548+
ctx.LangOpts.SDKName))
546549
return false;
547550

548551
// Next, check the dependencies in the forwarding file.

lib/Sema/CSClosure.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Expr *getVoidExpr(ASTContext &ctx) {
3838
/// Find any type variable references inside of an AST node.
3939
class TypeVariableRefFinder : public ASTWalker {
4040
/// A stack of all closures the walker encountered so far.
41-
SmallVector<DeclContext *> ClosureDCs;
41+
SmallVector<DeclContext *, 2> ClosureDCs;
4242

4343
ConstraintSystem &CS;
4444
ASTNode Parent;

lib/Serialization/ModuleFile.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,6 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
156156
return error(status);
157157
}
158158

159-
StringRef moduleSDK = Core->SDKName;
160-
StringRef clientSDK = ctx.LangOpts.SDKName;
161-
if (ctx.SearchPathOpts.EnableSameSDKCheck &&
162-
!moduleSDK.empty() && !clientSDK.empty() &&
163-
moduleSDK != clientSDK) {
164-
status = Status::SDKMismatch;
165-
return error(status);
166-
}
167-
168159
StringRef SDKPath = ctx.SearchPathOpts.getSDKPath();
169160
if (SDKPath.empty() ||
170161
!Core->ModuleInputBuffer->getBufferIdentifier().startswith(SDKPath)) {
@@ -365,7 +356,7 @@ ModuleFile::getModuleName(ASTContext &Ctx, StringRef modulePath,
365356
bool isFramework = false;
366357
serialization::ValidationInfo loadInfo = ModuleFileSharedCore::load(
367358
modulePath.str(), std::move(newBuf), nullptr, nullptr,
368-
/*isFramework*/ isFramework, Ctx.SILOpts.EnableOSSAModules,
359+
/*isFramework*/ isFramework, Ctx.SILOpts.EnableOSSAModules, Ctx.LangOpts.SDKName,
369360
Ctx.SearchPathOpts.DeserializedPathRecoverer,
370361
loadedModuleFile);
371362
Name = loadedModuleFile->Name.str();

0 commit comments

Comments
 (0)