# Unable to build 5.1-rc* Kernel

## saski4711

Hi,

it seems that any Kernel 5.1-rc* won't compile on my current Gentoo:

```

/usr/include/libelf/gelf.h:25:5: error: "__LIBELF_INTERNAL__" is not defined, evaluates to 0 [-Werror=undef]

 #if __LIBELF_INTERNAL__

     ^~~~~~~~~~~~~~~~~~~

In file included from elf.h:22,

                 from check.h:22,

                 from orc_gen.c:22:

```

I can work around this with:

```

CFLAGS="-Wno-error=undef"

```

however I cannot install/build Virtualbox:

```

This system is currently not set up to build kernel modules.

Please install the Linux kernel "header" files matching the current kernel

```

I suspect the linux-headers is too old (5.0). What can I do?

Cheers

----------

## fedeliallalinea

 *saski4711 wrote:*   

> What can I do?

 

Waiting official release of this kernel version?

----------

## saski4711

 *fedeliallalinea wrote:*   

>  *saski4711 wrote:*   What can I do? 
> 
> Waiting official release of this kernel version?

 

Yeah I was hoping for a somewhat quicker solution   :Embarassed: 

----------

## toralf

 *saski4711 wrote:*   

> I suspect the linux-headers is too old (5.0). What can I do?

 

```
echo "~sys-kernel/linux-headers-5.0" >> /etc/portage/package.accept_keywords/<your file>
```

?

----------

## saski4711

 *toralf wrote:*   

>  *saski4711 wrote:*   I suspect the linux-headers is too old (5.0). What can I do? 
> 
> ```
> echo "~sys-kernel/linux-headers-5.0" >> /etc/portage/package.accept_keywords/<your file>
> ```
> ...

 

Thanks. Switched back to 5.0 official.

----------

## ShinyDoofy

This change was introduced via commit 056d28d1 (via this GitHub issue.

I've had the same initial error message when compiling the 5.1 kernel. A possible solution is indicated here:

```
emerge --deselect dev-libs/libelf

emerge -v virtual/libelf
```

That did the trick for me to get the kernel compiled. Maybe it helps somebody else as well  :Smile: 

----------

## pleasantatk

I temporarily removed pkgconf and it worked.

Rationale / reason this works: https://github.com/NixOS/nixpkgs/issues/59929

tl;dr: recent upstream linux commit switched detection of libelf to pkgconfig, so it's being included via -I instead of -isystem. As a result, certain flags which were previously ignored due to -isystem are now combining with otherwise minor issues in the header file to result in catastrophe.

As I mentioned there, I'm planning on submitting a fix to the broken headers upstream, which will remove the real problem entirely.

Removing pkgconf manually using `emerge -C pkgconf`, building the kernel, and then reinstalling pkgconf seems to be the best solution ATM.

----------

## saski4711

This issue is still there. I wonder why this isn't hitting more pepole using gentoo. Anyway the best workaround IMHO is to tell GCC not to treat a warning as an error:

```
CFLAGS="-Wno-error=undef" make bzImage
```

----------

## risa2000

I just got it when compiling the recent stable vanilla (5.2.4). I used the workaround suggested by @ShinyDoofy above and it went well.

----------

## Mappy

I'm getting this error with the 5.2.8 kernel. Temporarily removing pkgconf works but I would rather not do that during every kernel upgrade.

----------

