Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
genkernel-next with clang and gold
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
Marlo
Veteran
Veteran


Joined: 26 Jul 2003
Posts: 1414

PostPosted: Wed Sep 27, 2017 7:01 pm    Post subject: genkernel-next with clang and gold Reply with quote

Hello!

I changed my system to clang and gold. It works well.
For the kernel I use genkernel-next and would like to use just as well. But Genkernel is used by default the gcc compiler.

In /etc/genkernel.conf there are the options:

http://docs.huihoo.com/gentoo/resources/document-listing/genkernel.html wrote:

Genkernel supports the following flags which are assigned to the relevant applications when your kernel is assembled:

--kernel-as = someAssembler: This specifies to assembler which would be used for compiling your kernel.
--kernel-cc = someCompiler: This specifies a compiler which would be used for compiling your kernel.
--kernel-ld = someLinker: This specifies a linker which would be used for compiling your kernel.
--kernel-make = someMake: This specifies to alternate GNU Make your kernel.

--utils-as = someAssembler: This specifies an assembler which would be used for compiling the support utilities.
--utils-cc = someCompiler: This specifies a compiler which would be used for compiling the support utilities.
--utils-ld = someLinker: This specifies a linker, which would be used for compiling the support utilities.
--utils-make = someMake: This specifies to alternate GNU.


But, what are the "specifies" flags? I could not find anything for clang and gold.

Thanks in advance for any help!
ma
-----
edit: Bug 632227
_________________
Thank you for your attention, interest and support.
------------------------------------------------------------------
http://radio.garden/
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 583

PostPosted: Fri Sep 29, 2017 3:59 pm    Post subject: Reply with quote

Last I heard clang is not yet capable of compiling the linux kernel. I'm not sure if that is still the case though. You might want to cd into /usr/src/linux and manually try building the kernel with it to see if it works now. I don't think it will.
Back to top
View user's profile Send private message
Marlo
Veteran
Veteran


Joined: 26 Jul 2003
Posts: 1414

PostPosted: Fri Sep 29, 2017 10:00 pm    Post subject: Reply with quote

tux /usr/src/linux # make && make modules_install wrote:

......
DATAREL arch/x86/boot/compressed/vmlinux
Kernel: arch/x86/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST 80 modules
.......
INSTALL sound/usb/usx2y/snd-usb-us122l.ko
INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
DEPMOD 4.12.12-gentoo


make && make modules_install works very well. But I can not see whether make uses the gcc or clang.
This is not important in principle either. I just wanted to know it.

Thanks for your reply.
Ma
_________________
Thank you for your attention, interest and support.
------------------------------------------------------------------
http://radio.garden/
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 583

PostPosted: Fri Sep 29, 2017 10:46 pm    Post subject: Reply with quote

Marlo wrote:
tux /usr/src/linux # make && make modules_install wrote:

......
DATAREL arch/x86/boot/compressed/vmlinux
Kernel: arch/x86/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST 80 modules
.......
INSTALL sound/usb/usx2y/snd-usb-us122l.ko
INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
DEPMOD 4.12.12-gentoo


make && make modules_install works very well. But I can not see whether make uses the gcc or clang.
This is not important in principle either. I just wanted to know it.

Thanks for your reply.
Ma


I think you have to use the CC=clang environment variable set before make
https://wiki.gentoo.org/wiki/Clang#Clang_environments
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13836

PostPosted: Fri Sep 29, 2017 11:24 pm    Post subject: Reply with quote

duby2291 wrote:
Last I heard clang is not yet capable of compiling the linux kernel. I'm not sure if that is still the case though.
Very timely LWN piece: Building the kernel with clang. In short, it can be done now for some useful configurations, but it's not possible for every configuration that gcc can handle.
Back to top
View user's profile Send private message
Marlo
Veteran
Veteran


Joined: 26 Jul 2003
Posts: 1414

PostPosted: Sat Sep 30, 2017 10:10 am    Post subject: Reply with quote

duby2291 wrote:


I think you have to use the CC=clang environment variable set before make
https://wiki.gentoo.org/wiki/Clang#Clang_environments


I have set the system to use the global configuration via make.conf.
https://wiki.gentoo.org/wiki/Clang#Global_configuration_via_make.conf.

And if I set the variable CC = "clang" in addition, that works synonymous.
tux /usr/src/linux # CC="clang" make:

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Setup is 15868 bytes (padded to 15872 bytes).
System is 12051 kB
CRC d9c40890
Kernel: arch/x86/boot/bzImage is ready  (#1)
  Building modules, stage 2.
  MODPOST 80 modules


Hu wrote:

Very timely LWN piece: Building the kernel with clang. In short, it can be done now for some useful configurations, but it's not possible for every configuration that gcc can handle.

Thanks for this interesting link.

https://lwn.net/Articles/734071/ wrote:

Hackmann related the state of the upstream kernel: "we are very close to having a kernel that can be built with Clang". It does require using a recent Clang that has some fixes, but the x86_64 and ARM64 kernels can be built, though each architecture has one out-of-tree patch that needs to be applied to do so.


I use the gentoo kernel 4.12.12 and I do not think that is already patched.

It seems that my configuration with clang works (maybe). But "make" and "genkernel-next" still switch to gcc.
Ma
_________________
Thank you for your attention, interest and support.
------------------------------------------------------------------
http://radio.garden/
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 583

PostPosted: Sat Sep 30, 2017 2:57 pm    Post subject: Reply with quote

Marlo wrote:
duby2291 wrote:


I think you have to use the CC=clang environment variable set before make
https://wiki.gentoo.org/wiki/Clang#Clang_environments


I have set the system to use the global configuration via make.conf.
https://wiki.gentoo.org/wiki/Clang#Global_configuration_via_make.conf.

And if I set the variable CC = "clang" in addition, that works synonymous.
tux /usr/src/linux # CC="clang" make:

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Setup is 15868 bytes (padded to 15872 bytes).
System is 12051 kB
CRC d9c40890
Kernel: arch/x86/boot/bzImage is ready  (#1)
  Building modules, stage 2.
  MODPOST 80 modules


Hu wrote:

Very timely LWN piece: Building the kernel with clang. In short, it can be done now for some useful configurations, but it's not possible for every configuration that gcc can handle.

Thanks for this interesting link.

https://lwn.net/Articles/734071/ wrote:

Hackmann related the state of the upstream kernel: "we are very close to having a kernel that can be built with Clang". It does require using a recent Clang that has some fixes, but the x86_64 and ARM64 kernels can be built, though each architecture has one out-of-tree patch that needs to be applied to do so.


I use the gentoo kernel 4.12.12 and I do not think that is already patched.

It seems that my configuration with clang works (maybe). But "make" and "genkernel-next" still switch to gcc.
Ma


Somebody can correct me if I'm wrong, but I don't think make actually reads portages make.conf. For years I've believed it is actually a mis-named configuration file. You have to actually set the environment variable on the command line before your make command. something like "CC=clang make bzImage modules && make modules_install install"
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13836

PostPosted: Sat Sep 30, 2017 4:21 pm    Post subject: Reply with quote

You are correct, and Marlo did show that, although the way it is presented as a code tag label can be missed if you do not look closely. For make, but not for most programs, you can also set the variable as a program argument: make CC=clang targets. This has slightly different semantics for processing a Makefile. When a Makefile assigns a variable using the classic syntax VARIABLE = value, that overrides environment variables, but not command line arguments. When it assigns using ?=, the environment variable takes precedence.
Back to top
View user's profile Send private message
Marlo
Veteran
Veteran


Joined: 26 Jul 2003
Posts: 1414

PostPosted: Sat Sep 30, 2017 6:52 pm    Post subject: Reply with quote

Yes, thank you duby2291 and Hu.
You recorded the correct syntax.
It is not possible to compile the gentoo kernel with clang.

tux /usr/src/linux # env | grep clang:

CC=clang


Sample:
make CC=clang bzImage:
 
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
error: unable to load plugin './scripts/gcc-plugins/structleak_plugin.so': './scripts/gcc-plugins/structleak_plugin.so: undefined symbol: cfun'
make[1]: *** [Kbuild:21: kernel/bounds.s] Fehler 1
make: *** [Makefile:1064: prepare0] Fehler 2


Crosscheck:
make CC="gcc" bzImage:

 CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Setup is 15868 bytes (padded to 15872 bytes).
System is 12051 kB
CRC d9c40890


Thank you very much for your comments and help.
Ma

[Moderator edit: changed [quote] tags to [code] tags to preserve output layout. -Hu]
_________________
Thank you for your attention, interest and support.
------------------------------------------------------------------
http://radio.garden/
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