Skip to content

Only load compiler plugins from direct dependencies - #1885

Open
markvasiv wants to merge 1 commit into
bazelbuild:mainfrom
markvasiv:direct-plugin-loading
Open

Only load compiler plugins from direct dependencies#1885
markvasiv wants to merge 1 commit into
bazelbuild:mainfrom
markvasiv:direct-plugin-loading

Conversation

@markvasiv

@markvasiv markvasiv commented Aug 11, 2026

Copy link
Copy Markdown

What

  • Change plugin collection in compile() to walk only the direct modules of the compilation's swift_infos and private_swift_infos, making the code match its documented intent ("we only need to load plugins directly used by the module being compiled"). Module propagation (search paths, explicit module maps) is untouched, so dependents can still resolve the serialized macro attribute when deserializing.
  • Behavior change: a module that uses a macro while depending on the interface library only transitively (e.g. through an @_exported re-export) used to compile by accident, because the plugin arrived transitively. It now fails with a clear "macro implementation not found" error until the direct dependency is declared. This matches SwiftPM, which passes macro plugins only to targets that declare the macro dependency.
  • Add test/fixtures/macros and a macro_plugin analysis-test suite verifying that the declaring module and its direct dependent get -load-plugin-executable, and the transitive dependent does not.

Why

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.

Compiler plugins are loaded by all transitive dependents, making the plugin executable an input to every downstream Swift compile

1 participant