Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I include debug information only for my code without packages?

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
like image 461
anatol Avatar asked Oct 30 '19 14:10

anatol


People also ask

How do I debug a specific part of a code?

Run to a breakpoint in code You can also select the line and then select F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert Breakpoint. The breakpoint appears as a red dot in the left margin next to the line of code. The debugger suspends execution just before the line runs.

What does enable just my code do?

Just My Code is a Visual Studio debugging feature that automatically steps over calls to system, framework, and other non-user code.

What is Release with debug info?

RelWithDebugInfo means build with debug symbols, with or without optimizations. Anyway, the debug symbols can be stripped later, both using strip and/or obj-copy. If you use strip, the output can be saved.


1 Answers

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

like image 176
apetranzilla Avatar answered Oct 11 '22 10:10

apetranzilla