mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
Fix the swiftCxxStdlib link with explicit module build on Windows (#85904)
We currently support static linking swiftCxxStdlib only on Windows. When C++ interop is enabled but swiftCxxStdlib isn't actually used or only when its underlying std module is used, we incorrectly emitted the dynamic version of the lib name and caused the link error. This change fixes it by always adding it to the dependency. Issue https://github.com/swiftlang/swift/issues/85876
This commit is contained in:
@@ -620,6 +620,23 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ScanASTContext.LangOpts.EnableCXXInterop) {
|
||||
StringRef mainModuleName = mainModule->getName().str();
|
||||
if (mainModuleName != CXX_MODULE_NAME)
|
||||
mainDependencies.addModuleImport(CXX_MODULE_NAME, /* isExported */ false,
|
||||
AccessLevel::Public,
|
||||
&alreadyAddedModules);
|
||||
if (llvm::none_of(llvm::ArrayRef<StringRef>{CXX_MODULE_NAME,
|
||||
ScanASTContext.Id_CxxStdlib.str(), "std"},
|
||||
[mainModuleName](StringRef Name) {
|
||||
return mainModuleName == Name;
|
||||
}))
|
||||
mainDependencies.addModuleImport(ScanASTContext.Id_CxxStdlib.str(),
|
||||
/* isExported */ false,
|
||||
AccessLevel::Public,
|
||||
&alreadyAddedModules);
|
||||
}
|
||||
|
||||
// Add any implicit module names.
|
||||
for (const auto &import : importInfo.AdditionalUnloadedImports) {
|
||||
mainDependencies.addModuleImport(
|
||||
|
||||
Reference in New Issue
Block a user