-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Respecting .cargo/config.toml
#8741
Comments
Note that we explicitly pass |
Hm, ye that might be a problem. I wonder if parsing the config might be not such a bad idea though, we wouldn't have to parse everything but a few things we are interested in anyways(currently |
Then again we don't have toml in our dependency tree and I don't think we would want to add that. I wonder if it would make sense to add a subcommand to cargo to emit the configuration as json similar to what Edit: Turns out this is already an unstable thing rust-lang/cargo#9301 🎉 |
Actually, I think we can get by with this rust-lang/cargo#9357 once it lands? |
Managed to throw a working branch together: Veykril@8989fb8 This uses unstable cargo features, Now the question is, as we don't really use nightly apis, does not using unstable things also apply to cargo when we have fallbacks in place if those commands fail? Anyways at least we got a (future) solution to these problems. |
8774: feat: Honor `.cargo/config.toml` r=matklad a=Veykril ![f1Gup1aiAn](https://user-images.githubusercontent.com/3757771/117545448-1dcaae00-b026-11eb-977a-0f35a5e3f2e0.gif) Implements `cargo/.config` build target and cfg access by using unstable cargo options: - `cargo config get` to read the target triple out of the config to pass to `cargo metadata` --filter-platform - `cargo rustc --print` to read out the `rustc_cfgs`, this causes us to honor `rustflags` and the like. If those commands fail, due to not having a nightly toolchain present for example, they will fall back to invoking rustc directly as we currently do. I personally think it should be fine to use these unstable options as they are unlikely to change(even if they did it shouldn't be a problem due to the fallback) and don't burden the user if they do not have a nightly toolchain at hand since we fall back to the previous behaviour. cc #8741 Closes #6604, Closes #5904, Closes #8430, Closes #8480 Co-authored-by: Lukas Wirth <[email protected]>
The only open issue about this now is #5828, which I'm unsure what the cause of is. I'll close this issue in favor of the already opened issue there since its the only remaining one. |
This is more of a collection of some issues floating around regarding the
.cargo/config.toml
and general discussion of how to solve these.Respect thebuild.target
key for analysis(can be worked around mostly with"rust-analyzer.cargo.target"
): Feature request: Support using target from .cargo/config.toml #6604 Any way to temporarily change default target? #5904 Rust-analyzer not respecting default target #8430Respect features set via rustflags for analysis cfg calculation doesn't seem to respect-Ctarget-cpu=native
in.cargo/config.toml
#8480As pointed out in #5904 (comment):
We probably do not want to parse this ourselves but
cargo metadata
doesn't seem to expose this info in its output either, see https://doc.rust-lang.org/cargo/commands/cargo-metadata.html#output-format. So we either have to parse it ourselves or get the relevant info to be emitted bycargo metadata
from what I can tell.The text was updated successfully, but these errors were encountered: