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

Ensure plug-in C modules don't mix with target ones. #8083

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dschaefer2
Copy link
Member

When a Swift module depends on a C library that is also a dependent of plug-in that the module depends on, we were seeing includes of the module map for both versions of that library, host and target, causing types to be redefined.

This change filters out the plug-in version of these dependencies.

When a Swift module depends on a C library that is also a
dependent of plug-in that the module depends on, we were seeing
includes of the module map for both versions of that library,
host and target, causing types to be redefined.

This change filters out the plug-in version of these dependencies.
@dschaefer2
Copy link
Member Author

Still have tests to write.

MaxDesiatov

This comment was marked as duplicate.

@MaxDesiatov MaxDesiatov added bug build system Changes to interactions with build systems needs tests This change needs test coverage labels Oct 29, 2024
@dschaefer2
Copy link
Member Author

@swift-ci please test

@dschaefer2 dschaefer2 removed the needs tests This change needs test coverage label Oct 29, 2024
@dschaefer2
Copy link
Member Author

Updated to push this all the way to the dependency walking so we never get plug-in rooted dependencies in this part of the planning. And added a test.

Also missed adding the issue link #8060 which points at the @DougGregor's repo where I first reproduced this.

@dschaefer2
Copy link
Member Author

@swift-ci please test

@dschaefer2
Copy link
Member Author

@swift-ci please test windows

@@ -20,12 +20,13 @@ extension BuildPlan {
func plan(swiftTarget: SwiftModuleBuildDescription) throws {
// We need to iterate recursive dependencies because Swift compiler needs to see all the targets a target
// depends on.
for case .module(let dependency, let description) in swiftTarget.recursiveDependencies(using: self) {
for case .module(let dependency, let description) in swiftTarget.recursiveLinkDependencies(using: self) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead of a special method that is filtering out plugins what you want to do is check whether the dependency targets the same destination and if not skip it, that would filter out plugins/macros and other things for "target" destination.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did that originally but felt that was hiding the real issue of including plug-in dependencies in my list of recursive dependencies when I don't want them when constructing the command line arguments for my module build.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a optional destination as a parameter to recursive dependencies method then, it would be easier to understand than having to navigate multiple slightly different methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe it would be okay to adjust recursiveDependencies to always respect destination of the requesting module I don't think we ever want to have things from different destinations used anyway, it's not only plugins though it's also applicable to macros.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been hesitant to rely on destinations. Could a plug-in tool depend on another plug-in tool? Wouldn't both be host?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, both would be host, just like macros. There are other places in Build which filter based on the destination so it won’t be unique.

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, note that plugins actually have a special description not SwiftModuleBuildDescription.

@dschaefer2
Copy link
Member Author

@swift-ci please test

@dschaefer2
Copy link
Member Author

@swift-ci please test windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug build system Changes to interactions with build systems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants