-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Add -Zwasm-proc-macros flag #160854
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
Add -Zwasm-proc-macros flag #160854
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # `wasm-proc-macros` | ||
|
|
||
| This option controls whether to enable support for compiling and loading | ||
| `--crate-type=proc-macro` to/from WASM rather than the normal host dylib target. | ||
|
|
||
| Currently we expect that proc macros are compiled to the `wasm32-wasip2` | ||
| target. The exact target will likely change in the future. When this flag is | ||
| passed, both regular dylib proc macros and wasm proc macros are supported. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1351,7 +1351,27 @@ impl<'test> TestCx<'test> { | |
| let mut aux_props = | ||
| self.props.from_aux_file(&aux_path, self.variant.revision(), self.config); | ||
| if aux_type == Some(AuxType::ProcMacro) { | ||
| aux_props.force_host = true; | ||
| if self.config.wasm_proc_macros { | ||
| aux_props.compile_flags.push("--target=wasm32-wasip2".to_owned()); | ||
| // Override any earlier linkers for now, otherwise we fail to build since compiletest | ||
| // thinks we're building for a different target and passes its linker (if one is | ||
| // configured). | ||
| // | ||
| // wasm32-wasip2 should in principle always be able to link with wasm-component-ld + | ||
| // wasm-ld. This does mean that rust.lld needs to be enabled to build wasm-ld wrapper | ||
| // around rust-lld. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jieyouxu do you know if there is a better way to force usage of the default linker or at least use the linker set for the wasm32-wasip2 target rather than the target that gets tested?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I'm afraid I don't recall existing mechanisms to force reusing the "host" linker for the target-being-tested (cross-compile in compiletest was always a bit fishy)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tracking the general problem in #160917. |
||
| aux_props.compile_flags.push("-Clinker=wasm-component-ld".to_owned()); | ||
| aux_props.compile_flags.push(format!( | ||
| "-Clink-arg=--wasm-ld-path={}", | ||
| self.config | ||
| .sysroot_base | ||
| .join("lib/rustlib") | ||
| .join(&self.config.host) | ||
| .join("bin/gcc-ld/wasm-ld") | ||
| )); | ||
| } else { | ||
| aux_props.force_host = true; | ||
| } | ||
| } | ||
| let mut aux_dir = aux_dir.to_path_buf(); | ||
| if aux_type == Some(AuxType::Bin) { | ||
|
|
@@ -1576,6 +1596,11 @@ impl<'test> TestCx<'test> { | |
| }; | ||
| compiler.arg(input_file); | ||
|
|
||
| // Enable wasm proc macros. | ||
| if self.config.wasm_proc_macros { | ||
| compiler.arg("-Zwasm-proc-macros"); | ||
| } | ||
|
|
||
| // Hide libstd sources from ui tests to make sure we generate the stderr | ||
| // output that users will see. | ||
| // Without this, we may be producing good diagnostics in-tree but users | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Doesn't have to be in this PR, but we should suppress the panic=abort warning below for wasm proc-macros.
View changes since the review
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.
Yeah, I intentionally left that out to keep this more minimal and not really changing behavior (just plumbing).