Option -Z strip=val
controls stripping of debuginfo and similar auxiliary data from binaries
during linking.
Supported values for this option are:
none
- debuginfo and symbols (if they exist) are copied to the produced binary or separate files.pdb
files in case of MSVC).debuginfo
- debuginfo sections and debuginfo symbols from the symbol table sectionsymbols
- same as debuginfo
, but the rest of the symbol table section is stripped as wellHistory:
Is there a way to make the compiler emit separate debug symbol files (besides the default on Windows)?
@ccope I think split debug support on Linux is tracked in #34651.
This flag doesn't seem to work with the Darwin linker (ld64). MacOS is defined to use the gcc linker flavor, but although it uses clang, the underlying ld64 doesn't support gcc options.
Is there an intent to support that?
src\librustc_codegen_ssa\back\linker.rs
has a bunch of special cases for the MacOS linker, but it's still considered a GccLinker
linker flavor.
Perhaps it needs one more such case for symbol stripping.
That's pretty much all I know about MacOS linker and MacOS in general, so no plans to fix it from me.
MacOS linker supports -s
and -S
shorthand arguments, but not --strip-all
and --strip-debug
longhand arguments; given that the shorthands are supported by all GCC linkers (afaik), perhaps one only needs to change GccLinker::debuginfo()
to use those instead?
It turns out that, whilst the MacOS linker accepts the -s
and -S
shorthand arguments, they are obsolete and ignored (they generate warnings rather than the fatal errors produced with the longhand arguments).
The MacOS linker no longer provides any ability to strip its output. Instead, Apple provide a strip
utility that can be run on a resulting binary鈥攂ut caveat that it is designed for the output from Apple compilers and may not work with the layouts produced by other compilers. I've not had any issues using it with rust binaries, however.
This option needs to accept true
and false
, where true
would be the equivalent of symbols
and false
to none
.
Currently both lto
and debug
also support configuration using true
for the highest level, and false
for disabled.
Including this option would make a lot of sense and simplify usage of it (but would not remove the old functionality either)
Most helpful comment
This option needs to accept
true
andfalse
, wheretrue
would be the equivalent ofsymbols
andfalse
tonone
.Currently both
lto
anddebug
also support configuration usingtrue
for the highest level, andfalse
for disabled.Including this option would make a lot of sense and simplify usage of it (but would not remove the old functionality either)