PS C:\bees\code\super-metroid\web-viewer> cargo build --target wasm32-unknown-unknown
Compiling proc-macro2 v0.2.3
Compiling sm v0.1.0 (file:///C:/bees/code/super-metroid/sm)
error[E0463]: can't find crate for `proc_macro`
--> C:\Users\Bees\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-0.2.3\src\lib.rs:32:1
|
32 | extern crate proc_macro;
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
The workspace's Cargo.toml
s follow.
If we go by the comments in rust-lang/rust#40174, then it seems like we can't have the proc-macro
crate as a dependency when building a binary for the wasm32-unknown-unknown
target.
The ideal build situation:
procedural-macro
requireslibrary
with itscodegen
feature in order to build and run itself- the
codegen
feature ends up requiringquote
(andproc-macro2
andproc-macro
as a result) in order to implement thequote::ToTokens
trait - while the
binary
crate requireslibrary
(without thecodegen
feature) as well asprocedural-macro
What actually happens:
- Cargo only builds one version of
library
, the version withcodegen
- the
codegen
feature ends up "poisoning" thebinary
crate so that it can't compile on a different target.