-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cargo ignores config.toml of dependencies #11492
Comments
The config file is an environment configuration, not a project or package configuration. One way to demonstrate this in practice is say you have a project $ cd foo
$ cargo build # uses the config
$ cd ..
$ cargo build --manifest-path foo/Cargo.toml # doesn't use the config Now, some project configuration is in the config and people have been identifying what those are and working to get them into manifests so it is tied to the package. |
Found that in #9096 (comment), but the problem is build-std isn't being moved to Cargo.toml. At #10308 (comment), ehuss says that build-std will likely not be moved to Cargo.toml, but that forces projects to manually call builds and removes some uses of the new artifact dependency feature (even though the goal is to prevent project manually calling builds). So what is the planned solution for this? It seems pretty limiting for no good reason. |
It's not really clear to me what this issue is about, so it is hard to respond. If this issue is about having per-package config settings, then I think that is #2930. It is unlikely that we will add those directly. Some discussion around that is towards moving things that are absolutely required for the package to build to be placed in If this is about fixing per-package-target with If you can provide a more specific example of your exact use case, we can maybe look at how that could be handled? |
This issue is about some config.toml options are required for projects to build (like build-std), so any projects depending on them will fail. Build-std is the main one that will cause issues though
I see. The author of that seemed to stop and endorse #10308 which got closed, but if per-package-target allowed setting per-package build-std, would that be the approach cargo will likely go with? I'm interested in picking up where the original issue creator left off.
There's a few config.toml settings that can't be set in Cargo.toml that force projects to chain cargo builds in a build script instead of a pure cargo implementation. One exact case is phil-opman's bootloader crate (which chains builds in the build script). This applies to a few other settings other than build-std, like [env] (for example, setting linker settings) and [target] (for example, per-target rust flags). |
There are two unstable options may cover those use cases.
Though I am no sure when and how they get stabilized, especially for rustflags related option s. |
I'm going to close as I believe there are several other issues tracking what is being asked here. For build-std support, that is tracked in rust-lang/wg-cargo-std-aware#43. If you have a specific use case that does not seem to be already brought up, feel free to open a new issue. I recommend focusing on describing a real use case, preferably with an example. For example, I'm not really following the question about environment variables and linker settings, since those can be set in build scripts. |
Problem
Cargo internally only has one config, and will not load dependency configuration files when compiling them.
This causes a few issues with specific projects:
Steps
Possible Solution(s)
This may be hard to fix in Cargo, a lot of those settings may be applied before dependency resolution or not apply (like the [install] block setting where cargo install installs to), in which case they should be ignored. Other settings, like build-std, need to be applied.
I made a proof of concept at https://github.com/BigBadE/cargo, giving a possible implementation of this feature that adds the Config to the Unit, which means Config has to be clonable. For this proof of concept, a lot of LazyCells just use default, and some Unit methods just use the default Config. I'll open a PR if this is a usable implementation and not entirely naive.
Notes
No response
Version
The text was updated successfully, but these errors were encountered: