www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Strip Unused Symbols Ldc + Windows

reply SrMordred <patric.dexheimer gmail.com> writes:
Someone knows how to strip unused symbols on final binary using 
ldc on windows ?
i found this about this topic:

https://forum.dlang.org/post/yvmnkvzgoxhcfavjayky forum.dlang.org

that uses --gc-sections and --version-script but this options are 
not avaliable in windows lld-link
Mar 20 2020
parent reply kinke <noone nowhere.com> writes:
On Saturday, 21 March 2020 at 01:54:00 UTC, SrMordred wrote:
 Someone knows how to strip unused symbols on final binary using 
 ldc on windows ?
 i found this about this topic:

 https://forum.dlang.org/post/yvmnkvzgoxhcfavjayky forum.dlang.org

 that uses --gc-sections and --version-script but this options 
 are not avaliable in windows lld-link
That was about ELF symbol visibility and doesn't apply to Windows at all. - The symbols are stripped by default for Windows targets (/OPT:REF for MS linker/LLD). You can cross-check by disabling via `-disable-linker-strip-dead`.
Mar 21 2020
parent reply SrMordred <patric.dexheimer gmail.com> writes:
On Saturday, 21 March 2020 at 15:53:53 UTC, kinke wrote:
 On Saturday, 21 March 2020 at 01:54:00 UTC, SrMordred wrote:
 Someone knows how to strip unused symbols on final binary 
 using ldc on windows ?
 i found this about this topic:

 https://forum.dlang.org/post/yvmnkvzgoxhcfavjayky forum.dlang.org

 that uses --gc-sections and --version-script but this options 
 are not avaliable in windows lld-link
That was about ELF symbol visibility and doesn't apply to Windows at all. - The symbols are stripped by default for Windows targets (/OPT:REF for MS linker/LLD). You can cross-check by disabling via `-disable-linker-strip-dead`.
Hmm, ok, my question is in fact relate to this kind of thing: https://godbolt.org/z/NGjyyx Why int example.add(int, int): its still on the binary when all u need is alredy optimized to main: mov eax, 30 ret ?
Mar 21 2020
parent reply kinke <noone nowhere.com> writes:
On Saturday, 21 March 2020 at 17:33:21 UTC, SrMordred wrote:
 Hmm, ok, my question is in fact relate to this kind of thing:
 https://godbolt.org/z/NGjyyx

 Why int example.add(int, int): its still on the binary when all 
 u need is alredy optimized to
 main:
  mov     eax, 30
  ret

 ?
You're inspecting an object file, before any linker and symbol stripping is involved.
Mar 21 2020
parent SrMordred <patric.dexheimer gmail.com> writes:
On Saturday, 21 March 2020 at 18:01:55 UTC, kinke wrote:
 On Saturday, 21 March 2020 at 17:33:21 UTC, SrMordred wrote:
 Hmm, ok, my question is in fact relate to this kind of thing:
 https://godbolt.org/z/NGjyyx

 Why int example.add(int, int): its still on the binary when 
 all u need is alredy optimized to
 main:
  mov     eax, 30
  ret

 ?
You're inspecting an object file, before any linker and symbol stripping is involved.
Oh, i thought that the symbol stripping was before linker!, my bad, thanks!
Mar 21 2020