Compile in release mode without debugging symbols

Hi,

I’m building a hello world app on Windows with the stable-x86_64-pc-windows-msvc toolchain and I cannot find a way not to generate debugging symbols in release mode.

I tried to set the debuginfo codegen option to 0 but it does not seem to work.
Do you know which option I should use?

Thanks!

Does Windows have a strip command?

There’s a long-standing bug in Rust that it picks up debug information from stdlib, even in release mode, so Rust can’t produce executables (with std) without debug information and requires a separate strip step.

1 Like

The debugging symbols for pc-windows-msvc targets are in a separate .pdb file. They’re not part of the binary itself and therefore do not need to be stripped. Why is the presence of this .pdb file so dangerous to you? Why do you insist on not allowing it to even generate?

Symbols are indeed in a separate .pdb file but the linker also adds a header in the binary that contains the full path and file name of the associated pdb. I would like not to get this header in my binaries and the way I usually do this is by not generating symbols.

In that case you just have to pass the linker argument /DEBUG:NONE. You’ll need to use -Clink-arg=/DEBUG:NONE to get rustc to pass it to the linker, and you’ll need to use rustflags in .cargo/config or cargo rustc to pass that flag to rustc.

Perfect! Thanks for the help!