mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Dependency Scanning][C++ Interop] Do not skip lookup of 'CxxStdlib' overlay for the source module
A prior change ensured that we forego this query when looking up Swift overlays for a textual interface which was built without C++ interop. This change introduced a bug where it also caused us to skip this lookup for the main source module. This commit resolves that by preserving the fix above but also ensuring we perform the lookup for the main source module under scan.
This commit is contained in:
@@ -1541,41 +1541,41 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
|
|||||||
recordResult(clangDep);
|
recordResult(clangDep);
|
||||||
|
|
||||||
// C++ Interop requires additional handling
|
// C++ Interop requires additional handling
|
||||||
if (ScanCompilerInvocation.getLangOptions().EnableCXXInterop &&
|
bool lookupCxxStdLibOverlay = ScanCompilerInvocation.getLangOptions().EnableCXXInterop;
|
||||||
moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
|
if (lookupCxxStdLibOverlay && moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
|
||||||
const auto &moduleInfo = cache.findKnownDependency(moduleID);
|
const auto &moduleInfo = cache.findKnownDependency(moduleID);
|
||||||
const auto commandLine = moduleInfo.getCommandline();
|
const auto commandLine = moduleInfo.getCommandline();
|
||||||
|
|
||||||
// If the textual interface was built without C++ interop, do not query
|
// If the textual interface was built without C++ interop, do not query
|
||||||
// the C++ Standard Library Swift overlay for its compilation.
|
// the C++ Standard Library Swift overlay for its compilation.
|
||||||
//
|
//
|
||||||
// FIXME: We always declare the 'Darwin' module as formally having been
|
// FIXME: We always declare the 'Darwin' module as formally having been built
|
||||||
// built without C++Interop, for compatibility with prior versions. Once we
|
// without C++Interop, for compatibility with prior versions. Once we are certain
|
||||||
// are certain that we are only building against modules built with support
|
// that we are only building against modules built with support of
|
||||||
// of
|
// '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
|
||||||
// '-formal-cxx-interoperability-mode', this hard-coded check should be
|
if (moduleID.ModuleName == "Darwin" ||
|
||||||
// removed.
|
llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") !=
|
||||||
if (moduleID.ModuleName != "Darwin" &&
|
commandLine.end())
|
||||||
llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") ==
|
lookupCxxStdLibOverlay = false;
|
||||||
commandLine.end()) {
|
}
|
||||||
for (const auto &clangDepName : allClangDependencies) {
|
|
||||||
// If this Clang module is a part of the C++ stdlib, and we haven't
|
if (lookupCxxStdLibOverlay) {
|
||||||
// loaded the overlay for it so far, it is a split libc++ module (e.g.
|
for (const auto &clangDepName : allClangDependencies) {
|
||||||
// std_vector). Load the CxxStdlib overlay explicitly.
|
// If this Clang module is a part of the C++ stdlib, and we haven't
|
||||||
const auto &clangDepInfo =
|
// loaded the overlay for it so far, it is a split libc++ module (e.g.
|
||||||
cache.findDependency(clangDepName, ModuleDependencyKind::Clang)
|
// std_vector). Load the CxxStdlib overlay explicitly.
|
||||||
.value()
|
const auto &clangDepInfo =
|
||||||
->getAsClangModule();
|
cache.findDependency(clangDepName, ModuleDependencyKind::Clang)
|
||||||
if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) &&
|
.value()
|
||||||
!swiftOverlayDependencies.contains(
|
->getAsClangModule();
|
||||||
{clangDepName, ModuleDependencyKind::SwiftInterface}) &&
|
if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) &&
|
||||||
!swiftOverlayDependencies.contains(
|
!swiftOverlayDependencies.contains(
|
||||||
{clangDepName, ModuleDependencyKind::SwiftBinary})) {
|
{clangDepName, ModuleDependencyKind::SwiftInterface}) &&
|
||||||
scanForSwiftDependency(
|
!swiftOverlayDependencies.contains(
|
||||||
getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str()));
|
{clangDepName, ModuleDependencyKind::SwiftBinary})) {
|
||||||
recordResult(ScanASTContext.Id_CxxStdlib.str().str());
|
scanForSwiftDependency(
|
||||||
break;
|
getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str()));
|
||||||
}
|
recordResult(ScanASTContext.Id_CxxStdlib.str().str());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
test/ScanDependencies/cxx-overlay-source-lookup.swift
Normal file
41
test/ScanDependencies/cxx-overlay-source-lookup.swift
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: %empty-directory(%t/deps)
|
||||||
|
// RUN: split-file %s %t
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -scan-dependencies -o %t/deps.json %t/client.swift -I %t/deps -cxx-interoperability-mode=default -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import
|
||||||
|
// RUN: cat %t/deps.json | %FileCheck %s
|
||||||
|
|
||||||
|
/// --------Main module
|
||||||
|
// CHECK-LABEL: "modulePath": "deps.swiftmodule",
|
||||||
|
// CHECK-NEXT: "sourceFiles": [
|
||||||
|
// CHECK-NEXT: cxx-overlay-source-lookup.swift
|
||||||
|
// CHECK-NEXT: ],
|
||||||
|
// CHECK: "directDependencies": [
|
||||||
|
// CHECK-DAG: "swift": "Swift"
|
||||||
|
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
||||||
|
// CHECK-DAG: "swift": "Cxx"
|
||||||
|
// CHECK-DAG: "swift": "CxxStdlib"
|
||||||
|
// CHECK-DAG: "clang": "CxxShim"
|
||||||
|
// CHECK-DAG: "clang": "Foo"
|
||||||
|
// CHECK: ],
|
||||||
|
|
||||||
|
//--- deps/bar.h
|
||||||
|
void bar(void);
|
||||||
|
|
||||||
|
//--- deps/foo.h
|
||||||
|
#include "bar.h"
|
||||||
|
void foo(void);
|
||||||
|
|
||||||
|
//--- deps/module.modulemap
|
||||||
|
module std_Bar [system] {
|
||||||
|
header "bar.h"
|
||||||
|
export *
|
||||||
|
}
|
||||||
|
|
||||||
|
module Foo {
|
||||||
|
header "foo.h"
|
||||||
|
export *
|
||||||
|
}
|
||||||
|
|
||||||
|
//--- client.swift
|
||||||
|
import Foo
|
||||||
Reference in New Issue
Block a user