14

With included debug info, my binary becomes 400 MB about. This happens because Rust includes debug info for all dependencies. Is there any way to include debug info only for my code?

[package]
name = "app"
version = "0.7.1"
edition = "2018"

[dependencies]
actix = "*"
actix-web = {version = "1.0", features = ["ssl"]}
...
tokio-core = "*"
tokio = "*"

[profile.release]
debug = true
anatol
  • 145
  • 1
  • 4

1 Answers1

11

Edit: This functionality is now stabilized and can be used on the stable toolchain without the cargo-features manifest key. This functionality is documented in the Cargo reference.


If you're willing to use unstable cargo features with a nightly toolchain, this is possible through the cargo profile dependencies feature, like so:

cargo-features = ["profile-overrides"]

[package]
name = "app"
version = "0.7.1"
edition = "2018"

[dependencies]
actix = "*"
actix-web = {version = "1.0", features = ["ssl"]}
...
tokio-core = "*"
tokio = "*"

[profile.release]
debug = true

// disable debug symbols for all packages except this one
[profile.release.package."*"]
debug = false

apetranzilla
  • 5,331
  • 27
  • 34