# Kernel with clang and lto

## antonellocaroli

Hi,

i'm trying to compile a kernel with clang and lto,

with genkernel following this https://wiki.gentoo.org/wiki/Clang#Kernel, configuring genkernel as the guide, I always get a kernel that fails to start giving errors, with kernel panics...(I don't remember the errors well but it looks like segfault errors)

if instead I compile directly with

```
make CC=clang LD=ld.lld NM=llvm-nm AR=llvm-ar LLVM_IAS=1

make modules_install

make istall

```

I get a working kernel.

----------

## Jocelyn_M

It's quite easy, but one has to find it:

make LLVM=yes bzImage modules install modules_install

works well on multiple machines in my place.

The trick is just to set LLVM=<anything_not_empty> instead of trying to change CC, LD, ... individually

----------

