-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Macros] In-process plugin server #73725
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making an aggregated swift-syntax libraries, can we link those static libraries with ASTGen and make libASTGen.dylib?
edit: no because ASTGen depends on C++ code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a bug in executable plugins where (from macro '\(macroName)') suffix wasn't added in the diagnostics from executable plugins 😞
9c69aa8 to
abc1390
Compare
1d223b1 to
8e7b75e
Compare
cmake/modules/AddPureSwift.cmake
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fragile modules are now created in ${CMAKE_CURRENT_BINARY_DIR}/modules. This is to avoid PR testing failures in incremental bots. This PR changes _CompilerRegexParser to fragile, if we create ${CMAKE_CURRENT_BINARY_DIR}/_CompilerRegexParser.swiftmodule , subsequent PR testings will be confused because -I ${CMAKE_CURRENT_BINARY_DIR} is added by CMake. Pre-patch #73799 can avoid that, but just in case.
test/Macros/macro_expand.swift
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because the plugin message facilities (i.e. executable plugins) doesn't support "resolve macro type" at this point. Expansions would just fail and be diagnosed if the type is not found or not a macro type.
Maybe we can introduce case resolveMacroType(module: String, type: String) plugin message to recover this.
e64de00 to
9be379a
Compare
|
👋 does this PR remove support for the I should mention that I don't fully understand the implications of this PR so please do correct me if I'm mistaken. In general, in-process execution for first-party plugins during one-off swiftc invocation does seem like a nice improvement! |
I'm not 100% sure what " Since we need to keep supporting "in-process" plugins (i.e.
This PR doesn't have any intent of removing or deprecating out-of-process plugin mechanism.
Yes, reusing plugin processes across multiple I'm not sure I entirely understand your concerns. Let me know if you still have any questions! |
9be379a to
7dd4f52
Compare
|
Ah I was under the impression that this removed support for external plugin servers in favour of in-process plugins, but looks like I was confused. Thanks for the clarification! |
d7a0d58 to
db933a8
Compare
bd5a47d to
c0449ed
Compare
Separate swift-syntax libs for the compiler and for the library plugins.
Compiler communicates with library plugins using serialized messages
just like executable plugins.
* `lib/swift/host/compiler/lib_Compiler*.dylib`(`lib/CompilerSwiftSyntax`):
swift-syntax libraries for compiler. Library evolution is disabled.
* Compiler (`ASTGen` and `swiftIDEUtilsBridging`) only depends on
`lib/swift/host/compiler` libraries.
* `SwiftInProcPluginServer`: In-process plugin server shared library.
This has one `swift_inproc_plugins_handle_message` entry point that
receives a message and return the response.
* In the compiler
* Add `-in-process-plugin-server-path` front-end option, which specifies
the `SwiftInProcPluginServer` shared library path.
* Remove `LoadedLibraryPlugin`, because all library plugins are managed
by `SwiftInProcPluginServer`
* Introduce abstract `CompilerPlugin` class that has 2 subclasses:
* `LoadedExecutablePlugin` existing class that represents an
executable plugin
* `InProcessPlugins` wraps `dlopen`ed `SwiftInProcPluginServer`
* Unified the code path in `TypeCheckMacros.cpp` and `ASTGen`, the
difference between executable plugins and library plugins are now
abstracted by `CompilerPlugin`
9769e8f to
2f7aa42
Compare
|
swiftlang/llvm-project#8855 |
e9254dc to
4d42b59
Compare
|
swiftlang/llvm-project#8855 |
Not all driver can send '-in-process-plugin-server-path'. To keep existing '-plugin-path' working, infer default server path in the frontend.
4d42b59 to
f08d69c
Compare
1 similar comment
|
swiftlang/llvm-project#8855 |
…target PR swiftlang#73725 introduced the in-process plugin server library, but the selection of the library depends on the selected toolchain, which depends on the compiler target, not the host. When cross-compiling (for example from macOS to a embedded Unix target), the compiler will incorrectly chose the `.so` file, not find it, and fail to compile things like the `@debugDescription` macro. Move the in-process plugin server library code from the platform toolchains into the parent type, and code it so it uses the right name depending on the compiler host at compilation time. This discards the target and only relies on the compiler host for selecting the right library.
…target (#74785) PR #73725 introduced the in-process plugin server library, but the selection of the library depends on the selected toolchain, which depends on the compiler target, not the host. When cross-compiling (for example from macOS to a embedded Unix target), the compiler will incorrectly chose the `.so` file, not find it, and fail to compile things like the `@debugDescription` macro. Move the in-process plugin server library code from the platform toolchains into the parent type, and code it so it uses the right name depending on the compiler host at compilation time. This discards the target and only relies on the compiler host for selecting the right library.
…target PR swiftlang#73725 introduced the in-process plugin server library, but the selection of the library depends on the selected toolchain, which depends on the compiler target, not the host. When cross-compiling (for example from macOS to a embedded Unix target), the compiler will incorrectly chose the `.so` file, not find it, and fail to compile things like the `@debugDescription` macro. Move the in-process plugin server library code from the platform toolchains into the parent type, and code it so it uses the right name depending on the compiler host at compilation time. This discards the target and only relies on the compiler host for selecting the right library. (cherry picked from commit 55d9e74)
Separate swift-syntax libs for the compiler and for the library plugins. Compiler communicates with library plugins using serialized messages just like executable plugins.
lib/swift/host/compiler/lib_Compiler*.dylib(sourcelib/CompilerSwiftSyntax): swift-syntax libraries for compiler. Library evolution is disabled.Compiler (
ASTGenandswiftIDEUtilsBridging) only depends onlib/swift/host/compilerlibraries.lib/swift/host/libSwiftInProcPluginServer.dylib(sourcetools/swift-plugin-server/Sources/SwiftInProcPluginServer): In-process plugin server shared library. This has oneswift_inproc_plugins_handle_messageentry point that receives a message and return the response.In the compiler:
-in-process-plugin-server-pathfront-end option, which specifies theSwiftInProcPluginServershared library path.LoadedLibraryPlugin, because all library plugins are managed bySwiftInProcPluginServerCompilerPluginclass that has 2 subclasses:LoadedExecutablePluginexisting class that represents an executable pluginInProcessPluginswrapsdlopenedSwiftInProcPluginServerand communicate with it via theswift_inproc_plugins_handle_messageTypeCheckMacros.cppandASTGen, the difference between executable plugins and library plugins are now abstracted byCompilerPlugin