Skip to content
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

Turn off implicit clang modules while importing CU dependencies. #8752

Merged
merged 1 commit into from
May 16, 2024

Conversation

adrian-prantl
Copy link
Member

ModuleFileSharedCore::getTransitiveLoadingBehavior() has a best-effort mode that is enabled when debugger support is turned on that will try to import implementation-only imports of Swift modules, but won't treat import failures as errors. When explicit modules are on, this has the unwanted side-effect of potentially triggering an implicit Clang module build if one of the internal dependencies of a library was not used to build the target. To avoid these costly and potentially dangerous imports we turn off implicit modules while importing the CU imports only. If a user manually evaluates an expression that contains an import statement that can still trigger an implict import. Implicit imports can be dangerous if an implicit module depends on a module that also exists as an explicit input: In this case, a subsequent explicit import of said dependency will error because Clang now knows about two versions of the same module.

rdar://127455779

@adrian-prantl
Copy link
Member Author

@swift-ci test

@adrian-prantl
Copy link
Member Author

@swift-ci test

@adrian-prantl
Copy link
Member Author

@swift-ci test

@adrian-prantl
Copy link
Member Author

ping @augusto2112 @kastiglione

Copy link

@augusto2112 augusto2112 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Do you think it'd be possible to add a test which contains an import statement that triggers an implicit import?

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h Outdated Show resolved Hide resolved
ModuleFileSharedCore::getTransitiveLoadingBehavior() has a best-effort
mode that is enabled when debugger support is turned on that will try
to import implementation-only imports of Swift modules, but won't
treat import failures as errors. When explicit modules are on, this
has the unwanted side-effect of potentially triggering an implicit
Clang module build if one of the internal dependencies of a library
was not used to build the target. To avoid these costly and
potentially dangerous imports we turn off implicit modules while
importing the CU imports only. If a user manually evaluates an
expression that contains an import statement that can still trigger an
implict import.  Implicit imports can be dangerous if an implicit
module depends on a module that also exists as an explicit input: In
this case, a subsequent explicit import of said dependency will error
because Clang now knows about two versions of the same module.

rdar://127455779
@adrian-prantl
Copy link
Member Author

@swift-ci test

@adrian-prantl
Copy link
Member Author

@swift-ci test windows

2 similar comments
@adrian-prantl
Copy link
Member Author

@swift-ci test windows

@adrian-prantl
Copy link
Member Author

@swift-ci test windows

@adrian-prantl adrian-prantl merged commit 3169ffe into apple:swift/release/6.0 May 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants