Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Does gcc support thinlto?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
papu
l33t
l33t


Joined: 25 Jan 2008
Posts: 729
Location: Sota algun pi o alzina...

PostPosted: Sun Aug 18, 2024 9:01 pm    Post subject: Does gcc support thinlto? Reply with quote

hi,
I am not sure if gcc have thinLTO like clang has,
if yes , are there same level of performance between gcc and clang with thin?

COMMON_FLAGS="-O2 -pipe -march=native -flto=thin"
COMMON_FLAGS="-O2 -pipe -march=native -flto"

thanks :)
_________________
--so ~amd64 & openrc --cpu 7700 non-x --ram 2x16GB --gpu RX 470
Back to top
View user's profile Send private message
krumpf
Apprentice
Apprentice


Joined: 15 Jul 2018
Posts: 186

PostPosted: Sun Aug 18, 2024 9:12 pm    Post subject: Reply with quote

From GCC flto documentation :

Quote:
-flto[=n]
If you specify the optional n, the optimization and code generation done at link time is executed in parallel using n parallel jobs by utilizing an installed make program.
[…]
Use -flto=auto to use GNU make’s job server, if available, or otherwise fall back to autodetection of the number of CPU threads present in your system.


Afaik, there's no thinlto in gcc, it's specific to clang.
If you want to get better lto performance when using gcc, try to install and setup the mold linker.
_________________
Dragon Princess Music Games Heroes and villains
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22601

PostPosted: Sun Aug 18, 2024 9:21 pm    Post subject: Reply with quote

gcc supports -ffat-lto-objects and -fno-fat-lto-objects, where the latter would seem to be the "thin" variant. Per info gcc, no-fat is default on targets with linker plugin support.
Back to top
View user's profile Send private message
papu
l33t
l33t


Joined: 25 Jan 2008
Posts: 729
Location: Sota algun pi o alzina...

PostPosted: Sun Aug 18, 2024 9:30 pm    Post subject: Reply with quote

krumpf wrote:
From GCC flto documentation :

Quote:
-flto[=n]
If you specify the optional n, the optimization and code generation done at link time is executed in parallel using n parallel jobs by utilizing an installed make program.
[…]
Use -flto=auto to use GNU make’s job server, if available, or otherwise fall back to autodetection of the number of CPU threads present in your system.


Afaik, there's no thinlto in gcc, it's specific to clang.
If you want to get better lto performance when using gcc, try to install and setup the mold linker.


ok, thanks!
_________________
--so ~amd64 & openrc --cpu 7700 non-x --ram 2x16GB --gpu RX 470
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1254

PostPosted: Mon Aug 19, 2024 12:15 am    Post subject: Reply with quote

afaik, mold doesn't support LTO itself, it translates LTO to bfd/lld. So there is no any speed improvement with mold when using LTO.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1946

PostPosted: Mon Aug 19, 2024 12:45 am    Post subject: Reply with quote

mold has plugin support and can handle gcc LTO by itself. Curiously, the maintainer of mold is the same person who rejected such plugin support for lld a few years ago.

You can easily verify this by running:
Code:

echo 'int main() { __builtin_printf("hello\n"); }' | gcc -x c - -flto -fuse-ld=mold -Wl,-v -Wl,--trace
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1946

PostPosted: Mon Aug 19, 2024 12:51 am    Post subject: Reply with quote

Hu wrote:
gcc supports -ffat-lto-objects and -fno-fat-lto-objects, where the latter would seem to be the "thin" variant. Per info gcc, no-fat is default on targets with linker plugin support.


Yes, this matches my understanding.

Now, one question is whether GCC could implement the same style of partitioning as Clang to speed things up, but there are trade-offs associated with that (namely worse optimisation). There are other differences in how they implement LTO (the amount of information to stream, representing that, and so on) but it's not about thin-vs-not. GCC is also working on incremental LTO, not that it's much use for ebuilds.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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