The following command
$ cargo build
produces a non-optimized build with debugging information. On the contrary,
$ cargo build --release
produces an optimized build without debugging information.
Is there a way of producing an optimized build with debugging information? I need this to get meaningful profiling information.
Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.
Cargo has two main profiles: the dev profile Cargo uses when you run cargo build and the release profile Cargo uses when you run cargo build --release . The dev profile is defined with good defaults for development, and the release profile has good defaults for release builds.
So building with debug information is slower.
As shown in the Cargo documentation, modify the release
profile to include debugging symbols:
[profile.release] debug = true
Note that the release
profile and the bench
profile differ.
See also
Or basically any of the top search results for "rust profiling":
Another option that I found that does not require changing Cargo.toml
is to use the RUSTFLAGS
environment variable:
$ RUSTFLAGS=-g cargo build --release
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With