How to get a release build with debugging information when using cargo?

后端 未结 2 577
长发绾君心
长发绾君心 2020-12-05 02:01

The following command

$ cargo build

produces a non-optimized build with debugging information. On the con

相关标签:
2条回答
  • 2020-12-05 02:14

    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

    • Can tests be built in release mode using Cargo?
    • How to compile and run an optimized Rust program with overflow checking enabled
    • Does Cargo support custom profiles?

    Or basically any of the top search results for "rust profiling":

    • Rust Profiling with Instruments and FlameGraph on OSX: CPU/Time
    • Profiling Rust applications on Linux
    • Profiling rust code with callgrind
    0 讨论(0)
  • 2020-12-05 02:22

    Another option that I found that does not require changing Cargo.toml is to use the RUSTFLAGS environment variable:

    $ RUSTFLAGS=-g cargo build --release
    
    0 讨论(0)
提交回复
热议问题