Cannot depend on crates that depends on procedural macro?
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
In my procedural macro, I need several crates that further depends on procedural macro. For example:
```rust
#[derive(serde::Deserialize)]
struct Config {
...
}
use proc_macro2::TokenStream;
#[no_mangle]
pub extern "C" fn the_macro(input: TokenStream) -> TokenStream {
/* use struct Config to help manipulating TokenStream */
}
```
and in my `Cargo.toml` I have:
```toml
[lib]
crate-type = ["cdylib"]
[patch.crates-io]
proc-macro2 = { git = "https://github.com/dtolnay/watt" }
[dependencies]
serde = { version = "*", features = ["derive"] }
```
When I compile, I get:
```bash
$ cargo build --release --target wasm32-unknown-unknown
Compiling serde v1.0.116
error: /home/mashplant/Code/CLionProjects/lalr1-wasm/target/release/deps/libserde_derive-cbe50235eb5bda1c.so: undefined symbol: print_panic
--> /home/mashplant/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/serde-1.0.116/src/lib.rs:285:1
|
285 | extern crate serde_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: could not compile `serde`
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Cargo.toml dependency and patch configuration, then reproduce the documented cargo build --release --target wasm32-unknown-unknown command. Inspect how serde, serde_derive, proc-macro2, and the wasm target interact during compilation. Done means the example procedural macro can depend on these crates and the build completes without the undefined print_panic error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100