Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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 )
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.