Skip to content

[SourceKit] Support building sourcekitd without building swift-syntax #70174

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Dec 1, 2023

This allows building sourcekitd and swift-refactor with SWIFT_BUILD_SWIFT_SYNTAX=NO. In these builds, the relatedidents and find-syntactic-rename-ranges requests will always return an error.

@ahoppen ahoppen requested a review from bnbarham as a code owner December 1, 2023 23:47
@bnbarham
Copy link
Contributor

bnbarham commented Dec 2, 2023

Do you run refactoring tests for Android? If so, I think we need to disable those as well.

They would all need a swift_swift_parser guard now. There's more than just this too, swiftRefactoring isn't built either and thus sourcekit will also fail to build.

What we probably need to do here is to have swiftRefactoring only depend on swiftIDEUtilsBridging if swift-syntax was built, then #if any sections of swiftRefactoring that depend on swiftIDEUtilsBridging. And maybe a warning in sourcekit to say that rename is unavailable without early swift-syntax.

@ahoppen
Copy link
Member Author

ahoppen commented Dec 2, 2023

@finagolfin Do you use sourcekitd and Swift tools on Android? If not, you could try setting SWIFT_BUILD_SOURCEKIT=NO and SWIFT_INCLUDE_TOOLS=NO to just not build sourcekitd and swift-refactor (+ the other tools in swift/tools)

@finagolfin
Copy link
Member

Do you run refactoring tests for Android?

Yes, it appears they are normally run on the community Android CI, which I don't control but help monitor.

Do you use sourcekitd and Swift tools on Android?

Yes, I do. In fact, I even distribute sourcekit-lsp natively on Android, and have used it with an LSP-capable editor in the Termux terminal app for Android.

In any case, this issue has nothing to do with Android, but is about making the build and tests work with SWIFT_BUILD_SWIFT_SYNTAX turned off on any platform. I know the plan is to eventually make that flag a requirement, which is why every official CI now has a host Swift compiler and doesn't bother testing without it, but the community Android CI, which only runs on Ubuntu linux, doesn't install a prebuilt Swift compiler.

Would it be too much work to still support building without a host Swift compiler after this issue?

@drodriguez, maybe installing a host Swift compiler on the community Android CI would be best?

I don't know the best way forward here, just pointing out the problem of #70008 breaking the build on all platforms without a host Swift compiler.

@drodriguez
Copy link
Contributor

@drodriguez, maybe installing a host Swift compiler on the community Android CI would be best?

I do not have time to work on those machines that much. I cannot also give anyone access to the machines because my company policies. Anyone is free to donate other machines that they control and can be added to the Community CI. Those machines are there as a favor, but I cannot invest that much time in them

@ahoppen
Copy link
Member Author

ahoppen commented Dec 4, 2023

OK, I’ll update the build so that swift-refactor and sourcekitd can build without SWIFT_BUILD_SWIFT_SYNTAX. Some functionality in sourcekitd (and thus sourcekit-lsp) won’t work without SWIFT_BUILD_SWIFT_SYNTAX though. For now, this will be rename and related identifiers (which is used by sourcekit-lsp’s textDocument/documentHighlight request).

@ahoppen ahoppen force-pushed the ahoppen/dont-build-swift-refactor-without-swiftsyntax branch from cf390a9 to 675cc86 Compare December 4, 2023 22:04
@ahoppen ahoppen changed the title [build] Don’t build swift-refactor if swift-syntax is not being built [SourceKit] Support building sourcekitd without building swift-syntax Dec 4, 2023
@ahoppen
Copy link
Member Author

ahoppen commented Dec 4, 2023

Updated the PR so that sourcekitd and swift-refactor should build fine with SWIFT_BUILD_SWIFT_SYNTAX=NO. In these builds, the relatedidents and find-syntactic-rename-ranges requests will always return an error and the corresponding functionality in sourcekit-lsp will likewise not be available.

@ahoppen
Copy link
Member Author

ahoppen commented Dec 4, 2023

@swift-ci Please smoke test

@ahoppen ahoppen force-pushed the ahoppen/dont-build-swift-refactor-without-swiftsyntax branch from 675cc86 to 74141ca Compare December 4, 2023 23:17
@ahoppen
Copy link
Member Author

ahoppen commented Dec 4, 2023

@swift-ci Please smoke test

@ahoppen ahoppen force-pushed the ahoppen/dont-build-swift-refactor-without-swiftsyntax branch from 74141ca to 607fbf5 Compare December 5, 2023 03:11
This allows building sourcekitd and swift-refactor with `SWIFT_BUILD_SWIFT_SYNTAX=NO`. In these builds, the `relatedidents` and `find-syntactic-rename-ranges` requests will always return an error.
@ahoppen ahoppen force-pushed the ahoppen/dont-build-swift-refactor-without-swiftsyntax branch from 607fbf5 to a710111 Compare December 5, 2023 03:14
@ahoppen
Copy link
Member Author

ahoppen commented Dec 5, 2023

@swift-ci Please smoke test

@ahoppen ahoppen merged commit c48e578 into swiftlang:main Dec 5, 2023
@ahoppen ahoppen deleted the ahoppen/dont-build-swift-refactor-without-swiftsyntax branch December 5, 2023 16:49
@finagolfin
Copy link
Member

Thanks, this fixed that issue, but now it is complaining about error: cannot find -lswiftIDEUtilsBridging: maybe one last tweak to make that gated on building swift-syntax too?

ahoppen added a commit to ahoppen/swift that referenced this pull request Dec 6, 2023
…TAX` is set

swiftlang#70174 change swift-refactor and sourcekitd to not use `NameMatcher` from swift-syntax but it did not remove the link dependency from swiftRefactoring on `swiftIDEUtilsBridging` if `SWIFT_BUILD_SWIFT_SYNTAX` is false. Do so now.
@ahoppen
Copy link
Member Author

ahoppen commented Dec 6, 2023

Let’s see if this fixes it: #70269

Catfish-Man pushed a commit to Catfish-Man/swift that referenced this pull request Jan 19, 2024
…TAX` is set

swiftlang#70174 change swift-refactor and sourcekitd to not use `NameMatcher` from swift-syntax but it did not remove the link dependency from swiftRefactoring on `swiftIDEUtilsBridging` if `SWIFT_BUILD_SWIFT_SYNTAX` is false. Do so now.
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.

5 participants