1

I am debugging my cargo project. I build it using --release flag generally. But when I saw the stack trace in gdb, it was not very readable. I figured out that I could create debug symbols with debug=true in Cargo.toml.

Can I still use --release flag with cargo build ? Are these not contradicting? This is what the terminal help for the flag says -

--release Build artifacts in release mode, with optimizations

I ask this for clarity beforehand as a debug run takes several hours for me to hit the issue.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Rajeev Ranjan
  • 3,588
  • 6
  • 28
  • 52

1 Answers1

3

Compiling with --release, and having a Cargo.toml

[profile.release]
debug=True

And will indeed include debug symbols as well as perform optimizations. The two are not contradictory.

The [profile.release] table of your Cargo.toml only tells cargo what configuration options you'd like to use when you pass the --release flag. Other options include tuning LTO, optimization levels, and enabling/disabling rpath.

kbknapp
  • 172
  • 1
  • 5