Skip to content

Add -Zwasm-proc-macros flag - #160854

Open
Mark-Simulacrum wants to merge 1 commit into
rust-lang:mainfrom
Mark-Simulacrum:wasm-macro-partial
Open

Add -Zwasm-proc-macros flag#160854
Mark-Simulacrum wants to merge 1 commit into
rust-lang:mainfrom
Mark-Simulacrum:wasm-macro-partial

Conversation

@Mark-Simulacrum

@Mark-Simulacrum Mark-Simulacrum commented Aug 10, 2026

Copy link
Copy Markdown
Member

This is currently not really implemented, but partial support for it is added in various places across the tree. This is a patch extracted from the wider set of work to make review easier, which wires up:

  • Unstable flag in rustc
  • Bootstrap flag to enable using wasm-proc-macros (this needs an extra std compilation, wiring into compiletest)
  • Partial compiletest support for the flag (mostly just CLI side of things)
    • I suspect this will not work across all platforms but based on success with the full patch it should be enough for Linux, I think. I'd rather get them working on at least one platform and then iterate from there, unless we have clear ideas for improvements now.

cc #160389 (tracking issue)
cc #157590 (more complete implementation)

r? @bjorn3

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 10, 2026
@Mark-Simulacrum
Mark-Simulacrum marked this pull request as ready for review August 10, 2026 12:47
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/compiletest

cc @jieyouxu

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies bootstrap.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 10, 2026
Comment thread bootstrap.example.toml Outdated
#
# The implementation for this has not finished landing, so you probably don't
# want to enable this right now.
#rust.wasm-proc-macro = false

@bjorn3 bjorn3 Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe use plural macros here?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm, do you think we should do the same for the -Z flag? I feel like it's nice for those to be consistent. I don't have a super strong opinion here either way though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The flag already uses plural, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, so it does. I didn't realize :) I guess the compiletest flag must be what I remembered.

I'll go ahead and rename to plural form everywhere then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or you remembered the PR title, as that incorrectly has the flag as singular.

//
// 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.

@bjorn3 bjorn3 Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tracking the general problem in #160917.

@jieyouxu jieyouxu self-assigned this Aug 10, 2026
@rust-bors

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum changed the title Add -Zwasm-proc-macro flag Add -Zwasm-proc-macrso flag Aug 11, 2026
@Mark-Simulacrum Mark-Simulacrum changed the title Add -Zwasm-proc-macrso flag Add -Zwasm-proc-macros flag Aug 11, 2026
This is currently not really implemented, but partial support for it is
added in various places across the tree. This is a patch extracted from
the wider set of work to make review easier, which wires up:

* Unstable flag in rustc
* Bootstrap flag to enable using wasm-proc-macros (this needs an extra
  std compilation, wiring into compiletest)
* Partial compiletest support for the flag (mostly just CLI side of things)
@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

if is_proc_macro_crate && sess.target.is_like_wasm && !sess.opts.unstable_opts.wasm_proc_macros
{
sess.dcx().emit_err(diagnostics::UnstableWasmProcMacro);
}

@bjorn3 bjorn3 Aug 11, 2026

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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).

@bjorn3 bjorn3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r=me if @jieyouxu agrees with the compiletest changes

View changes since this review

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is reasonable to get us started; the compiletest problem is more general (AFAIK the dual under-test toolchain is its own rabbit hole; tracking in #160917) and isn't worth blocking this over.

View changes since this review

@bjorn3

bjorn3 commented Aug 11, 2026

Copy link
Copy Markdown
Member

@bors r=bjorn3,jieyouxu

@rust-bors

rust-bors Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6408d38 has been approved by bjorn3,jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 11, 2026
…, r=bjorn3,jieyouxu

Add -Zwasm-proc-macros flag

This is currently not really implemented, but partial support for it is added in various places across the tree. This is a patch extracted from the wider set of work to make review easier, which wires up:

* Unstable flag in rustc
* Bootstrap flag to enable using wasm-proc-macros (this needs an extra std compilation, wiring into compiletest)
* Partial compiletest support for the flag (mostly just CLI side of things)
  * I suspect this will not work across all platforms but based on success with the full patch it should be enough for Linux, I think. I'd rather get them working on at least one platform and then iterate from there, unless we have clear ideas for improvements now.

cc rust-lang#160389 (tracking issue)
cc rust-lang#157590 (more complete implementation)

r? @bjorn3
rust-bors Bot pushed a commit that referenced this pull request Aug 11, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #160620 (Do not pass `-no-pie` on Windows)
 - #160731 (Arc: Remove unnecessary fmt::Display use for overflow assertion)
 - #160760 (Miri: give the incremental session a chance to finish)
 - #160854 (Add -Zwasm-proc-macros flag)
 - #160868 (std: Adjust cfgs again for TLS on WASI)
 - #160894 (Allow running an arbitrary number of try jobs per PR)
 - #160790 (rustc-book: update sys-v abi link)
 - #160878 (Add rust_analyzer to check-cfg names)
 - #160909 (tests/run-make-cargo/thumb-none-cortex-m: bump `cortex-m` dependency)
 - #160920 (No longer mention the removed generic)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 11, 2026
…, r=bjorn3,jieyouxu

Add -Zwasm-proc-macros flag

This is currently not really implemented, but partial support for it is added in various places across the tree. This is a patch extracted from the wider set of work to make review easier, which wires up:

* Unstable flag in rustc
* Bootstrap flag to enable using wasm-proc-macros (this needs an extra std compilation, wiring into compiletest)
* Partial compiletest support for the flag (mostly just CLI side of things)
  * I suspect this will not work across all platforms but based on success with the full patch it should be enough for Linux, I think. I'd rather get them working on at least one platform and then iterate from there, unless we have clear ideas for improvements now.

cc rust-lang#160389 (tracking issue)
cc rust-lang#157590 (more complete implementation)

r? @bjorn3
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 11, 2026
…, r=bjorn3,jieyouxu

Add -Zwasm-proc-macros flag

This is currently not really implemented, but partial support for it is added in various places across the tree. This is a patch extracted from the wider set of work to make review easier, which wires up:

* Unstable flag in rustc
* Bootstrap flag to enable using wasm-proc-macros (this needs an extra std compilation, wiring into compiletest)
* Partial compiletest support for the flag (mostly just CLI side of things)
  * I suspect this will not work across all platforms but based on success with the full patch it should be enough for Linux, I think. I'd rather get them working on at least one platform and then iterate from there, unless we have clear ideas for improvements now.

cc rust-lang#160389 (tracking issue)
cc rust-lang#157590 (more complete implementation)

r? @bjorn3
rust-bors Bot pushed a commit that referenced this pull request Aug 11, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #160620 (Do not pass `-no-pie` on Windows)
 - #160731 (Arc: Remove unnecessary fmt::Display use for overflow assertion)
 - #160760 (Miri: give the incremental session a chance to finish)
 - #160854 (Add -Zwasm-proc-macros flag)
 - #160868 (std: Adjust cfgs again for TLS on WASI)
 - #160894 (Allow running an arbitrary number of try jobs per PR)
 - #160790 (rustc-book: update sys-v abi link)
 - #160878 (Add rust_analyzer to check-cfg names)
 - #160909 (tests/run-make-cargo/thumb-none-cortex-m: bump `cortex-m` dependency)
 - #160920 (No longer mention the removed generic)
 - #160921 (rustdoc: Fix invalid CSS classes generated for notable items)
 - #160924 (split up `rustc_session`)
 - #160934 (Ensure TLS accesses don't call the global allocator through panic)
 - #160937 (Store the names of `Fn` trait parameters in the AST, fix rustfmt bug)
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 12, 2026
…, r=bjorn3,jieyouxu

Add -Zwasm-proc-macros flag

This is currently not really implemented, but partial support for it is added in various places across the tree. This is a patch extracted from the wider set of work to make review easier, which wires up:

* Unstable flag in rustc
* Bootstrap flag to enable using wasm-proc-macros (this needs an extra std compilation, wiring into compiletest)
* Partial compiletest support for the flag (mostly just CLI side of things)
  * I suspect this will not work across all platforms but based on success with the full patch it should be enough for Linux, I think. I'd rather get them working on at least one platform and then iterate from there, unless we have clear ideas for improvements now.

cc rust-lang#160389 (tracking issue)
cc rust-lang#157590 (more complete implementation)

r? @bjorn3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants