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

Cannot depend on crates that depends on procedural macro? #45

Open
MashPlant opened this issue Oct 5, 2020 · 2 comments
Open

Cannot depend on crates that depends on procedural macro? #45

MashPlant opened this issue Oct 5, 2020 · 2 comments

Comments

@MashPlant
Copy link

In my procedural macro, I need several crates that further depends on procedural macro. For example:

#[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:

[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:

$ 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`
@MashPlant
Copy link
Author

MashPlant commented Oct 5, 2020

Note: I cannot simply replace

[patch.crates-io]
proc-macro2 = { git = "https://github.com/dtolnay/watt" }

with

[dependencies]
proc-macro2 = { git = "https://github.com/dtolnay/watt" }

either, because I also depend on syn and quote, which require the patched version of proc-macro2.

@peter-lyons-kehl
Copy link

peter-lyons-kehl commented Apr 16, 2021

Hi Chenhao @MashPlant,

Have you tried it with https://crates.io/crates/wa-serde-derive?

Also, watt is at https://crates.io/crates/watt now, so you can depend on it from there rather than from Github.

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

No branches or pull requests

2 participants