Decouple proc_macro from the rest of the compiler. by eddyb · Pull Request #49219 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation270 Commits16 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

eddyb

This PR removes all dependencies of proc_macro on compiler crates and allows multiple copies of proc_macro, built even by different compilers (but from the same source), to interoperate.

Practically, it allows:

On the server (i.e. compiler front-end) side:

On the client (i.e. proc macro) side (potentially using a different proc_macro instance!):

proc_macro public APIs call into the server via an internal "bridge":

r? @alexcrichton cc @jseyfried @nikomatsakis @Zoxc @thepowersgang

stepancheg reacted with thumbs up emoji kennytm, hanna-kruppe, eternaleye, LifeIsStrange, Mark-Simulacrum, sinkuu, Manishearth, Zoxc, jseyfried, wesleywiser, and 31 more reacted with hooray emoji ebkalderon and lambda-fairy reacted with heart emoji

@eddyb

@bors

@eddyb

@bors

bors added a commit that referenced this pull request

Mar 20, 2018

@bors

Decouple proc_macro from the rest of the compiler.

This PR removes all dependencies of proc_macro on compiler crates and allows multiple copies of proc_macro, built even by different compilers (but from the same source), to interoperate.

On the compiler (aka "frontend") side:

On the proc macro side (potentially using a different proc_macro instance):

proc_macro public APIs call into the "current frontend" via the internal bridge:

r? @alexcrichton cc @jseyfried @nikomatsakis @Zoxc @thepowersgang

@eddyb

cc @rust-lang/infra We shouldn't merge this without a crater run, although you might want to wait on a review as well (then again, the results could inform the review, so whichever comes first).

@bors

Zoxc

#[unstable(feature = "proc_macro_internals", issue = "27812")]
#[doc(hidden)]
pub contents: Term,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to commit to using interning for literals? I'm not sure interning it terrible useful for that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I can make these fields private again. Definitely not considering stabilizing any of this.

Zoxc

@@ -11,3 +11,6 @@ crate-type = ["dylib", "rlib"]
[dependencies]
getopts = "0.2"
term = { path = "../libterm" }
# not actually used but needed to always have proc_macro in the sysroot
proc_macro = { path = "../libproc_macro" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a rustbuild change.

@bjorn3

Could you use something like bincode for data bridging, instead of 800 lines of own code?

@eddyb

@bjorn3 I'm not serializing the data (but rather using handles), and bincode (like any other serialization) is annoying to use without derived impls (which you can't have because this is proc_macro itself - or at least I don't want to try to make that work, for now).

I am going to look into simplifying the bridge code, removing most unsafe, and making it more amenable to message-passing, however.

@bjorn3

@alexcrichton

This comment has been minimized.

@eddyb eddyb changed the titleDecouple proc_macro from the rest of the compiler. [WIP] Decouple proc_macro from the rest of the compiler.

Mar 22, 2018

@eddyb

This comment has been minimized.

@Mark-Simulacrum

@eddyb

@Mark-Simulacrum It doesn't look bad, that's for sure, thanks! If we switch to spawning a thread (or even a process) per invocation it'd warrant another perf run.

Phlosioneer added a commit to Phlosioneer/rust that referenced this pull request

Mar 25, 2018

@Phlosioneer

A few tests related to proc-macros fail when performing stage-1 testing. This PR adds // ignore-stage1 to them, along with a FIXME.

Original issue: rust-lang#49352

This should (hopefully) be fixed when rust-lang#49219 is merged.

@aidanhs

@eddyb eddyb mentioned this pull request

Mar 30, 2018

@aidanhs

Hi @eddyb (crater requester), @Zoxc (PR reviewer)! Crater results are at: http://cargobomb-reports.s3.amazonaws.com/pr-49219/index.html. 'Blacklisted' crates (spurious failures etc) can be found here. If you see any spurious failures not on the list, please make a PR against that file.

(interested observers: Crater is a tool for testing the impact of changes on the crates.io ecosystem. You can find out more at the repo if you're curious)

This was referenced

Nov 30, 2018

@petrochenkov

I can't believe you've done this!

eddyb, oli-obk, kennytm, fedochet, RalfJung, matthewjasper, euclio, ljedrz, mark-i-m, Centril, and 9 more reacted with laugh emoji

@eddyb eddyb deleted the proc-macro-decouple branch

November 30, 2018 11:13

@hcpl hcpl mentioned this pull request

Dec 9, 2018

sfackler added a commit to sfackler/proc-macro2 that referenced this pull request

Dec 18, 2018

@sfackler

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request

Mar 7, 2019

@emilio

1.32 includes rust-lang/rust#49219, which means new cbindgen no longer depends on compiler internals, which fixes some reported build issues on IRC.

xeonchen pushed a commit to xeonchen/gecko that referenced this pull request

Mar 7, 2019

@emilio

1.32 includes rust-lang/rust#49219, which means new cbindgen no longer depends on compiler internals, which fixes some reported build issues on IRC.

@eddyb eddyb mentioned this pull request

Mar 14, 2019

gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request

Oct 4, 2019

@marco-c

1.32 includes rust-lang/rust#49219, which means new cbindgen no longer depends on compiler internals, which fixes some reported build issues on IRC.

UltraBlame original commit: 8e48fdd65475c48fdc2f6af9e359c3d07bee66e5

gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request

Oct 4, 2019

@marco-c

1.32 includes rust-lang/rust#49219, which means new cbindgen no longer depends on compiler internals, which fixes some reported build issues on IRC.

UltraBlame original commit: 8e48fdd65475c48fdc2f6af9e359c3d07bee66e5

gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request

Oct 4, 2019

@marco-c

1.32 includes rust-lang/rust#49219, which means new cbindgen no longer depends on compiler internals, which fixes some reported build issues on IRC.

UltraBlame original commit: 8e48fdd65475c48fdc2f6af9e359c3d07bee66e5

@ehuss ehuss mentioned this pull request

Jul 3, 2020

Manishearth added a commit to Manishearth/rust that referenced this pull request

Jul 16, 2020

@Manishearth

…atsakis

Remove some ignore-stage1 annotations.

These tests appear to no longer need the ignore-stage1 marker.

Manishearth added a commit to Manishearth/rust that referenced this pull request

Jul 16, 2020

@Manishearth

…atsakis

Remove some ignore-stage1 annotations.

These tests appear to no longer need the ignore-stage1 marker.

Manishearth added a commit to Manishearth/rust that referenced this pull request

Jul 16, 2020

@Manishearth

…atsakis

Remove some ignore-stage1 annotations.

These tests appear to no longer need the ignore-stage1 marker.

Manishearth added a commit to Manishearth/rust that referenced this pull request

Jul 16, 2020

@Manishearth

…atsakis

Remove some ignore-stage1 annotations.

These tests appear to no longer need the ignore-stage1 marker.

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.