Recently I tryed to crosscompile android kernel for my xiaomi mi4c. To do this I have downloaded and configured toolchain like this:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 -b marshmallow-release toolchain64
export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE=`pwd`/toolchain64/bin/aarch64-linux-android-
then I cloned kernel source from here: https://github.com/AndropaX/android_kernel_xiaomi_msm8992
and do this:
make clean && make mrproper
make ARCH=arm64 resurrection_libra_defconfig
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE -j3
Then I have an error:
In file included from include/linux/kernel.h:14:0,
from include/linux/sched.h:15,
from /home/owner/android_kernel_xiaomi_msm8992/arch/arm64/include/asm/compat.h:25,
from /home/owner/android_kernel_xiaomi_msm8992/arch/arm64/include/asm/stat.h:23,
from include/linux/stat.h:5,
from include/linux/module.h:10,
from drivers/tspdrv/tspdrv.c:26:
drivers/tspdrv/ImmVibeSPI_ISA1000.c: In function 'ImmVibeSPI_ForceOut_SetSamples':
include/linux/dynamic_debug.h:64:16: error: implicit declaration of function 'KBUILD_STR' [-Werror=implicit-function-declaration]
static struct _ddebug __aligned(8) \
^
include/linux/dynamic_debug.h:76:2: note: in expansion of macro 'DEFINE_DYNAMIC_DEBUG_METADATA'
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
^
include/linux/printk.h:240:2: note: in expansion of macro 'dynamic_pr_debug'
dynamic_pr_debug(fmt, ##__VA_ARGS__)
^
drivers/tspdrv/ImmVibeSPI_ISA1000.c:573:2: note: in expansion of macro 'pr_debug'
pr_debug("%s: level = %d\n", __func__, level);
^
<command-line>:0:27: error: 'tspdrv' undeclared (first use in this function)
include/linux/dynamic_debug.h:66:14: note: in expansion of macro 'KBUILD_MODNAME'
.modname = KBUILD_MODNAME, \
^
include/linux/dynamic_debug.h:76:2: note: in expansion of macro 'DEFINE_DYNAMIC_DEBUG_METADATA'
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
^
include/linux/printk.h:240:2: note: in expansion of macro 'dynamic_pr_debug'
dynamic_pr_debug(fmt, ##__VA_ARGS__)
^
drivers/tspdrv/ImmVibeSPI_ISA1000.c:573:2: note: in expansion of macro 'pr_debug'
pr_debug("%s: level = %d\n", __func__, level);
^
<command-line>:0:27: note: each undeclared identifier is reported only once for each function it appears in
include/linux/dynamic_debug.h:66:14: note: in expansion of macro 'KBUILD_MODNAME'
.modname = KBUILD_MODNAME, \
^
include/linux/dynamic_debug.h:76:2: note: in expansion of macro 'DEFINE_DYNAMIC_DEBUG_METADATA'
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
^
include/linux/printk.h:240:2: note: in expansion of macro 'dynamic_pr_debug'
dynamic_pr_debug(fmt, ##__VA_ARGS__)
^
drivers/tspdrv/ImmVibeSPI_ISA1000.c:573:2: note: in expansion of macro 'pr_debug'
pr_debug("%s: level = %d\n", __func__, level);
^
drivers/tspdrv/tspdrv.c: At top level:
drivers/tspdrv/tspdrv.c:94:37: fatal error: tspdrvOutputDataHandler.c: No such file or directory
#include <tspdrvOutputDataHandler.c>
^
cc1: some warnings being treated as errors
compilation terminated.
So, the question is, what am I doing wrong? Maybe I need another toolchain for crosscompilation? Can sombody suggest one? I dont think there is an error in the kernel code. So what can go wrong?
So, after a few days I found the answer. Thanks to kay2777 from 4pda.
Look for KBUILD_CFLAGS in the main Makefile, and add the following to suppress warnings as errors: