No rule to make target ‘include/config/hz.h’, needed by ‘kernel/time/hz.bc’. Stop.

by moorray

I’ve been doing some work on Raspberry Pi recently and I came across following build error:

make[3]: *** No rule to make target 'include/config/hz.h', needed by 'kernel/time/hz.bc'. Stop.

It appeared when I switched from building in-source to building with an O=some_dir option which writes object files somewhere else than the code to keep the source tree clean (and make GIT work faster).

The problem was discussed on LKML but solution was not provided. It is actually caused by improper cross-compilation. When KBuild detected that the tree is not clean I automatically typed make mrproper missing all the cross compilation variables. As a result the arch/x86 directory was cleaned instead of arch/arm. To fix this error do mrproper with all the variables set, for me it was:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper
and then delete and recreate the build dir (the O=dir).