Skip to content

[6.2][Caching][Macro] Make macro plugin options cacheable #80751

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

cachemeifyoucan
Copy link
Contributor

  • Explanation: Make macro plugin options cacheable by applying prefix mapping to all of them.
  • Scope: Allows swift caching to get more cache hits when the identical macro dylibs are relocated.
  • Issues: rdar://148465899
  • Original PRs: [Caching][Macro] Make macro plugin options cacheable #80474
  • Risk: Low. Swift caching only.
  • Testing: Unit Test
  • Reviewers: @benlangmuir

Currently, the macro plugin options are included as cache key and the
absolute path of the plugin executable and library will affect cache
hit, even the plugin itself is identical.

Using the new option `-resolved-plugin-validation` flag, the macro
plugin paths are remapped just like the other paths during dependency
scanning. `swift-frontend` will unmap to its original path during the
compilation, make sure the content hasn't changed, and load the plugin.
It also hands few other corner cases for macro plugins:

* Make sure the plugin options in the swift module is prefix mapped.
* Make sure the remarks of the macro loading is not cached, as the
  mesasge includes the absolute path of the plugin, and is not
  cacheable.

rdar://148465899
(cherry picked from commit 3d38d0d)
@cachemeifyoucan cachemeifyoucan requested a review from a team as a code owner April 10, 2025 23:55
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

This looks safe enough to me to be cherry-picked because it only affects behaviors when caching is enabled.

@cachemeifyoucan cachemeifyoucan merged commit bd23859 into swiftlang:release/6.2 Apr 15, 2025
5 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.

2 participants