View previous topic :: View next topic |
Author |
Message |
Brane2 n00b
Joined: 03 Jul 2011 Posts: 44
|
Posted: Sat Jul 17, 2021 11:59 am Post subject: Using lld as default linker for all packages ? |
|
|
I have latest gcc ( 11.1.0-r2), clang/llvm/lld(12.0.1) and have tried to use lld as default linker.
And use some of its unique linking options ( --icf=safe,--print-icf-sections, --lto-Ox etc).
I have -fuse-ld=lld in COMMON options that are included into CFLAGS/CXXFLAGS and LDFLAGS
And I have "LD=/usr/bin/ld.lld"
But with this, every emerge fails with lld complaining that it can't find symbol of program entry point ( main function).
So, my relevant vars in make.conf look like this:
Quote: | COMMON_FLAGS="-march=native -O3 -flto=16 -pipe -fuse-ld=lld"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
LD=/usr/bin/ld.lld
LDFLAGS="${COMMON_FLAGS} -Wl,--flto-O3,-O3 -Wl,--sort-common,--as-needed -Wl,--gc-sections,--print-gc-sections -Wl,icf=safe,print-.icf-sections" |
But even trying to compile lld itself with that fails with:
Quote: |
ld.lld: error: undefined symbol: main
rerenced by /usr/lib/x86_64-pc-linux-gnu/11.1.0/../../../../lib64/Scrt1.o:(start)
|
Is there some other trick to it ?
Or perhaps it isn't meant to work yet with gcc in common case ?
It fails in this way even if leave LDFLAGS empty...
UPDATE: I took a hint from footnote of:
[gcc link options](https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html)
adding `-shared` to COMMON_FLAGS seems to be working. _________________ On the journey of life I chose the psycho path... |
|
Back to top |
|
|
Brane2 n00b
Joined: 03 Jul 2011 Posts: 44
|
Posted: Sun Jul 18, 2021 2:20 pm Post subject: Re: Using lld as default linker for all packages ? |
|
|
Errm, scratch that. Lld wasn't meant to be used with gcc in LTO mode.
It compiled lld itself, but failed with basically everything else. _________________ On the journey of life I chose the psycho path... |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|