Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCargo profile dependencies #2282
Conversation
This comment has been minimized.
This comment has been minimized.
Centril
added
the
T-cargo
label
Jan 8, 2018
Manishearth
force-pushed the
Manishearth:custom-profiles
branch
2 times, most recently
from
55bc7db
to
81f3470
Jan 8, 2018
This comment has been minimized.
This comment has been minimized.
Hm, I would think Cargo should just rebuild everything in this case? And I even think this will happen naturally with the current implementation: IIRC, compiler flags are hashed into the fingerprint for determining if the crate should be rebuild. What is the purpose of profiles |
This comment has been minimized.
This comment has been minimized.
I think tracking changes to config files might be out of scope for cargo
If this is true then that works great!
Well, two purposes. Lets people specify global useful profiles like Also, it fixes the big build system case -- Having a custom profile for each combination of flags quickly leads to blowup. Firefox lets you individually flip debug symbols, debug-assertions, and optimization levels. There are more involved, though. (There are use cases; folks hacking on Rust code may want different settings from folks hacking on C++ code) Profiles aren't part of the package anyway, they're build info, and that really should go in |
This comment has been minimized.
This comment has been minimized.
|
Is this compatible with the profiles 2.0 proposal by @matklad ? IIRC there was an embargo for new features for profiles until they get revamped? Generally I like the idea of this RFC though. |
ehuss
reviewed
Jan 10, 2018
| It is not possible to have the same crate compiled in different modes as a build dependency and a regular dependency within the same profile. | ||
|
|
||
|
|
||
| `build_override` is itself |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
force-pushed the
Manishearth:custom-profiles
branch
from
81f3470
to
ffb1862
Jan 10, 2018
This comment has been minimized.
This comment has been minimized.
|
@est31 I think this addresses the "some kind of DSL to map crates to flags" from profiles 2.0 This RFC does not attempt to handle the issue with test/bench/doc but I think that can be addressed independently. One solution for that would be closer to the "includeable profiles" proposal in the pre-RFC, and have something like |
This comment has been minimized.
This comment has been minimized.
|
@est31 I think of this RFC as basically profiles 2.0, and I really love it :) It doesn't solve the "which build in profile is run when" problem, but I think it can be addressed separately. Although I would prefer that instead of |
est31
reviewed
Jan 10, 2018
|
|
||
| We amend this to add that you can define custom profiles with the `profile.foo` key syntax. These can be invoked via | ||
| `cargo build --profile foo`. The `dev`/`doc`/`bench`/etc profiles remain special. Each custom profile, aside from the | ||
| "special" ones, gets a folder in `target/`, named after the profile. "dev" and "debug" are considered to be aliases |
This comment has been minimized.
This comment has been minimized.
est31
Jan 10, 2018
•
Contributor
Naming folders after profiles is no good idea because of profiles named del or similar. Better is to name them as profile.foo or sth.
This comment has been minimized.
This comment has been minimized.
matklad
Jan 10, 2018
Member
Profiles affect only the leaf crate, so I think it's ok not to guard against bad names here. That is, even if one uploads crate with a forbidden profile name to crates.io, no bad things should happen.
Although, it might be a good idea to give a warning/error like "Hey, you named your profile NUL, and this will probably break your crate on windows".
This comment has been minimized.
This comment has been minimized.
Manishearth
Jan 10, 2018
Author
Member
yeah, I agree with @matklad here. We can add warnings for badly-named profiles (doesn't need to be in the rfc)
ehuss
referenced this pull request
Jan 10, 2018
Closed
`cargo build --all-targets` generates two copies of crate test binary #4929
This comment has been minimized.
This comment has been minimized.
ben0x539
commented
Jan 14, 2018
|
Hash the profile data into the output path and you don't need to worry about undefined behavior on profile changes, I guess. |
This was referenced Jan 18, 2018
This comment has been minimized.
This comment has been minimized.
|
One question I have with this is how this applies transitively. For example, consider crate |
This comment has been minimized.
This comment has been minimized.
|
@jonhoo currently, only the leaf crate's profiles are accounted for (it can even be argued on this basis that profiles should not live in Cargo.toml and should go into I can imagine an orthogonal RFC though, which allows upstream crate to advice some profile settings to the downstream crates. For example, the image crate could advise "compile me with -O 3 in the dev profile", and this setting would be used for crates which depend on image, unless they explicitly override it. The possible interaction between this RFC and hypothetical advise RFC is that it's not clear how upstream crates can advice on custom profiles (they don't even know their names!). I think it's reasonable to assume though that this is not a super important problem which we need to solve now: either of "advises do not work with custom profiles" or "custom profile can opt into advises from a particular build-in profile" seems like an ok solution. |
This comment has been minimized.
This comment has been minimized.
|
Also, cc @wycats for the whole discussion :) |
This comment has been minimized.
This comment has been minimized.
|
@matklad you're right that this could totally be addressed in a separate RFC. In fact, I wonder whether, if we had that RFC, that would alleviate many of the pains that this RFC tries to counter. The reason I bring this up as a concern here is that I worry that we'll see these extra profiles added all over the place as a result of this particular solution to the problem. Basically every crate that depends on On a somewhat separate tangent: how often do we expect users to actually add separate profiles, rather than just adding overrides for the |
This comment has been minimized.
This comment has been minimized.
|
@jonhoo FWIW this RFC does propose allowing profiles in .cargo/config, but it also allows them in Cargo.toml for consistency |
This comment has been minimized.
This comment has been minimized.
|
@jonhoo note that the RFC supports overrides for build-in profiles, so I don't believe that "every crate that depends on image would add this extra profile". Rather, every crate which depends on In general, I think the need to customize profiles should be rare, so I'd go for the increased flexibility rather than for increased convenience (but the syntax proposed in this RFC looks pretty and convenient).
Hm, interesting! I believe that it is indeed possible to split this RFC further into "overrides" and "custom profiles" parts, and I agree that "overrides" part has potentially many more users, because fully custom profiles a required mainly by large users like Servo. My personal preference would be to nevertheless pursue the custom profiles part. I really like how it creates a very simple mental model for profiles: "if you pass |
aturon
referenced this pull request
Jan 22, 2018
Closed
Feature request: compile build.rs scripts in release mode even when doing a debug build #2424
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jan 29, 2018
•
|
Team member @matklad has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
the
proposed-final-comment-period
label
Jan 29, 2018
This comment has been minimized.
This comment has been minimized.
|
@rust-lang/cargo discussed this RFC at today's meeting, and it looks really great! There are couple of implementation-level concerns/questions though. |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern workspaces Cargo supports building several packages together as a part of the workspace. In workspaces, only the profile section from the root of the workspace (virtual or not) is taking an effect. Currently this works as expected, because profiles apply to all crates in the DAG of dependencies equally. However with this RFC there's an observable difference between the "current" crate and all other crates. How this interacts with multi-package workspaces. For example, if workspace consists of
what rule applies to |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern build_override
I personally also think that maybe we should just always compile It would be great if someone could measure the impact of always-release |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 16, 2018
|
|
1 similar comment
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 16, 2018
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Feb 16, 2018
This comment has been minimized.
This comment has been minimized.
|
uh oh it's the robot rebellion |
matklad
reviewed
Feb 21, 2018
| # Summary | ||
| [summary]: #summary | ||
|
|
||
| Allow overriding profile keys for certain dependencies, as well as providing |
This comment has been minimized.
This comment has been minimized.
Manishearth
force-pushed the
Manishearth:custom-profiles
branch
from
b3dcffd
to
e3f0e86
Feb 21, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 26, 2018
|
The final comment period is now complete. |
This comment has been minimized.
This comment has been minimized.
|
We've discussed the broader issue of workflows at today's meeting, here's the summary. Today's profiles represent two different things. The first one is the workflow, or operation, which Cargo currently is doing, like testing, documenting or benchmarking. The other, more narrow, is the set of "optimization flags" applied when building the code. It makes sense to split the current profile concept into two separate ones, by introducing workflow as a first-class thing for describing a particular set of operations cargo does, and scaling down profile concept to just mean the set of optimization flags. One can imagine that there will be roughly one workflow for each major Cargo command (testing workflow, documenting workflow, benchmarking workflow). Ideally, it should be possible to add custom workflows like a fuzzing workflow. In contrast, there should be relatively fewer profiles: Each workflow should be linked to some default profile, but the profile could be overridden via command line flag. For example, testing workflow would use Now, the interesting question is, which flags belong to profiles, and which flags belong to workflow? The interesting dimension for comparison here is "can I apply this flag to only part of the packages?". It is interesting because workflows are global for the whole project, while profiles, with this RFC, can apply only to the specific packages. However, certain optimization flags, like
Sorting the current flags gives this picture:
|
This comment has been minimized.
This comment has been minimized.
|
Why is codegen-units profile global? I think LTO, rpath, panic are all global, of which rpath/LTO are workflow-related ones, and panic is weird. We can amend this RFC so that LTO, rpath, panic can only be specified at the top level (we already do for panics) |
This comment has been minimized.
This comment has been minimized.
|
@matklad I'm confused as to what the status of this RFC is. Was your comment an indicator of the overall plans for profiles, or a request for amendments to this one (seems like they would be minor). The FCP has finished already. |
This comment has been minimized.
This comment has been minimized.
|
@Manishearth this was a comment about the general future direction of profiles, the RFC is great as it stands! I think it should be merged now, but I am not sure about the precise process to do this :) |
This comment has been minimized.
This comment has been minimized.
|
Cool. I think we're just supposed to rename the file and fill in details and then merge it. I'll let @nrc merge |
Manishearth
referenced this pull request
Mar 2, 2018
Open
Tracking issue for RFC 2282 - Cargo profile dependencies #48683
This comment has been minimized.
This comment has been minimized.
|
Updated |
Manishearth commentedJan 8, 2018
•
edited
Tracking issue: rust-lang/rust#48683
Rendered