You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add compiler option to strip symbols from generated binaries #71757
This might be best done as a rust-lang/rust PR first which has access to target information to know what flag should be passed to the linker. For example this could be added as -C strip or something like that. We could then add a profile setting for Cargo to configure that on the Cargo side of things afterwards.
I'm opening this issue to discuss adding such a -C strip flag and to track its implementation in the compiler.
Right now, it could be a simple boolean flag, which passes an additional option to the linker (since, AFAIK, most linkers have some sort of flag for stripping symbols from the final binaries).
I'm uncertain, but isn't -Zstrip-debuginfo-if-disabled essentially the same?
As far as I understand, this will only remove debug symbols, while the issue is about striping all symbol information (this means removing all symbols from an executable, and non-exported symbols for a dynamic library). What I am proposing would affect the size of release builds too.
This is analogous to the --strip-all and --strip-debug linker flags (and I believe this will only be achievable by configuring the linker).
Activity
ehuss commentedon May 1, 2020
I'm uncertain, but isn't
-Zstrip-debuginfo-if-disabledessentially the same?GabrielMajeri commentedon May 1, 2020
As far as I understand, this will only remove debug symbols, while the issue is about striping all symbol information (this means removing all symbols from an executable, and non-exported symbols for a dynamic library). What I am proposing would affect the size of release builds too.
This is analogous to the
--strip-alland--strip-debuglinker flags (and I believe this will only be achievable by configuring the linker).petrochenkov commentedon May 8, 2020
#71825 (comment) suggests introducing
-Z strip=[none|debuginfo|symbols].Auto merge of #8246 - GabrielMajeri:add-strip-option, r=alexcrichton