Skip to content

[5.4] Actually skip not needed dependencies during dependency resolution #3185

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

Conversation

neonichu
Copy link
Contributor

5.4 cherry-pick of #3166

…wiftlang#3166)

Actually skip not needed dependencies during dependency resolution

This is a follow-up to swiftlang#3162. While that brought back the code for `dependenciesRequired(for:)`, the guard based on `productFilter` actually made it so that it was practically never executed. Instead, the guard should be based on whether the package in question is a root package.

Additionally, this made the order of the returned dependencies unstable, due to use of `Set`. Since `dependenciesRequired(for: keepUnused:)` is now only used if `ENABLE_TARGET_BASED_DEPENDENCY_RESOLUTION` is set, I removed some dead code from there as well.

(cherry picked from commit da4d643)
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

@swift-ci please test

@neonichu neonichu self-assigned this Jan 11, 2021
@tomerd tomerd added the 5.4 label Jan 12, 2021
@tomerd
Copy link
Contributor

tomerd commented Jan 12, 2021

cc @airspeedswift

}
}
}

return Array(requiredDependencies)

Copy link
Member

Choose a reason for hiding this comment

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

Can we please remove the added invisibles at line 171, 173 and 181?

Copy link
Contributor Author

@neonichu neonichu Jan 12, 2021

Choose a reason for hiding this comment

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

We can surely remove them in main, but I don't think another multi-hour CI run is necessary to do it in 5.4 as well.

@neonichu
Copy link
Contributor Author

neonichu commented Jan 14, 2021

Scope of Issue: Any package that relied on dependencies not used by any products being skipped, e.g. because it is using a non-versioned dependency for tests. Notably, this is utilized by the Firebase SDK which is widely used.
Risk: Medium. This is changing dependency resolution, an area for which SwiftPM's test coverage isn't comprehensive. However, this is almost verbatim reverting the behavior to the one from 5.3, so it's unlikely to introduce any new issues.
Testing: I resurrected testTargetBasedDependency for this which was being skipped and also tested manually with a few projects. Specifically https://github.com/firebase/firebase-ios-sdk was broken before because it relies on test-only dependencies and works now.

@neonichu neonichu merged commit 2c41c56 into swiftlang:release/5.4 Jan 14, 2021
@neonichu neonichu deleted the semi-target-based-dependencies-5.4 branch January 14, 2021 21:01
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.

5 participants