LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-17-2007, 01:25 PM   #1
isalmbio
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Rep: Reputation: 0
compiling linux kernel 2.4 using gcc-4.1


I'm using gcc-4.1 on a debian host to compile the debian kernel 'kernel-source-2.4.27'. First 'make clean' and 'make menuconfig' went successfully. 'make dep' also had no problems. However, 'make bzImage' generated the following errors (please note that kernel 2.6 is compiled successfully with no errors using the same gcc-4.1 compiler) :

gcc -D__KERNEL__ -I/usr/src/kernel-source-2.4.27/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i586 -DKBUILD_BASENAME=main -c -o init/main.o init/main.c
In file included from /usr/src/kernel-source-2.4.27/include/linux/kernel.h:15,
from /usr/src/kernel-source-2.4.27/include/linux/wait.h:13,
from /usr/src/kernel-source-2.4.27/include/linux/fs.h:12,
from /usr/src/kernel-source-2.4.27/include/linux/capability.h:17,
from /usr/src/kernel-source-2.4.27/include/linux/binfmts.h:5,
from /usr/src/kernel-source-2.4.27/include/linux/sched.h:9,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/asm/byteorder.h:14: warning: type qualifiers ignored on function return type
/usr/src/kernel-source-2.4.27/include/asm/byteorder.h:30: warning: type qualifiers ignored on function return type
In file included from /usr/src/kernel-source-2.4.27/include/linux/byteorder/little_endian.h:11,
from /usr/src/kernel-source-2.4.27/include/asm/byteorder.h:65,
from /usr/src/kernel-source-2.4.27/include/linux/kernel.h:15,
from /usr/src/kernel-source-2.4.27/include/linux/wait.h:13,
from /usr/src/kernel-source-2.4.27/include/linux/fs.h:12,
from /usr/src/kernel-source-2.4.27/include/linux/capability.h:17,
from /usr/src/kernel-source-2.4.27/include/linux/binfmts.h:5,
from /usr/src/kernel-source-2.4.27/include/linux/sched.h:9,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/linux/byteorder/swab.h:160: warning: type qualifiers ignored on function return type
/usr/src/kernel-source-2.4.27/include/linux/byteorder/swab.h:173: warning: type qualifiers ignored on function return type
/usr/src/kernel-source-2.4.27/include/linux/byteorder/swab.h:186: warning: type qualifiers ignored on function return type
/usr/src/kernel-source-2.4.27/include/linux/byteorder/swab.h:200: warning: type qualifiers ignored on function return type
In file included from /usr/src/kernel-source-2.4.27/include/linux/prefetch.h:13,
from /usr/src/kernel-source-2.4.27/include/linux/list.h:6,
from /usr/src/kernel-source-2.4.27/include/linux/wait.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/fs.h:12,
from /usr/src/kernel-source-2.4.27/include/linux/capability.h:17,
from /usr/src/kernel-source-2.4.27/include/linux/binfmts.h:5,
from /usr/src/kernel-source-2.4.27/include/linux/sched.h:9,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/asm/processor.h:75: error: array type has incomplete element type
In file included from /usr/src/kernel-source-2.4.27/include/linux/fs.h:324,
from /usr/src/kernel-source-2.4.27/include/linux/capability.h:17,
from /usr/src/kernel-source-2.4.27/include/linux/binfmts.h:5,
from /usr/src/kernel-source-2.4.27/include/linux/sched.h:9,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/linux/ncp_fs_i.h:26: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp_fs_i.h:27: warning: ‘packed’ attribute ignored for field of type ‘__u8[6]’
In file included from /usr/src/kernel-source-2.4.27/include/linux/ncp_mount.h:12,
from /usr/src/kernel-source-2.4.27/include/linux/ncp_fs_sb.h:12,
from /usr/src/kernel-source-2.4.27/include/linux/fs.h:734,
from /usr/src/kernel-source-2.4.27/include/linux/capability.h:17,
from /usr/src/kernel-source-2.4.27/include/linux/binfmts.h:5,
from /usr/src/kernel-source-2.4.27/include/linux/sched.h:9,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:24: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:25: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:26: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:27: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:28: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:29: warning: ‘packed’ attribute ignored for field of type ‘__u8[]’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:37: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:38: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:39: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:40: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:41: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:42: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:43: warning: ‘packed’ attribute ignored for field of type ‘__u8[]’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:137: warning: ‘packed’ attribute ignored for field of type ‘__u8’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:138: warning: ‘packed’ attribute ignored for field of type ‘__u8[256]’
/usr/src/kernel-source-2.4.27/include/linux/ncp.h:174: warning: ‘packed’ attribute ignored for field of type ‘__u8’
In file included from /usr/src/kernel-source-2.4.27/include/asm/smp.h:17,
from /usr/src/kernel-source-2.4.27/include/linux/smp.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/sched.h:23,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/asm/mpspec.h:87: warning: ‘packed’ attribute ignored for field of type ‘unsigned char[6]’
In file included from /usr/src/kernel-source-2.4.27/include/linux/sched.h:23,
from /usr/src/kernel-source-2.4.27/include/linux/mm.h:4,
from /usr/src/kernel-source-2.4.27/include/linux/slab.h:14,
from /usr/src/kernel-source-2.4.27/include/linux/proc_fs.h:5,
from init/main.c:15:
/usr/src/kernel-source-2.4.27/include/linux/smp.h:29: error: conflicting types for ‘smp_send_reschedule’
/usr/src/kernel-source-2.4.27/include/asm/smp.h:42: error: previous declaration of ‘smp_send_reschedule’ was here
In file included from /usr/src/kernel-source-2.4.27/include/linux/unistd.h:9,
from init/main.c:17:
/usr/src/kernel-source-2.4.27/include/asm/unistd.h:375: warning: conflicting types for built-in function ‘_exit’
make[1]: *** [init/main.o] Error 1
make[1]: Leaving directory `/usr/src/kernel-source-2.4.27'
make: *** [debian/stamp-build-kernel] Error 2

 
Old 06-17-2007, 02:29 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

The 2.4 kernel is not compile-able with GCC 4

http://groups.google.com/group/fa.li...94a9eb36126478

Try a GCC 3 version instead. Depending on your distro, there may be a 'compat-gcc' package with a GCC 3.x compiler.

Dave
 
Old 06-18-2007, 10:56 AM   #3
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 774

Rep: Reputation: 243Reputation: 243Reputation: 243
I could never get this. I mean, is it or is it not (the Linux kernel) valid C source code? If it IS valid C source code, then GCC should compile it. If not, it can't be expected to compile something incorrect, but why is it incorrect? Does anyone else find this crazy?

I jumped from GCC-3.x and 2.4.x to 2.6 kernels and GCC-4.x. That's fine and dandy, but I've since gotten hold of a really stubborn machine that absolutely will not run a 2.6 kernel (God knows why) but will run a 2.4. So I've got megabytes and megabytes of developmental tools, can compile C, C++, Obj C, Obj C++, Ada, Java, and Fortran but behold, I can not compile a 2.4 Linux kernel!!!

(I'm looking for the smack-your-head-against-a-wall-type-silly smilies face, but there is none, so I'll use this guy: multiplied by )
 
Old 06-18-2007, 12:04 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
I believe it boils down to what the compiler will let you get away with. Previous versions of gcc would give a 'warning' where current versions will give an 'error' and bail out.

There are also differences between the ways that different gcc versions handle optimisation - you might be OK with the way gcc4 optimises a routine, but gcc3 may do something unintended. Programming on bare metal I'd imagine is particularly sensitive to this sort of thing.

And I'm also quite sure there are parts of the kernel source which violate numerous aspects of what might be considered 'standard' use of C.

Dave

P.S. I'm not a C programmer, so anyone feel free to shoot down what are essentially educated guessed on my part.
 
Old 06-18-2007, 01:29 PM   #5
hiren_bhatt
Member
 
Registered: Oct 2005
Distribution: FC3,Debian
Posts: 127

Rep: Reputation: 15
Quote:
Originally Posted by jayjwa
I could never get this. I mean, is it or is it not (the Linux kernel) valid C source code?
It is a valid source code but its not a ANSI standard. The primary reason why gcc and Linux kernel has a relation is because the kernel in not strictly programed in ANSI C, it also uses iso c99 and GNU C extensions. So the Linux kernel can only be compiled by a gcc compiler and not any other C compiles even if it is a standard ANSI compiler. Also between gcc3 and gcc4 there are many changes, you can see gcc change history if you are interested.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gcc version for compiling kernel 2.6.18 TemplaraPheonix Linux - Kernel 3 10-02-2006 06:20 PM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 11:38 AM
error compiling kernel 2.6.2 (GCC too old??) Dancingsalad Linux - Newbie 5 02-07-2004 04:05 PM
gcc 3.3.2 segfaults when compiling 2.4.23 kernel Azmeen Slackware 5 11-29-2003 07:53 PM
wich is the best gcc for compiling the linux kernel??? Claus Linux - Software 1 09-01-2003 09:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration