There are 5 profiles used for various purposes, and while each is configurable, you can't make your own profile. This would be useful for defining special profiles for a specific project. I personally would find a profiling profile useful to be able to enable both debugging and optimisations.
I propose supporting custom profiles, selected using --profile. The current profiles would just be predefined ones and I don't see why they couldn't be selected as well. A set of default values for the profile options will also need to be decided upon.
I do think that this was one of the original intentions of profiles (cc @wycats, @carllerche), but there's also certainly a case to be made that if there are sets of options frequently used that Cargo should bake in those profiles! (and a profiling profile does seem like something that may commonly arise).
Yep :+1:
I'd definitely love to have a profile profile, and having custom profiles seems like a nice pluggable way to do it.
I would really like to have a relwithdebinfo profile, like CMake does:
[profile.relwithdebinfo]
opt-level = 3
debug = true
rpath = false
lto = false
debug-assertions = false
codegen-units = 1
... which is really a superset of profiling, but also useful for shipping -dbg packages, etc.
We're in a situation with Firefox where we'd like to ship our release binaries with LTO, but we want to disable it by default for local developer builds to save on build time. Unfortunately there's no straightforward way to do that. Being able to define a custom profile would be really useful here.
I have a draft implementation here if anyone is interested.
I'm also interested in this.. I need 2 dev profiles, one with opt-level = 0 and one with opt-level = 1.
I have updated my implementation and opened a pull request. #5326
It would be nice to be able to have a fully optimized "release/publish" profile: https://github.com/rust-lang/rust/issues/47745#issuecomment-447530953
# The publish profile, used for `cargo build --publish`.
[profile.publish]
# (...) everything else the same as profile.release except:
lto = true # Enable full link-time optimization.
codegen-units = 1 # Use only 1 codegen-unit to enable full optimizations.
RFC 2678 for this is opened.
This has been implemented, closing in favor of the tracking issue #6988.
Most helpful comment
I would really like to have a relwithdebinfo profile, like CMake does:
... which is really a superset of profiling, but also useful for shipping -dbg packages, etc.