I have a workspace (lets call it app) where I use some crates.io dependencies, which are part of a separate monorepo workspace and release from there (lets call it root).
app defines a production profile where it applies certain optimizations. Same happens for root. When building a member from app without the patches for its dependencies, pointing to root members, with the production profile, the final artifact has a certain size, but if building the same member from app with the patched workspace dependencies, the build artifact is significantly larger.
I want to specify to cargo to compile the patched dependencies with the profile from the root repo, but I am not sure how to do it, or if it is possible. Based on my current experiments and search I am inclined to say there is no support.
Regardless of what kinds of dependencies and patches are in use, only[profile]s and [patch]es from the workspace in which you ran the cargo build command are used. You cannot inherit profile settings from another workspace or package under any circumstance whatsoever. You should think of [profile] as being a convenience for configuring the build command, not a property of the packages in the workspace.
You should think of [profile] as being a convenience for configuring the build command, not a property of the packages in the workspace.
Makes sense!
only[profile]s and [patch]es from the workspace in which you ran the cargo build command are used.
Compiling app member seems to work based on the patched crates from the root workspace. So patches outside of the workspace should work too (at least based on my experiments) - hope I haven't misread your comment though.
Patches not part of the workspace you are building will be ignored.
Cargo only looks at the patch settings in the Cargo.toml manifest at the root of the workspace. Patch settings defined in dependencies will be ignored.
Patches not part of the workspace you are building will be ignored.
Right, my phrasing was wrong. The patching itself is done in app workspace, and it points to crates on local filesystem, part of root workspace. I think we're aligned. Thanks for the reference!
All in all it is strange that the patches from app workspace, where I override crates.io dependencies with same versions from local filesystem from root workspace, are not compiled with same profile chosen in the build command of the app member (at least that what it seems, due to the artifact significant size when compared to pulling same dependencies from crates.io). Am I assuming something wrong or there might be a cargo bug?