Message about release build

Right now after "cargo build", we see something like

Finished dev [unoptimized + debuginfo] target(s) in 0.00s

I heard on a podcast that many people don't understand that there is a release flag. For instance, see Why my rust program is so slow? - help - The Rust Programming Language Forum.

I recommend one additional line of input. The two lines might be:

Finished dev [unoptimized + debuginfo] target(s) in 0.00s

To compile in optimized mode, use --release. See URL.

I think this would be valuable. The problem keeps coming up.

The extra instructions could automatically disappear the first time you use --release flag (i.e. cargo would write some hidden config "dont_show_optimization_hints = true").

I'd be wary of this, considering that a program might use --release without the user's knowing about it.


Cargo already detects tty to decide whether to use color output. Maybe the hint flag could be updated only in tty.

On the other hand, people generally don't read the command output. (They should, but let's admit the reality.) I worry "show only first time" is basically equivalent to "show never", since people won't see the hint when it was printed first time.

If this is implemented, I think it should require manual action, like prompting the user to type cargo seen release-hint, and always print the hint until it is done. Note that Rust's own build system, rustbuild, uses the same strategy, see changelog-seen.


I think that's an edge not worth worrying about. It's still better than not implementing this at all.

Oh, I agree that this warning/suggestion sounds useful to implement.

This is very true, but that's not an excuse not to provide better output. We'd be helping at least some people. It is also useful when people go to users., paste the output and are pointed out that the answer is right there: it tends to stick with people and read the output more carefully from then on :slight_smile:


I'm skeptical that folks who miss the unoptimized word in the current output will magically start reading once we tack on an additional sentence. As a more experienced user, I'd rather not see two extra lines of output that are useless to me.


Having unoptimized in the output is rather cryptic. It does not give away what you should be doing to get the optimized build.


And a quick web search for "how optimize rust" also doesn't give an answer right away, even after you filter out the Rust (game) results.

I'm not 100% sure how I feel about this proposal. I like having an extra line to tell you what you need to do, but also, in most of my projects, I use [] opt-level = 3 instead of --release, because I still want debugging symbols.

1 Like

With opt-level set to > 0, the output changes to:

Finished dev [optimized + debuginfo] target(s)`

So it might make more sense to tie any new help text to whatever logic is behind that optimized text, rather than making it a debug vs release thing.


Maybe that can be improved instead?