View previous topic :: View next topic |
Author |
Message |
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Thu May 20, 2021 10:00 pm Post subject: Clang LTO Support Merged For Linux 5.12 |
|
|
https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.12-Clang-LTO-Merged
The essence:
After entering the kernel tree please run
Code: |
make LLVM=1 LLVM_IAS=1 menuconfig #.I suppose you can use any target you like..I just prefer a stock .config that i usually steal from Arch so i dont run this first step
scripts/config -e LTO_CLANG_THIN
make LLVM=1 LLVM_IAS=1
|
Before running "make LLVM=1 LLVM_IAS=1" please make sure that in your .config the initial stanza is something like
Code: |
CONFIG_CC_VERSION_TEXT="clang version 12.0.0"
CONFIG_GCC_VERSION=0
CONFIG_CC_IS_CLANG=y
CONFIG_CLANG_VERSION=120000
CONFIG_LD_VERSION=0
CONFIG_LD_IS_LLD=y
CONFIG_LLD_VERSION=120000
CONFIG_CC_CAN_LINK=y
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
CONFIG_TOOLS_SUPPORT_RELR=y
CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_TABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y
|
Then when you run
make LLVM=1 LLVM_IAS=1
it will offer you among others a choice of Clang LTO thin or full.
I am making a kernel right now...
Lets see........
_________________
Last edited by alamahant on Mon Jun 07, 2021 5:46 pm; edited 1 time in total |
|
Back to top |
|
|
Torangan Apprentice
Joined: 21 Mar 2003 Posts: 178
|
Posted: Mon Jun 07, 2021 10:52 am Post subject: |
|
|
I just tried to build gentoo-sources-5.12.9 with clang LTO but it doesn't work. It shows me clang and the setup variables but my LTO choices are only LTO=none. Neither full nor thin offered. What am I doing wrong?
EDIT: not having lld installed was kind of a showstopper here. |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Mon Jun 07, 2021 5:21 pm Post subject: |
|
|
Did you run
Code: |
make LLVM=1 LLVM_IAS=1 menuconfig
scripts/config -e LTO_CLANG_THIN
make LLVM=1 LLVM_IAS=1
|
from inside the kernel tree?
For me it worked just fine but it produced a slightly bigger kernel. _________________
|
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Wed Jun 09, 2021 4:41 pm Post subject: |
|
|
Yes for some obscure reason you cant build external modules.
For me both nvidia and zfs-kmod.
Maybe you need to use clang to build them but still i couldnt. _________________
|
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
|
Back to top |
|
|
Perfect Gentleman Veteran
Joined: 18 May 2014 Posts: 1249
|
Posted: Sat Jun 12, 2021 12:52 pm Post subject: |
|
|
Code: | fsck | to "Linux version 5.12.10-gentoo (root@De-Humanizer) (clang version 12.0.1, LLD 12.0.1) #1 SMP PREEMPT Sat Jun 12 16:13:09 +07 2021" |
cannot build NTFS3 module and virtualbox-modules |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2719
|
Posted: Sat Jun 12, 2021 1:09 pm Post subject: |
|
|
Perfect Gentleman wrote: | cannot build NTFS3 module and virtualbox-modules | Yeah, every modules are likely to fail except nvidia-drivers without at least some workarounds.
Passing the right toolchain is something that could be added to linux-mod.eclass eventually but that the kernel enables thinlto cache by default is a problem for sandbox and there's not really a safe way to turn it off for every modules right now (for nvidia-drivers I know I can safetly set ldflags-y and LDFLAGS_MODULE though).
You could of course remove it from the kernel source itself, or use full lto instead. Not to say they may not fail for other reasons (looking into it, nvidia apparently been testing this). |
|
Back to top |
|
|
Perfect Gentleman Veteran
Joined: 18 May 2014 Posts: 1249
|
Posted: Sat Jun 12, 2021 1:33 pm Post subject: |
|
|
It was built with FullLTO. There is patch for NTFS3 module, but I haven't tested it. And I have no clue how to build virtualbox-modules. |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Sat Jun 12, 2021 1:44 pm Post subject: |
|
|
I built it with flto=thin.
I will try to use Ionen's solution at least for nvidia-drivers.
Be back soon. _________________
|
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Sat Jun 12, 2021 3:13 pm Post subject: |
|
|
Between this nvidia tweak and the libunwind update, converting as much of mmy system is now a reality
Code: | bash test.sh
Build with GCC:951 Built with Clang:297 23% conversion |
this is just an emerge -e @system with 200 packages to go and only 5 needed adding to package.env explicitly calling gcc. Once this is done ill filter down the remaining _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
|