Description
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:
- Any dependencies that need to build with a different std than the project building them (for example, custom kernels writing a bootloader that need to run in 16bit mode).
- Any dependencies that need custom flags for a target (for example, if a library needs a special env variable for Windows or MacOS)
Steps
- Create a project "A"
- Create project "B"
- Make project "A" depend on project "B"
- Write "invalid" to the file .cargo/config.toml in project "B"
- Compile project "B", cargo errors with a TOML error
- Compile project "A", cargo succeeds with no TOML error
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
cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: x86_64-pc-windows-msvc
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:Schannel)
os: Windows 10.0.19045 (Windows 10 Home) [64-bit]