Paul A. Bristow
Paul A. Bristow

Reputation: 51

How can I strip symbols from my executable when using Clang and the LLVM ELF ld.LLD linker?

I am building with Clang 9.0.0 and linking with the ld.lld linker

clang++.exe -Wall -fexceptions -m64 -O3 -Xclang -flto-visibility-public-std -std=c++2a -flto=thin  -c
  I:\Cpp\hello_boost\hello_codeblocks_world\hello_codeblocks_world.cpp -o obj\release\hello_codeblocks_world.o

clang++.exe  -o bin\release\hello_codeblocks_world.exe obj\release\hello_codeblocks_world.o  -m64 -fuse-ld=lld --strip-all  

but, unlike when using the usual GCC linker LD, this option (--strip-all or -s) is not recognized

clang++: error: unsupported option '--strip-all' (or similarly with -s)

Can anyone suggest what I should be doing to strip symbols?

(My release-mode hello_world.exe size is 15 kb for GC but 230 kB for Clang :-( and this is likely to have some adverse effects for no benefit).

Is this not an option for ld.lld ?

Thanks

Upvotes: 1

Views: 1330

Answers (1)

billy
billy

Reputation: 11

You might want to use: -Xlinker --strip-all You can use this to supply system-specific linker options that GCC does not recognize (gcc manual) https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

Upvotes: 1

Related Questions