# STABLE-13 Kernel fails to build: kmalloc issue



## DrEuclidean (Jan 25, 2021)

I'm trying to build the FreeBSD STABLE-13 kernel, but it errors out in various ways all relating to invocations of kmalloc

I'm running an older version of CURRENT-13

```
/usr/src/sys/compat/linuxkpi/common/include/linux/string.h:122:11: error: implicit declaration of 'kmalloc'

errors in sys/compat/linuxkpi/common/include/linux/slab.h for kmalloc, kmalloc_array, and kfree all stating that their static declaration follows a non-static declaration.
```
also in drm-current-kmod it says pci_bus_read_config is redefined.

I'm unsure how to proceed.
Thank you.


----------



## debguy (Feb 8, 2021)

simply, kmalloc(foo) came before any inlcuded header described it's declaration (or, some included declaration used kmalloc before kmalloc's real header was included)

either:
(1) your .c file uses kmalloc without including the correct header
(2) your linux heaaders are wrongly edited
(3) you or the .c have done the right thing in the wrong compiler environment.  BSD headers aren't the same as gcc headers nor gcc the same as clang, you will include headers by bsd standards in things compiled for bsd, but use linux standards when compiled by gcc or, if compatible, clang).  warning:  check those linux headers:  by default they are per kernel and need to be checked over by a linux expert as if exported from linux properly and then also: gcc.  gcc's headers are infamously hacked and a script that comes with gcc will mangle them (meaning, ubuntu and redhat are king of gcc but doen't use the product of the gcc header fixer script - its' a secret?)

i'm guessing you should update - whover is working on the beta may have already imported different linux headers or fixed the headers for you by now

I think Sir Dice would say this is the installer forum not the advanced development forum and not to post that kind of question here.


----------



## SirDice (Feb 8, 2021)

debguy said:


> I think Sir Dice would say this is the installer forum not the advanced development forum and not to post that kind of question here.


You're mistaken. You have no idea what you're talking about. 



DrEuclidean said:


> I'm trying to build the FreeBSD STABLE-13 kernel


When was the last time you fetched the sources? stable/13 is still somewhat in flux after being split off. Make sure to fetch the latest commits. And I would recommend doing a full build, not just the kernel. `make buildworld buildkernel` (you may want to add `-j <X>` to that to speed it up). 






						src - FreeBSD source tree
					






					cgit.freebsd.org


----------

