我可以只为我的代码添加调试信息而没有包吗?


11

包含调试信息,我的二进制文件大约变为400 MB。发生这种情况是因为Rust包含所有依赖项的调试信息。有什么办法只为我的代码包括调试信息吗?

[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

Answers:


7

如果您愿意在夜间使用工具链使用不稳定的货物功能,则可以通过货物档案依赖功能来实现,如下所示:

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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.