Reputation: 501
I build embedded machines that run an RT_PREMPT version of Linux. It's an Ubuntu 10.04 installation running an Linux 2.6 kernel. Yes, it's an old kernel, but I'm stuck with it for awhile.
When I compiled the kernel, I used gcc version 4.4. On this system, there is a kernel module I have been compiling successfully for three years.
From my Makefile...
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) \
modules
My current project requires support for c++14, so I updated gcc and g++ to version 5.1.0 by building from source. All my user-mode software compiles, but when I went to build an updated version of my kernel module, I get the following error right away:
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-54-generic'
CC [M] /home/tbj/srcroot/ctsengine-hg/CtsRt/ctsrt_main.o
In file included from include/linux/compiler.h:40:0,
from include/linux/stddef.h:4,
from include/linux/list.h:4,
from include/linux/module.h:9,
from /home/tbj/srcroot/ctsengine-hg/CtsRt/ctsrt_main.c:31:
include/linux/compiler-gcc.h:86:30: fatal error: linux/compiler-gcc5.h: No such file or directory
In short:
fatal error: linux/compiler-gcc5.h: No such file or directory
If I use gcc 4.4 again (I left it installed on my computer in a different directory), it compiles and runs perfectly.
Obviously, I'm missing something. Is it not possible to compile a kernel module with a newer version of the compiler than what the operating system was compiled with? That seems unlikely to me. Is there a configuration step I'm missing? Is there a system variable I need to update? Are there extra headers I'm supposed to download? I ran apt to update build-essential, but it was up to date. I have the source and headers for the kernel on my system. I'm not sure what else I would download.
Any insights to this problem are greatly appreciated. Thank you in advance.
Upvotes: 21
Views: 24563
Reputation: 2064
Open a terminal and type:
$ ls -r /usr/src/linux-headers-$(uname -r)/include/linux/ | \
grep -P "compiler-gcc\d.h" | \
head -n 1
this will hopefully output the latest gcc header suitable for your linux kernel.
In my case it is compiler-gcc4.h
. Now you can link this file to compiler-gcc5.h
in the following way:
$ sudo ln -s /usr/src/linux-headers-$(uname -r)/include/linux/compiler-gcc4.h \
/usr/src/linux-headers-$(uname -r)/include/linux/compiler-gcc5.h
Upvotes: 0
Reputation: 4661
Your kernel version is too old and it is missing linux/compiler-gcc5.h
.
The header is included from linux/compiler-gcc.h and its name is generated by preprocessor macro based on current compiler version:
#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
This header was introduced around version 3.18
.
You might try to get this file from a newer kernel source and put in into include/linux
.
Upvotes: 20