With the new LTO patches in the kernel it would be nice to be able to use them in conjunction with genkernel. As far as I can tell the following commandlines do the trick: make CC=clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1 menuconfig (choose LTO) make CC=clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1 Without any of these options LTO disappears from the .config Apart from the CC and LD options I found no solution for the other flags. Reproducible: Always
I don't think we will add explicit support for this. You can set compiler to clang/llvm already, please have a look at /etc/genkernel.conf or read man page (--kernel-cc and friends). You would just need to pass LLVM_IAS=1 to your genkernel call in addition if you want to enable LLVM assembler.
Not looking for explecit support, but I cannot figure out how to properly pass the NM=llvm-nm AR=llvm-ar LLVM_IAS=1 parameters to the make command.
Please read man page (`man genkernel`). You can either pass "--kernel-cc=clang ..." or set values in /etc/genkernel.conf.
That doesn't work, both: genkernel all --install --no-splash --oldconfig --kernel-cc="clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1" and genkernel all --install --no-splash --oldconfig "--kernel-cc=clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1" immediately give "Restart config..." while a manual "make CC=clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1" works fine.
Please read man page. --kernel-cc is just for CC. You have to use similar commands for NM, AR...
(In reply to Thomas Deutschmann from comment #5) > Please read man page. --kernel-cc is just for CC. You have to use similar > commands for NM, AR... That simply doesn't work, the man page does not give an option to add these parameters! See (this doesn't even include the "freeform" LLVM_IAS=: genkernel all --install --no-splash --oldconfig --kernel-cc=clang --kernel-ld=ld.lld --kernel-nm=llvm-nm --kernel-ar=llvm-ar ERROR: Unknown option '--kernel-nm=llvm-nm'!
OK, we are not exposing all stuff, you can overwrite everything listed in https://gitweb.gentoo.org/proj/genkernel.git/tree/defaults/config.sh?h=v4.2.1#n40. Please don't edit /usr/share/genkernel/defaults/config.sh directly, set KERNEL_NM in /etc/genkernel.conf for example.
After overriding the AR and NM it still drops to "Restart config...", while the config is valid when the make command is called manually. What could be wrong?
same here, any workarounds apart from manual build?
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=a30b7139cfad7261c84345b136c671744e64ec29 commit a30b7139cfad7261c84345b136c671744e64ec29 Author: Thomas Deutschmann <whissi@gentoo.org> AuthorDate: 2021-07-06 20:22:12 +0000 Commit: Thomas Deutschmann <whissi@gentoo.org> CommitDate: 2021-07-06 20:59:30 +0000 gen_cmdline.sh: parse_cmdline(): Allow to override AS, AR, NM & Co via CLI Bug: https://bugs.gentoo.org/786405 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org> doc/genkernel.8.txt | 44 +++++++++++++++++++++++++++++++- gen_cmdline.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++----- genkernel.conf | 38 +++++++++++++++++++--------- 3 files changed, 135 insertions(+), 19 deletions(-)
With this change I was able to compile kernel using CLANG, even with LTO enabled.
Fixed in >=sys-kernel/genkernel-4.2.2!
Seems to work fine, many many thanks for the patches! One tiny question, is it ok to do this: KERNEL_MAKE="make LLVM=1 LLVM_IAS=1 ? For anyone finding this bug: genkernel.conf: KERNEL_AS="llvm-as" KERNEL_AR="llvm-ar" KERNEL_CC="clang" KERNEL_LD="ld.lld" KERNEL_NM="llvm-nm" UTILS_AS="llvm-as" UTILS_AR="llvm-ar" UTILS_CC="clang" UTILS_CXX="clang++" UTILS_LD="ld.lld" UTILS_NM="llvm-nm" invoking menuconfig: make CC=clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1 menuconfig invoking the build: genkernel all --install --no-splash --oldconfig --utils-objcopy=llvm-objcopy --utils-objdump=llvm-objdump --utils-readelf=llvm-readelf --utils-strip=llvm-strip --utils-ranlib=llvm-ranlib --kernel-objcopy=llvm-objcopy --kernel-objdump=llvm-objdump --kernel-readelf=llvm-readelf --kernel-strip=llvm-strip --kernel-ranlib=llvm-ranlib
No, it's not. Most build systems won't expected spaces in values so you will run into errors due to quoting/word splitting. What you can do: Set this variables before running genkernel, i.e. LLVM=1 LLVM_IAS=1 genkernel ...
(In reply to Thomas Deutschmann from comment #14) > No, it's not. Most build systems won't expected spaces in values so you will > run into errors due to quoting/word splitting. What you can do: Set this > variables before running genkernel, i.e. > > LLVM=1 LLVM_IAS=1 genkernel ... Just emerged gentoo-sources with clang-13 appending LLVM=1 just doesn't make kernel compiled with clang I had to change KERNEL_* in config file I'm using genkernel as a hook for gentoo-sources like this post_pkg_postinst() { LLVM=1 genkernel --kernel-config="/etc/portage/savedconfig/sys-kernel/gentoo-sources/.config" all || die eclean-kernel grub-mkconfig -o /boot/grub/grub.cfg }