Skip to content

Let SwiftPM use prebuilt swift-syntax for CodableKitMacros - #31

Merged
WendellXY merged 1 commit into
mainfrom
prebuilt-swift-syntax
Nov 8, 2026
Merged

WendellXY merged 1 commit into
mainfrom
prebuilt-swift-syntax

Conversation

@WendellXY

Copy link
Copy Markdown
Owner

SwiftPM substitutes prebuilt swift-syntax only when every macro module depends solely on host-only modules (handlePrebuilts in ModulesGraph+Loading). CodableKitMacros depended on CodableKitCore, which clients also link through CodableKit. That made Core an all-platform module, and SwiftPM fell back to building swift-syntax from source for the whole graph.

The macro now compiles the shared option definitions through the symlink Sources/CodableKitMacros/SharedCore -> ../CodableKitCore, so there is still one source of truth. Core files were renamed to avoid basename clashes. The public API is unchanged.

Measured downstream (Tiamat, cold swift build -c release on macOS 26.7.1 / Swift 6.4): 1,136 s → 59 s, with no swift-syntax compilation. All 367 package tests pass locally.

🤖 Generated with Claude Code

SwiftPM only substitutes prebuilt swift-syntax when every macro module
depends solely on host-only modules. CodableKitMacros depended on
CodableKitCore, which clients also link through CodableKit, so the whole
graph fell back to compiling swift-syntax from source. Compile the shared
option definitions into the macro through a SharedCore symlink instead.

A downstream cold release build dropped from 1,136 s to 59 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 8, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the macro dependency restructuring.

No open issues 🎉

What changed in this PR

This PR restructures how CodableKitMacros consumes shared option definitions so SwiftPM can use prebuilt swift-syntax, without changing CodableKit’s public API.

Changes:

  • Removes the macro target’s dependency on the runtime-linked CodableKitCore module.
  • Reuses shared definitions through a symlink, with renamed source files to avoid basename collisions.
  • Removes CodableKitCore imports from macro implementation files.
File Description
Sources/​CodableKitMacros/​CodeGenCore.swift Removes the Core module import from code generation.
Sources/​CodableKitMacros/​CodableOptions.swift Uses locally compiled shared macro options.
Sources/​CodableKitMacros/​CodableMacro.swift Removes the Core module import from macro implementation.
Sources/​CodableKitMacros/​CodableKeyOptions.swift Uses locally compiled shared key options.
Sources/​CodableKitCore/​CodableOptionsDefinition.swift Renames shared macro option definitions to avoid filename collisions.
Sources/​CodableKitCore/​CodableKeyOptionsDefinition.swift Renames shared key option definitions to avoid filename collisions.
Package.swift Removes the macro-to-Core dependency and documents the prebuilt rationale.

Review effort: Balanced

@WendellXY
WendellXY merged commit 1edccb0 into main Nov 8, 2026
9 checks passed
@WendellXY
WendellXY deleted the prebuilt-swift-syntax branch November 8, 2026 16:04
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