Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for RFC 2282 - Cargo profile dependencies #48683
Comments
Manishearth
added
B-RFC-approved
T-lang
C-tracking-issue
labels
Mar 2, 2018
alexcrichton
referenced this issue
Mar 4, 2018
Open
Fails to link `-no-pie` executable that depends on a proc macro #5115
alexcrichton
referenced this issue
Mar 23, 2018
Open
make it easy for build.rs to use lalrpop executable #349
This comment has been minimized.
This comment has been minimized.
Boscop
commented
Apr 4, 2018
|
Any update on this? :) |
This comment has been minimized.
This comment has been minimized.
|
Someone needs to implement it. |
This comment has been minimized.
This comment has been minimized.
|
If you're looking for someone to work on this I'd be happy to help! |
This comment has been minimized.
This comment has been minimized.
|
Sure! I don't have the bandwidth to mentor this but feel free to try it out. Might want to file an issue on the cargo side to coordinate the implementation work. |
This comment has been minimized.
This comment has been minimized.
|
Some issues came up during implementation.
|
This comment has been minimized.
This comment has been minimized.
|
Full spec sounds great. The problem with having a dedicated profile for scripts is that you may wish them to be compiled differently in debug vs release. build-override lets you do both. The original proposal (not the one we RFCd) allowed nesting of profiles which would have made this work well (you declare a new profile, and link it in as the build profile for an existing one) |
This comment has been minimized.
This comment has been minimized.
|
(Also to me it seems like having a build profile just makes the whole profile vs workflow deal even messier -- we already are in a situation where the test/bench profiles are a bit weird) |
This comment has been minimized.
This comment has been minimized.
|
Yep! I was just meaning that it can probably be improved on without too much effort. I think there was some concern during the RFC process that shared dependencies would be a problem, but they shouldn't be. I think @matklad had more thoughts on the profile/workflow stuff, so I'll let him say more. |
This comment has been minimized.
This comment has been minimized.
@Manishearth could you give an example for this? An important practical reason for compiling build scripts exactly the same in More broadly, I think the following properties make a dedicated
The interaction with workflows is also interesting here: in a nutshell, a workflow would allow one to compile and run some custom rust code on the host to do execute custom tasks, like cargo subcommands, but locally to the project. And this code needs to be compiled with some optimization settings and such :) I envision the It is true that |
This comment has been minimized.
This comment has been minimized.
My dev workflow may be one where I'm recompiling often (but I don't edit the build scripts) so I need the build scripts to be fast, but my release workflow may be one where I only run it occasionally (incremental builds are less common), so build scripts should be compiled in dev. This isn't everyone, but this could be someone.
This is an argument for why the defaults should be such that build profiles are the same , not an argument for why we shouldn't expose this functionality. Firefox, for example, would probably want an optimized build script with an unoptimized libsyntax/syn/whatever.
IMO it's not relevant to bring cross compilation into the picture here because cross compilation works differently -- dependencies are not shared. If cargo was rearchitected so that shared deps between build scripts and the main build may be compiled into separate artifacts, this makes more sense, but as it stands, these are shared, and IMO it's easier to reason about these shared dependencies when you have a single profile instead of two. |
This comment has been minimized.
This comment has been minimized.
Not anymore. Shared deps are now compiled separately. (The graph for features/versions is still unified, though.) |
This comment has been minimized.
This comment has been minimized.
|
I had some questions on how to feature-gate profiles in config files. I can imagine a variety of ways to implement it:
I can imagine if you put a profile in a global config it could be really fussy. Let me know if you have any ideas. |
This comment has been minimized.
This comment has been minimized.
|
I'd have some kind of flag in the config itself. |
This comment has been minimized.
This comment has been minimized.
|
But that's not a strong opinion |
This comment has been minimized.
This comment has been minimized.
|
I have some more questions (cc @alexcrichton @matklad).
|
This comment has been minimized.
This comment has been minimized.
|
Aha some excellent questions @ehuss! Lemme see if I can dig in...
|
This comment has been minimized.
This comment has been minimized.
My concern with rejecting with an error is that if in the future cargo supports additional profile names, it would make it impossible to use the new names or keys in a global config and continue using older versions of cargo. I would feel more comfortable with just warnings (
Do you mean string can override an int? If so, that sounds fine to me.
That seems fine with me, too. Would this be a command-line flag that is only necessary during the unstable period? My concern with unconditionally warning if you have a profile in a global config and you don't specify the command-line option is that you will end up with seeing that warning everywhere you don't specify the flag, which would be rather noisy. I kinda like the idea of only warning with I had another question: What should the precedence be? This comment suggests it should be manifest over config. However, |
This comment has been minimized.
This comment has been minimized.
An excellent point and sounds good to me!
Oops yes, indeed!
Correct! I'd also be ok not warning for now. It may lead to some confusion but you're right in that it's likely less than otherwise
I definitely agree it's config over manifest because you modify your local config as opposed to the manifest which is shared amongst all users. |
This comment has been minimized.
This comment has been minimized.
|
Part 2 that includes config profiles has landed on nightly. The (minimal) documentation is at: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#config-profiles |
alexcrichton
referenced this issue
Jun 28, 2018
Closed
Should proc macro crates always be compiled in release even if target crate is being compiled in debug? #5622
alexcrichton
referenced this issue
Sep 17, 2018
Closed
Add an option to optimize just dependencies #1359
alexcrichton
referenced this issue
Sep 26, 2018
Closed
Add a way to only optimize dependencies #6099
ehuss
referenced this issue
Nov 3, 2018
Closed
Allow profile settings to be overridden with command line arguments or environment variables. #3088
This comment has been minimized.
This comment has been minimized.
|
@Manishearth uhm -- why is this T-lang? was that a mistake? |
Manishearth
added
T-cargo
and removed
T-lang
labels
Nov 11, 2018
This comment has been minimized.
This comment has been minimized.
|
uh..... yes oops |
This comment has been minimized.
This comment has been minimized.
|
We're suffering bad codegen issues in webrender with bincode that this would help to solve. Any chance someone can estimate a timeline for stabilization? Or should we try to look for alternative ways to solve this? |
This comment has been minimized.
This comment has been minimized.
|
@jrmuizel Unfortunately there currently is no timeline. I have a concern about the design, and I'll follow up here to try to spur discussion. |
This comment has been minimized.
This comment has been minimized.
|
The current implementation has some drawbacks regarding build script profiles and shared dependencies. Some of this is likely due to misunderstanding/miscommunication on my part. It centers around this statement in the RFC:
This limitations was lifted, but has some possibly unintended consequences, and highlights some drawbacks. There might be some weird interactions with precedence, too. The current implementation merges overrides in the following order:
An example of where this might be an issue: Build-override settings can cause shared dependencies to be built multiple times. This may be desirable in some cases, and in some it causes unwanted longer initial build times. Example: [profile.dev.build-override]
debug = falseThis will cause a shared dependency to be built once with How much of a problem is that? There are some other hypothetical concerns about the lack of control:
Implementation-wise I think these are easy to change, but UI/UX-wise it's not clear what's the best design. I would appreciate any feedback from anyone following here. Is there a better way to control normal dependencies shared with build scripts/proc-macro? Should it be easier to configure proc-macros? Are there any other concerns before stabilizing? |
This comment has been minimized.
This comment has been minimized.
|
I think I'm not personally too terribly concerned about multiple builds. Over time I think minimizing the number of builds for non-cross builds has ended up being a mistake as it just ends up causing a lot of problems here and there that amount to a large papercut. In practice these duplicated crates are always very small and at the bottom of the dependency graph where there's a lot of parallelism, so even practically I don't think it has a terrible amount of impact. I think having package-specific overrides apply for both build/normal use cases is fine for now, we can always add more tweaks later! It's a pretty straightforward way to interpret it in the near term.. For procedural macros, I think I'd probably expect uniform handling of both procedural macros and build script dependencies (e.g. both should probably have debuginfo turned off by default). It's possible to pretty easily fold in proc-macro deps into the category of |
This comment has been minimized.
This comment has been minimized.
If we go a route of not deduping between dev/non-dev dependencies, then I feel a dedicated |
This comment has been minimized.
This comment has been minimized.
|
Yeah that seems reasonable to me, and such a profile we could define as "used for artifacts that are only transiently used during the build process itself", ranging from build scripts to procedural macros. |
This comment has been minimized.
This comment has been minimized.
I like the idea of including proc-macro/plugins in build-override. @Manishearth do you have any thoughts for or against doing that?
I was originally in this camp, but I'm not convinced that it is necessarily better. Pros for
Pros for dedicated build profile:
The benefits to a dedicated profile do not seem very strong to me. @Manishearth gave explicit use cases where the current design is more powerful. Does anyone have any thoughts about that? I was curious how common shared build dependencies are. I scanned all the crates on crates.io (all features enabled). Of the 8288 crates that have a build dependency anywhere in their graph, 2426 have at least one shared build dependency. The top 20 most shared crates are:
The rustc repo has an unusually large number of shared build dependencies (30). |
This comment has been minimized.
This comment has been minimized.
|
Given the inclusion of proc-macros and plugins, the build-override having a separate profile could make it feasible to have build scripts, proc macros, etc. compiled in release mode by-default (even on |
This comment has been minimized.
This comment has been minimized.
Agree that having dev/release gives more power, but I'd expect that, in common case, one does need such power. If one indeed runs release/dev workflows on different machines (so that sharing compiled build scripts is not benefitial), then, on release machine, one can override build profile to match release via env-vars/cargo config. If you do
A slightly different spin here is avoiding recompiling builds/proc macros when tweaking profiles. For example, my software is slow, so I want to build a flame graph, so I add
To me, a separate profile for "everything compiled for host" seems significantly simpler then a layer of overrides. So, I'd personally give this benefit a relatively heavy weight. TL;DR: I think we need to weigh "power" against "common case": overrides win on power, dedicated profile wins on "common case" |
alexcrichton
referenced this issue
Dec 11, 2018
Closed
Make possible to use a different build profile to compile build.rs #6418
This comment has been minimized.
This comment has been minimized.
|
I think I'd personally be more of a fan of a dedicated profile, and we could figure out later how to have cascading overrides perhaps or something like that. Having a dedicated profile seems best for configuration and simplicity from the get-go |
This comment has been minimized.
This comment has been minimized.
|
Here's an example of Firefox's use case that may make some needs clear: Firefox has a build time dependency on bindgen. Bindgen reads a crapload of c++ headers, does a bunch of analysis, and spits out rust code. In debug mode, bindgen should be compiled in release mode because otherwise it's super slow. However, the rust generation step is not slow. Compiling bindgen in release mode means compiling I think a separate profile works with this? You can still support per-dep overrides with this. |
ozkriff
referenced this issue
Dec 20, 2018
Closed
Change default debug build optimization level and update README #398
alercah
referenced this issue
Jan 8, 2019
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.
|
Why not both? |
This comment has been minimized.
This comment has been minimized.
|
Oops, I'd like to apologize for the double-post. But I accidentally submitted before I wrote the rest of my post... Maybe just add an option controlling profile deduplication? For all non-main profiles (that is, profiles other than |
This comment has been minimized.
This comment has been minimized.
|
Sorry for the delay in response. I was going to suggest both, too. I was just hoping a better idea would pop in my mind. It doesn't seem too bad. The new profiles have largely not supported test/bench, since it's not clear if those will even be kept long-term. So I'm not sure I completely follow the dedup field. If Cargo supported both methods, and deduplication is important to a project, then one could specify |
This comment has been minimized.
This comment has been minimized.
|
Using a That said, this is a relatively obscure case and there is no reason it can't be added later. |
Manishearth commentedMar 2, 2018
•
edited by SimonSapin
This is a tracking issue for RFC 2282 (rust-lang/rfcs#2282).
Cargo issue: rust-lang/cargo#5298
Steps:
(cc @rust-lang/cargo for mentorship instructions)
.cargo/configUnresolved questions: