Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for plugin stabilization (plugin, plugin_registrar features) #29597

Closed
aturon opened this issue Nov 5, 2015 · 44 comments · Fixed by #116412
Closed

Tracking issue for plugin stabilization (plugin, plugin_registrar features) #29597

aturon opened this issue Nov 5, 2015 · 44 comments · Fixed by #116412
Labels
A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. S-tracking-perma-unstable Status: The feature will stay unstable indefinitely. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@aturon
Copy link
Member

aturon commented Nov 5, 2015

Tracks stabilization for the plugin and plugin_registrar feature gates.

@aturon aturon added T-lang Relevant to the language team, which will review and decide on the PR/issue. B-unstable Blocker: Implemented in the nightly compiler and unstable. labels Nov 5, 2015
@aturon
Copy link
Member Author

aturon commented Nov 5, 2015

Current status: awaiting a complete revamp of the plugin system.

cc @nrc

@aturon aturon changed the title Tracking issue for plugin_registrar Tracking issue for plugin stabilization (plugin, plugin_registrar features) Nov 5, 2015
@jimmycuadra
Copy link
Contributor

Is anyone actively working on this? Curious what the status is since using Serde without the need for code generation with syntex on stable Rust is very high on my Rust wishlist. 😃

@steveklabnik
Copy link
Member

@nrc is

@aturon
Copy link
Member Author

aturon commented Jan 7, 2016

In particular, check out the discussion here, which points to a bunch of blog posts by @nrc amongst other things. He plans to finish the blog series and post an RFC soon.

@jimmycuadra
Copy link
Contributor

Thanks Aaron—I had read a couple of the posts about the macro system but it didn't click that this was intended to replace compiler plugins for the purpose of syntax extensions. It makes sense now, and looks great. I can't wait. :}

callahad added a commit to callahad/ladaemon that referenced this issue Jun 24, 2016
This is necessary because stable Rust does not yet support custom #[derive]
implementations, which are needed for Serde's Serialize/Deserialize traits.

Serde has a macro package and compiler plugin which handle those, but compiler
plugins are *also* not availble in stable Rust, so we instead have to generate
code at build time using serde_codegen.

Bug for `custom_derive` feature: rust-lang/rust#29644

Bug for compiler plugins: rust-lang/rust#29597
callahad added a commit to callahad/ladaemon that referenced this issue Jun 26, 2016
This is necessary because stable Rust does not yet support custom #[derive]
implementations, which are needed for Serde's Serialize/Deserialize traits.

Serde has a macro package and compiler plugin which handle those, but compiler
plugins are *also* not availble in stable Rust, so we instead have to generate
code at build time using serde_codegen.

Bug for `custom_derive` feature: rust-lang/rust#29644

Bug for compiler plugins: rust-lang/rust#29597
@knight42
Copy link
Contributor

Any progress now?

@SimonSapin
Copy link
Contributor

Yes! The "Macros 1.1" RFC at rust-lang/rfcs#1681 was accepted. It’s implementation is tracked at #35900.

scottlamb added a commit to scottlamb/moonfire-nvr that referenced this issue Dec 8, 2016
It would be nice to build on stable Rust. In particular, I'm hitting
compiler bugs in Rust nightly, such at this one:
rust-lang/rust#38177
I imagine beta/stable compilers would be less problematic.

These two features were easy to get rid of:

* alloc was used to get a Box<[u8]> to uninitialized memory.
  Looks like that's possible with Vec.

* box_syntax wasn't actually used at all. (Maybe a leftover from something.)

The remaining features are:

* plugin, for clippy.
  rust-lang/rust#29597
  I could easily gate it with a "nightly" cargo feature.

* proc_macro, for serde_derive.
  rust-lang/rust#35900
  serde does support stable rust, although it's annoying.
  https://serde.rs/codegen-stable.html
  I might just wait a bit; this feature looks like it's getting close to
  stabilization.
@Mark-Simulacrum Mark-Simulacrum added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Jul 22, 2017
@SimonSapin
Copy link
Contributor

The one remaining plugin in Servo is a register_late_lint_pass that analyses use of GC-managed types to make sure they’re "rooted" correctly. It traverses expressions HIR expression inside functions and methods, and requires access to the resolved type of these expressions as well as attributes on the definitions of these types. (Looking for custom attributes that indicate which types must be rooted. These attributes also need to be allowed by the compiler.)

Could this kind of analysis be built on top of RLS? Could that be a way forward for custom lints without relying on unstable rustc internals?

@eisterman
Copy link

Any progress now?

@0rvar
Copy link

0rvar commented Jul 16, 2018

Are there any plans for stabilizing plugins in the foreseeable future?

@oli-obk
Copy link
Contributor

oli-obk commented Jul 16, 2018

The plan is to remove the plugin API entirely.

@iddm
Copy link

iddm commented Aug 3, 2018

@oli-obk Could you go into details please?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 3, 2018

Even if we stabilized the plugin interface, it would be useless, because there is no stable API it offers. Instead things like proc macros 2.0, custom derive, ... are stabilized by offering an interface that does not require the language to guarantee a plugin interface to the compiler. All of these non-plugin-requiring APIs can be implemented with various other schemes, even if they are currently implemented via plugins in the background.

Note: this issue is not about allowing writing bin crates which can be extended via plugins, it is about plugins that can extend the compiler.

@iddm
Copy link

iddm commented Aug 3, 2018

Is not rocket a plugin to a compiler? If so, that means we will bury it alive?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 3, 2018

Rocket is a plugin to the compiler because proc macros 2.0, and most notably their attribute support is not implemented yet. Of course there is no desire to eliminate any uses of the plugin API without a viable alternative. But there is also no desire to stabilize it while there are much better alternatives on the horizon. Especially if stabilizing has a high cost for the compiler, while the alternatives do not have the same cost associated with them.

@Centril
Copy link
Contributor

Centril commented Jan 13, 2019

@SimonSapin What's the status on Servo's use of this?

@SimonSapin
Copy link
Contributor

Unchanged. https://github.com/servo/servo/blob/c7cd1b83a11/components/script_plugins/lib.rs uses #[plugin_registrar], register_late_lint_pass, and register_attribute.

@syntacticsugarglider
Copy link
Contributor

What's going to replace the support for custom lints provided by lint plugins? Some sort of alternative seems like a good idea.

@SimonSapin
Copy link
Contributor

At this point there is no replacement. See #62868 for some discussion of this.

@joshtriplett joshtriplett added the S-tracking-perma-unstable Status: The feature will stay unstable indefinitely. label Nov 10, 2021
@joshtriplett
Copy link
Member

At this time, what's still using plugin support?

@joshtriplett joshtriplett added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-compiler-nominated Nominated for discussion during a compiler team meeting. labels Nov 10, 2021
@SimonSapin
Copy link
Contributor

No change to report for Servo. https://github.com/servo/servo/tree/9693111c9/components/script_plugins is still an old-style plugin. I don’t know of another practical way to write a custom lint that has access to type resolution. Details in #62868.

Without this lint, any Rust code in Servo that manipulates values owned by the GC (which is a lot of code) would need to be marked as unsafe and just be very careful not to forget to "root" GC any pointer on the stack.

@dlight
Copy link

dlight commented Nov 12, 2021

At this time, what's still using plugin support?

I'm not sure if this counts, but there's this crate https://github.com/draivin/rust-hotswap that although wasn't updated in a while (and I'm not sure if it even builds anymore), it's pretty cool.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 6, 2022

At this time, what's still using plugin support?

Discussed in T-compiler triage meeting today.

I think the T-compiler strategy should be this:

  1. Develop API for MIR-based analyses that we can commit to. The stakeholders I know of for this are Servo (e.g. #14902 Write a MIR lint for rooting analysis servo/servo#20264) and https://github.com/model-checking/rmc
  2. Once Servo is moved off of plugin and onto a MIR-based analysis, then we start officially deprecating and subsequent removal of plugin support.

@rustbot label: -I-compiler-nominated

@rustbot rustbot removed the I-compiler-nominated Nominated for discussion during a compiler team meeting. label Jan 6, 2022
@SimonSapin
Copy link
Contributor

SimonSapin commented Jan 6, 2022

In my previous message I only replied to #29597 (comment) on a technical level.

Activity in the Servo project has been low lately and will be in the forseeable future. If a better API becomes available, it’s not clear when or if we’d be able to migrate the GC rooting lint to it. Given this, I feel it’s probably not fair to expect rustc to indefinitely keep the burden of maintaining plugin support for Servo’s sake.

@blyxyas
Copy link
Member

blyxyas commented Dec 25, 2022

Of course there is no desire to eliminate any uses of the plugin API without a viable alternative

Is there any viable alternatives? I really like compiler plugins, even if "they would be useless" (I don't see how)

@spoutn1k
Copy link

spoutn1k commented Jan 10, 2023

So what alternatives are there to replace the plugin interface ? Specifically, AST code injection. I was looking to create a plugin instrumenting code for specialized performance tracking, is this just not going to be supported going forward ?

Back in 2018 the following project had a proof of concept: https://github.com/da-x/instru.

Edit: I stumbled upon the following mentioning how the LLVM intrumentation coverage can be enabled in rustc. Does that means the LLVM backend is used reliably - ie can be used to inject code via LLVM passes ? I have seen conflicting opinions on the subject from the rust team.

@crlf0710
Copy link
Member

Specifically, AST code injection.

For the ast-level things, isn't proc_macros enough? Just execute a proc_macro at the root module of the crate, parse everything, do whatever transform you want to the code, and put them back together as a TokenStream.

@dlight
Copy link

dlight commented Jan 11, 2023

Specifically, AST code injection.

For the ast-level things, isn't proc_macros enough? Just execute a proc_macro at the root module of the crate, parse everything, do whatever transform you want to the code, and put them back together as a TokenStream.

If we could do #![macro_invocations] that wraps around the whole file, this would be much easier

@spoutn1k
Copy link

Just execute a proc_macro at the root module of the crate, parse everything

Does that entail tagging every function with a macro ? This project is meant to simplify the analysis of large scientific codebases. The plugin approach removes the need to dig into every twisted codebase, instead just compiling with a secret spice mix plugin to get instrumentation.

@blyxyas
Copy link
Member

blyxyas commented Jan 13, 2023

I find that creating a way to use custom inner macros would solve the problem. And if the plugin system is meant to simplify the analysis of large scientific codebases, there should be an alternative. Like custom inner attributes that are applied to every item.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 13, 2023

Note that you can already replace rustc with your own by using the RUSTC_WRAPPER env var. This allows you to do your own preprocessing of the file and feed the output of that to the actual rustc. (Keyword "custom driver" if you want to search for ways to still access rustc internals like clippy and miri do)

The existing plugin API has not been maintained in years.

nnethercote added a commit to nnethercote/rust that referenced this issue Oct 4, 2023
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.
nnethercote added a commit to nnethercote/rust that referenced this issue Oct 4, 2023
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.
nnethercote added a commit to nnethercote/rust that referenced this issue Oct 30, 2023
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 30, 2023
Remove support for compiler plugins.

They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.

r? `@ghost`
nnethercote added a commit to nnethercote/rust that referenced this issue Nov 3, 2023
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 3, 2023
Remove support for compiler plugins.

They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.

r? `@ghost`
@bors bors closed this as completed in 5c462a3 Nov 4, 2023
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Nov 10, 2023
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.
bors pushed a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes rust-lang#29597.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. S-tracking-perma-unstable Status: The feature will stay unstable indefinitely. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.