Skip to content

Resolve swiftly when referenced in compile commands #2143

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
merged 1 commit into from
May 12, 2025

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 9, 2025

When the compiler in compile_commands.json references a swift executable that’s a symlink to swiftly, SourceKit-LSP got confused because the swift executable doesn’t reside in a real toolchain, causing us to not provide any semantic functionality.

When we discover that the swift executable reference in compile commands references a swiftly executable, use swiftly use -p to resolve the binary in the real toolchain and continue operating based on that.

Fixes #2128
rdar://150301344

When the compiler in `compile_commands.json` references a `swift` executable that’s a symlink to `swiftly`, SourceKit-LSP got confused because the `swift` executable doesn’t reside in a real toolchain, causing us to not provide any semantic functionality.

When we discover that the `swift` executable reference in compile commands references a `swiftly` executable, use `swiftly use -p` to resolve the binary in the real toolchain and continue operating based on that.

Fixes swiftlang#2128
rdar://150301344
@ahoppen ahoppen requested review from bnbarham and hamishknight May 9, 2025 07:12
@ahoppen
Copy link
Member Author

ahoppen commented May 9, 2025

@swift-ci Please test

Comment on lines +160 to +163
if notification.changes.contains(where: { $0.uri.fileURL?.lastPathComponent == ".swift-version" }) {
await swiftlyResolver.clearCache()
connectionToSourceKitLSP.send(OnBuildTargetDidChangeNotification(changes: nil))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There would still be the case that the global version changes 🤔. Maybe that's fine though, ie. the answer there is to restart.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that’s what I decided as well. There isn’t really a way to notice the global changes apart from polling swiftly, which doesn’t seem like a great solution.

@ahoppen ahoppen merged commit 2c7ecff into swiftlang:main May 12, 2025
3 checks passed
@ahoppen ahoppen deleted the resolve-swiftly branch May 12, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants