I am building rust sources with 'cargo build' command which sets the '-C debuginfo=2' for all crates by default. I want that to be disabled (in debug mode). I tried changing it in the Cargo.toml and various places in code 'src/cargo/core/profiles.rs' & 'src/cargo/core/compiler/mod.rs' also tried adding it in the toml file of a single crate but this flag is not changing (always sets to 2). When compiled in release mode the opt-level=3 is getting set and the debuginfo flag is not passed to cargo at all.
Is there any way I can disable this flag in debug mode? Let me know if any additional info needed.
to Cargo.toml of the crate you want to compile this way.
I’m not sure I completely follow your description in your question text; I’ll re-read a few more times to see if I can make more sense of it (edit: still not making 100% sense to me, as I don’t know what these src/cargo/… paths refer to, but I hope I’m giving a useful answer nonetheless; but feel free to clarify if it doesn’t work).
I haven’t tested it (edit: actually tested it now, too), but controlling the debuginfo level used for the debug-mode built with cargo build should work as described above, according to here and here.
(If you get any build error related to openssl, in .../rustc-1.69.0-src/src/tools/cargo/Cargo.toml update openssl dependencies as openssl = { version = '0.10.11', features = ["vendored"] } )
In the console log you see the options for compiling crates => ... --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 ....
I've tried these options given in here and here.. also the below but didn't work
[profile.dev]
debug = 0
There are 2 toml files. One inside rustc-1.69.0-src/src/tools/cargo/Cargo.toml and the other in rustc-1.69.0-src/Cargo.toml. The rustc-1.69.0-src/Cargo.toml file change worked.