From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.int.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 From: gosha Organization: elins To: devel-kernel@lists.altlinux.org Date: Wed, 15 Oct 2008 08:39:22 +0400 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200810150839.22431.gosha@elins.ru> Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Subject: [d-kernel] =?koi8-r?b?8NLP0MHEwcAuIPPCz9LLwSDRxNLBIDIuNC4zNiDJ?= =?koi8-r?b?09AgZ2NjIDQuMS4x?= X-BeenThere: devel-kernel@lists.altlinux.org X-Mailman-Version: 2.1.10b3 Precedence: list Reply-To: gosha@elins.ru, ALT Linux kernel packages development List-Id: ALT Linux kernel packages development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Oct 2008 04:26:22 -0000 Archived-At: List-Archive: List-Post: =E4=CF=C2=D2=D9=CA =C4=C5= =CE=D8. YK>=F7=D2=CF=C4=C5 =CB=C1=CB =D1=C4=D2=C1 2.4.=C8 =CD=CF=C7=D5=D4 =D3=CF=C2= =C9=D2=C1=D4=D8=D3=D1 =CD=C1=CB=D3=C9=CD=D5=CD gcc 2.96 =F0=C5=D2=C5=C8=CF=C4=C9=D4=D8 =CE=C1 2.96 =CF=DE=C5=CE=D8 =CE=C5 =C8=CF=D4= =C5=CC=CF=D3=D8 =C2=D9: =CE=C5=D5=C4=CF=C2=CE=CF, =D4.=CB. =CE=C1 =D4=C5=CB= =CD=CF=CD=C5=CE=D4 =CF=C4=C9=CE=20 =CB=D2=CF=D3=D3-=CB=CF=CD=D0=C9=CC=D1=D4=CF=D2 4.1.1 =C9=D3=D0=CF=CC=D8=DA= =D5=C5=D4=D3=D1 =C4=CC=D1 =CB=D2=C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2.4 =CE=C5=C9=DA=C2=C5=D6= =CE=C1, =D4.=CB. =CB=D2=CF=CD=C5 =D0=D2=CF=DE=C5=C7=CF =CD=D9 =C4=CF=CC=D6= =CE=D9 =D0=CF=C4=C4=C5=D2=D6=C9=D7=C1=D4=D8=20 =D0=CF=D2=D4 =ED=F3=F7=F3 =CE=C1 =D3=D7=CF=C5=CA =D0=D2=CF=C3=C5=D3=D3=CF= =D2=CB=C5. - =F7=D3=C5 =D2=C5=CC=C9=DA=D9 MCBC- , =D5=D7=D9, =D4=CF=CC=D8= =CB=CF =CE=C1 =D1=C4=D2=C1=C8=20 2.4 . =F3=D0=C1=D3=C9=C2=CF. =20 =2D-=20 =F3 =F5=D7=C1=D6=C5=CE=C9=CD, gosha. patch-2.4.36.7.bz2: diff --git a/Documentation/Changes b/Documentation/Changes index fce16f7..7331868 100644 =2D-- a/Documentation/Changes +++ b/Documentation/Changes @@ -91,7 +91,12 @@ The Red Hat gcc 2.96 compiler subtree can also be used t= o=20 build this tree. You should ensure you use gcc-2.96-74 or later. gcc-2.96-54 will not build the kernel correctly. =2Dgcc 4 is not supported. +gcc 3.3 and 3.4 are both known to work well. gcc 4.0 and 4.1 also work on +a several architectures (i386, x86_64, ppc, sparc, sparc64, alpha). Other +archs will not work. Versions 4.2 and onwards are not supported anymore. +Supporting them would require massive in-depth changes which will add a +lot of bugs and might break older compilers. If you don't have any gcc +below 4.2, check Documentation/using-newer-gcc.txt for instructions. In addition, please pay attention to compiler optimization. Anything greater than -O2 may not be wise. Similarly, if you choose to use gcc-2.9= 5.x diff --git a/Documentation/using-newer-gcc.txt=20 b/Documentation/using-newer-gcc.txt new file mode 100644 index 0000000..7834427 =2D-- /dev/null +++ b/Documentation/using-newer-gcc.txt @@ -0,0 +1,187 @@ +Building older versions of GCC compatible with Linux Kernel 2.4 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +This document explains how to build an older supported version of the GCC +compiler from a distribution which only offers incompatible recent version= s. + + +Context +=3D=3D=3D=3D=3D=3D=3D + +When Linux 2.4.0 was released in early 2001, GCC 2.95.2 was mainstream and +GCC 2.91.66 was still widely used. The GCC development model was evolving +and still confused. Since then, GCC has evolved a lot and stabilized. New +versions are regularly released, and some old features from the early code +get deprecated then removed. + +The kernel heavily relies on GCC's capabilities and behaviour. Some of the +code in Linux looks strange but is in fact intended to workaround early GCC +bugs. For these reasons, almost every new major GCC release breaks the ker= nel +build process. GCC 3.4 was a real pain to introduce as it required a lot of +rewriting in sensible areas, and GCC 4 required a lot of work, though this +work was less complicated thanks to the cleanup efforts invested in GCC 3.= 4. + +Starting with GCC 4.2, the output code randomly fails depending on section +ordering, which itself depends on the declaration order of functions, modu= le +parameters and many other things. The nasty part is that the code builds b= ut +randomly fails at runtime, so it is almost impossible to fix it and ensure +that everything works, especially in the drivers area where most of the +problems lie. + +As of 2008, GCC 4.3.2 is advertised as the current release and 4.2 the=20 previous +release. Most distributions have been shipping with 4.2 and 4.3 for some=20 time, +so building Linux 2.4 on a recent distribution has become a real problem f= or +users who still have to support kernel 2.4 on servers, firewalls or any ot= her +system. + + +Solution : the two-minutes process +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +If it is not possible to adapt the kernel to GCC, let's adapt GCC to the +kernel. We're lucky, building GCC to build just a kernel is not hard and +is rather fast. I call that a two-minutes process because building an +older GCC takes about 1 minute, and the kernel with that GCC also takes +one minute. + +First, you have to select which version of GCC you want to build your kern= el +with. Here are some comments on possible versions : + + - 2.95.3 : very well tested for the kernel, builds kernels very fast, + requires a lot of patches and is rather hard to build.. + + - 3.0 : very buggy, avoid it. + + - 3.1 & 3.2 : apparently less buggy but rarely used so bugs might have + remained unnoticed. + + - 3.3 : used and tested for a long time. A bit slow but easy to=20 build. + + - 3.4 : was recently introduced, received less testing, though see= ms + OK. Builds kernels faster than 3.3, and is easy to build t= oo. + + - 4.0 & 4.1 : received little testing, particularly slow but may produce + smaller kernels when compiled with -Os. + +Always take the last maintenance version of a compiler (eg: 3.4.6 for 3.4). + +For best reliability and less hassle, I tend to recommend GCC 3.3.6. For +improved build times (about 30% lower) and improved kernel performance, I'd +recommend 3.4.6. It tends to produce more efficient code on i386, but has +had a long history of causing annoyances with inline declarations. It seems +OK though, and I build all my kernels with it. We'll assume 3.4 is used for +the rest of this document, though what is described will work with 3.3 to +4.1 unless stated otherwise. + + +Instructions +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +1) Download gcc sources from the nearest mirror +----------------------------------------------- + +Find a mirror address here : [ http://gcc.gnu.org/mirrors.html ] or downlo= ad +from this directory : + + ftp://ftp.gnu.org/pub/gnu/gcc/gcc-3.4.6/ + +Get gcc-core-3.4.6.tar.bz2. It only contains the C compiler, which is what= =20 you +want. + +2) Prepare your build environment +--------------------------------- + +Create a temporary directory where you'll extract the sources. Don't build= on +NFS, it may be slow. Use /tmp if you want. You'll need about 150 MB of free +space. You'll have to extract the sources in that new directory, and creat= e a +temporary build directory aside it : + + $ mkdir /tmp/gcc-build + $ cd /tmp/gcc-build + $ tar jxf /tmp/gcc-core-3.4.6.tar.bz2 + $ mkdir build + +3) Configure gcc +---------------- + +You don't want your new gcc to conflict with the one already in place. I +recommend simply prefixing it with "kernel-", and not installing it in +/usr/bin, but rather /opt/kgcc/bin or anywhere else (/usr/local/bin will be +used by default). I recommend choosing a place you already have in your PA= TH +(such as the default /usr/local/bin), so that you don't have to pass the f= ull +path to the binary when building. + + $ cd /tmp/gcc-build/build + $ ../gcc-3.4.6/configure --disable-locale --disable-shared --disable-nl= s \ + --enable-languages=3Dc \ + --prefix=3D/opt/kgcc --program-prefix=3Dkernel- + +If you're using GCC 3.3, you may see strange messages indicating that some +programs were not found (eg: kernel-objdump). Simply ignore them. + +Note that you can set a lot of options, even use it as a cross-compiler.=20 While +very frequent, such a build will not be covered by this document. + +4) Build GCC +------------ + +Both GCC 3.3 and 3.4 support parallel building, which reduces build time o= n=20 SMP +systems : + + $ make -j 4 + +If the build fails here because of some options you added above, you'll ha= ve=20 to +remove the build dir and recreate it. + +5) Install your new GCC +----------------------- + +The binaries may be a bit big, but you can strip them. Both GCC 3.3 and 3.4 +support a trick on the command line during the installation process, which +consists in passing the "-s" flag to "install" : + + $ sudo make install INSTALL_PROGRAM=3D'${INSTALL} -s' + +It will be installed under the directory referred to by the "prefix" option +above, or /usr/local/bin if none was specified : + + $ ls -l /opt/kgcc/bin/kernel-gcc + -rwxr-xr-x 3 root root 73124 Sep 6 22:45 /opt/kgcc/bin/kernel-gcc + + $ /opt/kgcc/bin/kernel-gcc -v + Reading specs from /tmp/gcc-3.4.6-build/tmp-inst/opt/kgcc/bin/... + Configured with: ../gcc-3.4.6/configure --disable-shared --disable-... + Thread model: posix + gcc version 3.4.6 + +6) Using your new compiler +-------------------------- + +The compiler just has to be passed to "make" via the "CC" variable for all +commands : + + $ make CC=3D/opt/kgcc/bin/kernel-gcc -j 4 dep bzImage modules modules_in= stall + + or more simply, when you have it in your path : + + $ make CC=3Dkernel-gcc -j 4 dep bzImage modules modules_install + + +Conclusion +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Building an older GCC on to build an older kernel on a newer machine is not +really hard. It becomes harder when you have to cross-build (eg: you're +building on a 64-bit machine for a 32-bit one). But for this, I would=20 recommend +that you check the excellent "crosstool" utility from Dan Kegel. It suppor= ts=20 a +wide variety of compilers, contains a lot of fixes and will do all the hard +patching and configuration work for any combination you want or need. + + +Suggestions and comments +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +If you find mistakes or want to send comments about this document, please= =20 mail +me at . +