Just following this up in case anyone else is interested: @NiLuJe's toolchain is suitable for compiling Linux kernel modules, but you need to make a small tweak to the Linux sources first (at least for 3.0.35).
When compiling a module for the first time, I encountered this error:
Code:
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
In file included from include/linux/compiler.h:48:0,
from include/linux/stddef.h:4,
from include/linux/posix_types.h:4,
from include/linux/types.h:17,
from include/linux/page-flags.h:8,
from kernel/bounds.c:9:
include/linux/compiler-gcc.h:94:1: fatal error: linux/compiler-gcc7.h: No such file or directory
#include gcc_header(__GNUC__)
^~~~
compilation terminated.
/home/ubuntu/linux3/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:990: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
This is simple to fix - all you need to do is create a hard link to the file that the compiler is expecting to find:
Code:
ln include/linux/compiler-gcc4.h include/linux/compiler-gcc7.h
Once this is done, you should be good to go.