# Regarding custom compilation in FreeBSD



## Pegasus711 (Apr 12, 2010)

Hello folks,

I have been reading about compiling the kernel mostly from hereand the relevant links that page contains like this and this.

Now since I want to enable kernel level debugging I am following this page about enabling ddb. To do that, I have created a configuration file called _MYKERNEL_ ( sounds cliched , but what the heck) and in keeping with the present trend, have included the original GENERIC file in the new configuration file called MYERNEL.

Now my new config file starts out like:

```
include GENERIC
ident MYKERNEL
```
 followed by


```
options KDB
options DDB
```
But when I compile the kernel, using 

```
make buildkernel KERNCONFIG=MYKERNEL
```
it looks like it rebuilds everything or atleast seems to check the dependencies that this change might have affected. IS there a way to speeden things up a little?

Now one of the links above, i.e. this talks about speeding up the compile process by explicitly telling the make uitlity to only build those modules which have been 'tainted' in some way because of the new config file. But I do not know the modules that might need to be rebuilt yet I want the build process to figure it out itself. Is this what happens or am I asking for too much?

Looking to hear from you,

Regards,
Aijaz Baig.


----------



## SirDice (Apr 12, 2010)

aijazbaig1 said:
			
		

> But when I compile the kernel, using
> 
> ```
> make buildkernel KERNCONFIG=MYKERNEL
> ...



I think the fastest way is to create a 2GB ram disk and mount that on /usr/obj. Of course you will lose everything when you reboot. But seriously, it only takes about 2 hours on my machine to do a full buildworld and several kernels. 



> Now one of the links above, i.e. this talks about speeding up the compile process by explicitly telling the make uitlity to only build those modules which have been 'tainted' in some way because of the new config file. But I do not know the modules that might need to be rebuilt yet I want the build process to figure it out itself. Is this what happens or am I asking for too much?


That'll work but you have to have built it at least once for this to work.


----------



## Pegasus711 (Apr 12, 2010)

Well thanks for the very prompt reply sir!

Could you please elaborate on 





> "That'll work but you have to have built it at least once for this to work."



I guess I would try that once my new custom kernel is up and running (assuming it does run since I have been had problems running it previously!)

Regards,
Aijaz


----------



## SirDice (Apr 12, 2010)

The build process can tell which modules are tainted and would need a rebuild. Usually this works without problems. I've never used it though, just compiling the kernel only takes a few minutes. And if you run into problems you are advised to do a full kernel build anyway.


----------



## trasz@ (Apr 12, 2010)

To avoid recompiling everything, use KERNFAST (e.g. "make buildkernel KERNCONF=MYKERNEL KERNFAST=1").  Note that this won't work if you have clean object directory - basically, if you have empty /usr/obj (after "make clean"), you first have to build the kernel without KERNFAST.  After that, you can change code and compile it quickly using KERNFAST.


----------



## phoenix (Apr 12, 2010)

Nice addition to the build framework.  

Haven't finished reading through Makefile.inc1 to see exactly what this does, but is it safe to assume it's roughly equivalent to (but safer than) "make -DNO_CLEAN -DNOCLEAN buildkernel"?


----------



## Pegasus711 (Apr 13, 2010)

Hello everyone,

now That is some really nice info. Now that I have compiled the kernel I would definitely use the KERNFAST option to avoid waiting for those few mins 

thanks everyone!


----------

