Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using lld as default linker for all packages ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Brane2
n00b
n00b


Joined: 03 Jul 2011
Posts: 44

PostPosted: Sat Jul 17, 2021 11:59 am    Post subject: Using lld as default linker for all packages ? Reply with quote

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
View user's profile Send private message
Brane2
n00b
n00b


Joined: 03 Jul 2011
Posts: 44

PostPosted: Sun Jul 18, 2021 2:20 pm    Post subject: Re: Using lld as default linker for all packages ? Reply with quote

Brane2 wrote:

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.


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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
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