Skip to content

Figure out a better story around optional proc_macro #139

Closed
@dtolnay

Description

@dtolnay

Registering @alexcrichton's ideas from #137 (comment) so they don't get lost:


We've got the following state of affairs:

  • This report saying we don't compile by default on alpine
  • This report saying the same
  • This comment indicating that some musl builds have proc_macro
  • This report saying that if proc_macro2 doesn't link to proc_macro then the dependencies of proc_macro2 aren't ready for that.

I think it's sort of a bummer that this crate doesn't work by default on the standard musl target, and I think it'd be great to fix this. Here's an idea, though, of how we could get this working:

  1. Somehow in this crate's build script we deterine whether or not to link to proc_macro
  2. This crate also indicates links = "proc-macro2-04x"
  3. This crate's build script now prints out whether or not it links to proc_macro
  4. Crates like syn have a build script.
  5. syn reads the env var DEP_PROC_MACRO2_04X, learning about whether proc_macro was linked.
  6. syn's build script then prints out something like cargo:rustc-args=--cfg proc_macro_works and is compiled appropriately

This is sort of heinously complex unfortunately though. It also requires this crate's build script to figure out whether to depend on proc_macro or not (which I'm not sure how to do)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions