View previous topic :: View next topic |
Author |
Message |
papu l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 25 Jan 2008 Posts: 728 Location: Sota algun pi o alzina...
|
Posted: Sun Aug 18, 2024 9:01 pm Post subject: Does gcc support thinlto? |
|
|
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 ![Smile :)](images/smiles/icon_smile.gif) _________________ --so ~amd64 & openrc --cpu 7700 non-x --ram 2x16GB --gpu RX 470 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
krumpf Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 15 Jul 2018 Posts: 182
|
Posted: Sun Aug 18, 2024 9:12 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 22392
|
Posted: Sun Aug 18, 2024 9:21 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
papu l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 25 Jan 2008 Posts: 728 Location: Sota algun pi o alzina...
|
Posted: Sun Aug 18, 2024 9:30 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Perfect Gentleman Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/127084678760dc546c6b873.jpg)
Joined: 18 May 2014 Posts: 1254
|
Posted: Mon Aug 19, 2024 12:15 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
sam_ Developer
![Developer Developer](/images/ranks/rank-dev.gif)
![](images/avatars/7738740495f7d1acc45bdb.jpg)
Joined: 14 Aug 2020 Posts: 1862
|
Posted: Mon Aug 19, 2024 12:45 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
sam_ Developer
![Developer Developer](/images/ranks/rank-dev.gif)
![](images/avatars/7738740495f7d1acc45bdb.jpg)
Joined: 14 Aug 2020 Posts: 1862
|
Posted: Mon Aug 19, 2024 12:51 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|