Skip to content
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

[Macros] Add support for wasm plugins #1582

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kabiroberai
Copy link
Contributor

This PR implements the driver portion of support for Wasm Macros in Swift. The frontend requires the driver's help to locate swift-wasm-plugin-server, which we obtain in a similar fashion to the existing swift-plugin-server.

Counterpart to apple/swift#73031 — will mark this as a draft until that PR lands but would appreciate input on the approach here (is explicitly passing -wasm-plugin-server-path the right approach or should we do something different?)

@@ -488,6 +488,11 @@ extension Driver {

commandLine.appendFlag(.pluginPath)
commandLine.appendPath(pluginPathRoot.localPluginPath)

if isFrontendArgSupported(.wasmPluginServerPath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead this chunk of code should live in WebAssemblyToolchain's implementation of toolchain.addPlatformSpecificCommonFrontendOptions so that other platforms' command-lines don't unnecessarily end up with this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, wasm macros can be invoked by any toolchain and so this server can also be used by any toolchain — it's independent of the target triple.

That said we could still be smarter about this and only pass along the wasm-server iff the user has also passed in a wasm macro. I avoided this initially because I didn't want the Driver to have to parse plugin load options to determine if a wasm macro was being loaded, but if cluttering up the options is a concern then it might be worth it. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with a hasWasmPlugins check, let me know if this looks better!

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.

None yet

2 participants