Closed eqrion closed 5 years ago
Ah unfortunately not, I think the issue with bindgen is one we would want to fix in proc-macro2
@alexcrichton How do you propose to do that?
Binaries shouldn't ever depend on proc_macro, so if a binary depends on proc-macro2 then proc-macro2 shouldn't depend on proc_macro.
This'd probably involve adding a feature to proc-macro2
to say "don't link to proc_macro" and turn it on by deafult.
Binaries shouldn't ever depend on proc_macro, so if a binary depends on proc-macro2 then proc-macro2 shouldn't depend on proc_macro.
Sounds like this applies to the quote
and syn
crates as well since those also depend on proc_macro
.
This'd probably involve adding a feature to proc-macro2 to say "don't link to proc_macro" and turn it on by deafult.
Is this something you can specify in the Cargo.toml? It's not clear to me how you'd do this.
@alexcrichton FYI since we didn't have any better options I went ahead and forked proc_macro into a standalone crate: https://crates.io/crates/rustc-ap-proc_macro. I also forked proc-macro2, quote, and syn, into standalone-proc-macro2 etc. and now we finally have a working cbindgen again. It only builds with nightly rustc so it's less than ideal but better than nothing. Still hoping we can resolve this with rust-lang/rust#48217 so that I can unfork all these things.
https://github.com/alexcrichton/proc-macro2/pull/65 is the strategy I envisioned. That wouldn't require forking anything and would largely just require bindgen to tweak how it depends on syn.
Currently
cbindgen
depends onsyn
for parsing rust which depends onproc-macro2
which depends onproc-macro
.This works, but it means that the binary depends on rustc libs being in LD_LIBRARY_PATH, which leads to linking errors when running the binary outside of
cargo run
. See rust-lang/rust#47931.I noticed that
rustfmt
seems to get around this by using a published version oflibsyntax
. Does it make sense to have a published version oflibproc_macro
so we could do the same? I believe all oflibproc_macro
s dependencies are currently published.cc @staktrace