Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Does it make sense to publish libproc_macro? #1

Closed
eqrion opened this issue Feb 15, 2018 · 6 comments
Closed

Does it make sense to publish libproc_macro? #1

eqrion opened this issue Feb 15, 2018 · 6 comments

Comments

@eqrion
Copy link

eqrion commented Feb 15, 2018

Currently cbindgen depends on syn for parsing rust which depends on proc-macro2 which depends on proc-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 of libsyntax. Does it make sense to have a published version of libproc_macro so we could do the same? I believe all of libproc_macros dependencies are currently published.

cc @staktrace

@alexcrichton
Copy link
Owner

Ah unfortunately not, I think the issue with bindgen is one we would want to fix in proc-macro2

@staktrace
Copy link

@alexcrichton How do you propose to do that?

@alexcrichton
Copy link
Owner

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.

@staktrace
Copy link

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.

@staktrace
Copy link

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

@alexcrichton
Copy link
Owner

dtolnay/proc-macro2#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.

@eqrion eqrion closed this as completed Jan 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants