Forward SPM -package-name to dylib recompile#132
Merged
Conversation
obj-p
added a commit
that referenced
this pull request
Apr 21, 2026
Address review nits on PR #132: - trim whitespacesAndNewlines so a stray CRLF manifest doesn't strand a trailing \r on the line and defeat the prefix check - `continue` (not `return nil`) when a matched module-name line lacks -package-name, so an SPM variant that emits multiple commands per target can still succeed on the args line that carries the flag No behavioral change against the real SPM manifest shape; defense in depth only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previewing a file in a Swift package that uses `package`-access symbols across sibling targets failed with "cannot find 'X' in scope" because the dylib recompile step omitted `-package-name <identity>`. SPM's package identity can't be derived from Package.swift's `name:` (it's the lowercased directory basename for path packages), so read it from the LLBuild manifest at `.build/<config>.yaml` and thread it through BuildContext.compilerFlags. The fix is scoped to SPM — Bazel and Xcode gate package access through different mechanisms. Manifest path is derived from binPath so relocating `.build` via --scratch-path / SWIFTPM_BUILD_DIR continues to work. examples/spm's ToDoExtras now exposes a `package`-scoped helper that Summary.swift references, turning the existing tier2Compile test into a direct regression guard for this code path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address review nits on PR #132: - trim whitespacesAndNewlines so a stray CRLF manifest doesn't strand a trailing \r on the line and defeat the prefix check - `continue` (not `return nil`) when a matched module-name line lacks -package-name, so an SPM variant that emits multiple commands per target can still succeed on the args line that carries the flag No behavioral change against the real SPM manifest shape; defense in depth only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9cefbcd to
b0fc8a3
Compare
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cannot find 'X' in scopewhen the previewed file referencespackage-scoped symbols from a sibling target — SPM passes-package-name <identity>to every target it builds, butSPMBuildSystemwasn't forwarding it to the raw swiftc invocation..build/<config>.yaml) rather than recomputing it (SPM uses the lowercased directory basename for path packages, notPackage.swift'sname:).binPathso--scratch-path/SWIFTPM_BUILD_DIRusers are covered.Regression guard
examples/spm/Sources/ToDoExtras/Formatter.swiftnow exposespackage enum PackageScopedLabel, referenced fromSummary.swiftin theToDotarget. The existingtier2Compileend-to-end test fails with the exact error from the bug report when the fix is disabled; passes with it in place.Test plan
swift buildswift test --filter BuildSystem(59 tests, incl. 6 new forreadPackageName/manifestPath)swift test --filter PreviewSessionBuildContextTests(5 tests, incl. updatedspmLinksDependencyTargetsasserting-package-name spm)tier2Compilefails withcannot find 'PackageScopedLabel' in scope— the exact symptom from the bug report.🤖 Generated with Claude Code