Skip to content
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

Workspaces: Cargo profiles should be shared among all workspace members. #3206

Closed
matklad opened this issue Oct 17, 2016 · 1 comment · Fixed by #3249
Closed

Workspaces: Cargo profiles should be shared among all workspace members. #3206

matklad opened this issue Oct 17, 2016 · 1 comment · Fixed by #3249

Comments

@matklad
Copy link
Member

matklad commented Oct 17, 2016

Split off from #3194.

Currently workspaces do not work really well with profiles. Suppose you have two crates, foo and bar, both of them have a profile section and bar depends on foo. If you invoke cargo build inside foo package and inside bar package, then the bar package will be build twice with different profiles!

The property we want here is this "a package of the workspace is always build with the same profile, regardless of place where cargo build was invoked".

This can be achieved in one of the two ways:

  1. Use the single profile configuration for the whole workspace.

  2. When building a workspace package, always use its own profile.

I think it's simpler and better to implement 1), and perhaps add per package overrides in the future.

To implement 1), we should:

  • add a profile section to the virtual manifest,
  • start to produce a warning if the non-root member of the workspace specifies profiles,
  • switch the behavior to always use the profiles from the root of the workspace.

Does this sound reasonable? :)

@alexcrichton
Copy link
Member

Sounds good to me! I do think that we'll need a warning here for a bit as this wasn't implemented just yet, but we don't have to leave the warning in for too too long I think.

bors added a commit that referenced this issue Nov 4, 2016
Use a single profile set per workspace

This aims to close #3206.

I have not figured out how to do this 100% backward compatibly, that's why I want to discuss this separately, although a related PR (#3221) is already in flight.

The problem is this: suppose that you have a workspace with two members, A and B and that A includes a profiles section and B does not. Now, mentally `cd` inside B and run `cargo build`. Today, Cargo will use a default profile. We want it to use a profile from A. So here the silent behavior switch will inevitably occur :( Looks like we can't detect this situation.

So this PR just switches the behavior to always use root profiles, and to print a warning if a non-root package specifies profiles. Feel free to reuse it in any form for #3221 if that's convenient!
@bors bors closed this as completed in #3249 Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants