-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow marker_adapter
to accept statically linked lints
#258
Comments
I remember that a suggestion like that also came up in a discussion about potentially using Right now, I have nothing against it. Using dynamic libraries was just the easiest solution for how I envisioned the standalone version Marker, we currently have. Supporting something like this in the future, was one reason for extracting this logic into the Another contributor, @Veetaha, also asked about a similar feature. I believe there are a few things which need to be discussed in this regard, like how these lint crates are statically linked? Do we load them all as one dynamic library, or do we compile them with the driver? Where do we store the driver if it contains static lints? etc.. |
What I am proposing would be an additional means of using Marker, not a replacement for the current one. (I should have been more clear about this.) The drivers might be changed (slightly) internally. But from a user's perspective, there would be no change, including where/what things are stored on the file system. Essentially, I'm suggesting that the "loading" be moved out of the adapter. Marker's code does two things conceptually:
My proposal might be thought of as drawing a cleaner line between 1 and 2.
Let me try to answer this with some sample code. Currently, marker/marker_rustc_driver/src/lint_pass.rs Lines 28 to 31 in 4bd433f
If my suggestion were adopted, then I imagine that code might look like this: ADAPTER.with(move |cell| {
let lint_crate_handles: &[LintCrateHandle] = load_lint_crates(lint_crates)?;
cell.get_or_try_init(|| Adapter::new(lint_crate_handles))?;
Ok(())
}) The crucial idea is: a |
Oh right, my head was still focussing on the way Marker deals with the driver. (By default, we store the driver in the toolchain folder, which might not be ideal, if the lint crates are statically linked)
Point 1 and 2 are split into different crates in Marker. Rustc's driver only does the conversion to the stable interface, and passes that to the adapter. I still would like the driver to focus on the actual conversion part and leave the lint crate loading things etc to the adapter. We can do something like you suggested here:
Though, I would like the Another option, we could think about, would be to generate a dummy crate that has the lints we want to statically load as dependencies. This dummy crate would be used as a dependency for the driver, kind of like this: The arrows (x --> Y) mean that X depends on Y. The code would then look something like this: ADAPTER.with(move |cell| {
let lint_crate_handles: &[LintCrateHandle] = static_lint_crates::get_handles()?;
cell.get_or_try_init(|| Adapter::new(lint_crate_handles))?;
Ok(())
}) What I like about this approach, is that My short answer would be: If we find a nice interface for this, I'm not apposed to the idea of statically linking lint crates :) |
I have been experimenting with idea of running Marker lints under a Dylint driver, and I have a PoC. The PoC is essentially a Dylint library that loads other Marker libraries (see #257 for additional details). Ideally, the additional loading would not be necessary. Rather, the Marker lints would be linked directly into the Dylint library.
To elaborate, the PoC Dylint library has a
check_crate
implementation that looks like this:self.lint_crates()
is a vector ofLintCrateInfo
, i.e., the names and locations of the Marker libraries the adapter should load.What I would prefer would be an interface like the following:
where:
foo
andbar
are Marker lint crates, named in the Dylint library's Cargo.toml file.handle
is a const-evaluable function that returns a structure with the information the adapter needs to call into the crate.Do you think such an interface could be possible? Does it sound too onerous to implement?
The text was updated successfully, but these errors were encountered: