-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Dependency Scanning][C++Interop] Do not query CxxStdlib
Swift overlay for textual modules which were not built with c++interop
#81415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
test/ScanDependencies/no-cxx-overlay-for-non-interop-interface.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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/clientWithInteropDep.swift -I %t/deps -cxx-interoperability-mode=default -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -verify | ||
// RUN: cat %t/deps.json | %FileCheck %s -check-prefix=ENABLE-CHECK | ||
|
||
// RUN: %target-swift-frontend -scan-dependencies -o %t/deps_no_interop_dep.json %t/clientNoInteropDep.swift -I %t/deps -cxx-interoperability-mode=default -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -verify | ||
// RUN: cat %t/deps_no_interop_dep.json | %FileCheck %s -check-prefix=DISABLE-CHECK | ||
|
||
//--- deps/bar.h | ||
void bar(void); | ||
|
||
//--- deps/module.modulemap | ||
module std_Bar [system] { | ||
header "bar.h" | ||
export * | ||
} | ||
|
||
//--- deps/Foo.swiftinterface | ||
// swift-interface-format-version: 1.0 | ||
// swift-module-flags: -module-name Foo -enable-library-evolution | ||
import std_Bar | ||
public struct Foo1 {} | ||
|
||
//--- deps/FooNoInterop.swiftinterface | ||
// swift-interface-format-version: 1.0 | ||
// swift-module-flags: -module-name FooNoInterop -enable-library-evolution | ||
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off | ||
import std_Bar | ||
public struct Foo2 {} | ||
|
||
//--- clientWithInteropDep.swift | ||
import Foo | ||
|
||
//--- clientNoInteropDep.swift | ||
import FooNoInterop | ||
|
||
// Ensure that when the 'Foo' dependency was built with C++ interop enabled, | ||
// it gets the C++ standard library overlay for its 'std_*' dependency | ||
// | ||
// 'Foo' as it appears in direct deps | ||
// ENABLE-CHECK: "swift": "Foo" | ||
// 'Foo' as it appears in source-import deps | ||
// ENABLE-CHECK: "swift": "Foo" | ||
// Actual dependency info node | ||
// ENABLE-CHECK: "swift": "Foo" | ||
// ENABLE-CHECK: "directDependencies": [ | ||
// ENABLE-CHECK: { | ||
// ENABLE-CHECK: "swift": "SwiftOnoneSupport" | ||
// ENABLE-CHECK: }, | ||
// ENABLE-CHECK: { | ||
// ENABLE-CHECK: "swift": "CxxStdlib" | ||
// ENABLE-CHECK: }, | ||
// ENABLE-CHECK: { | ||
// ENABLE-CHECK: "clang": "std_Bar" | ||
// ENABLE-CHECK: } | ||
// ENABLE-CHECK: ], | ||
|
||
// Ensure that when the 'Foo' dependency was *not* built with C++ interop enabled, | ||
// it does not get the C++ standard library overlay for its 'std_*' dependency | ||
// | ||
// 'Foo' as it appears in direct deps | ||
// DISABLE-CHECK: "swift": "FooNoInterop" | ||
// 'Foo' as it appears in source-import deps | ||
// DISABLE-CHECK: "swift": "FooNoInterop" | ||
// Actual dependency info node | ||
// DISABLE-CHECK: "swift": "FooNoInterop" | ||
// DISABLE-CHECK: "directDependencies": [ | ||
// DISABLE-CHECK: { | ||
// DISABLE-CHECK: "swift": "SwiftOnoneSupport" | ||
// DISABLE-CHECK: }, | ||
// DISABLE-CHECK: { | ||
// DISABLE-CHECK: "clang": "std_Bar" | ||
// DISABLE-CHECK: } | ||
// DISABLE-CHECK: ], | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the reason we do a textual search here because we haven't loaded the module yet?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The dependency scanner doesn't actually load modules. If/Once it finds a textual interface for a module dependency, we create a sub-instance to parse the module for its imports and compute a command-line recipe to build it, storing it in the
ModuleInfo
in the scanner. The build system client then uses this information to actually build this module for ingestion into compilation.Because the module doesn't actually get loaded, we currently can only get this information from the command line. It would be reasonable to record this as a boolean flag in the
ModuleInfo
when we create one for this module, but I wanted to have a narrow fix first.