Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Clang LTO Support Merged For Linux 5.12
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu May 20, 2021 10:00 pm    Post subject: Clang LTO Support Merged For Linux 5.12 Reply with quote

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


Joined: 21 Mar 2003
Posts: 178

PostPosted: Mon Jun 07, 2021 10:52 am    Post subject: Reply with quote

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. :D
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Mon Jun 07, 2021 5:21 pm    Post subject: Reply with quote

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


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Wed Jun 09, 2021 12:57 pm    Post subject: Reply with quote

So I was able to build the kernel, but the nvidia drivers however... https://forums.gentoo.org/viewtopic-t-1136808-highlight-clang.html

meanwhile I will carry on trying to build the entire system with clang
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Wed Jun 09, 2021 4:41 pm    Post subject: Reply with quote

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


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Sat Jun 12, 2021 11:37 am    Post subject: Reply with quote

Well the toolchain's need to align and so does the linking methodology

luckily Ionen pushed out an experimental update and it works well
https://forums.gentoo.org/viewtopic-t-1136808-highlight-.html
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1249

PostPosted: Sat Jun 12, 2021 12:52 pm    Post subject: Reply with quote

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


Joined: 06 Dec 2018
Posts: 2719

PostPosted: Sat Jun 12, 2021 1:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1249

PostPosted: Sat Jun 12, 2021 1:33 pm    Post subject: Reply with quote

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


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Sat Jun 12, 2021 1:44 pm    Post subject: Reply with quote

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


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Sat Jun 12, 2021 3:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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