Compile modern Linux kernel on RHEL4

Kernel version: 2.6.35.11, used for server.

Although Documentation/Changes wants gcc 3.2, it can’t compile on gcc 3.4 comes with RHEL/CentOS 4. Most programs seem to compile with a little warning, but several drivers need later compiler features.

Fortunately, RHEL/CentOS 4 provides gcc4 (4.1.2) in later updates. The kernel compiles perfectly with it. But I found it’s a little tricky to tell the building system (KBuild?) to use gcc4 instead of gcc: there’re no stuff like configure, and Makefile doesn’t accept CC environment variables. And I can’t find any documents with Google… Finally I found modifying top level Makefile works: just set HOSTCC to gcc4, and CC to $(CROSS_COMPILE)/gcc4. I’m not sure the difference between HOSTCC and CC. It seems like HOSTCC is for programs for “make menuconfig”, while CC is for the actual kernel code.

I can’t use “make -j” with the default make version comes with RHEL4 (3.80). After upgrading to 3.81, it works just fine.



留下评论