On Fri, Jul 07, 2000 at 04:48:35PM +0100, David Rusling wrote:
> All,
> 
>     I've been 'playing' with cross-tools.   Using the various helpful help
> files (Phil Blundell and Chris Rutter) I can now build binutils-2.9.5
> and gcc-2.95.1 every which way.   However, I cannot build glibc-2.1
> or newlib-1.8.2.
> 
>     Configuring newlib fail's 'cos it cannot compile/link a test image.
> (I'm assuming arm-linux as the build variant).   It fails with unsupported
> emulations.  I'm guessing that the kernel builds 'cos it uses steering files
> for this stuff.
> 
>     Following Chris's instructions, glibc-2.1 fails because gcc 2.95.1
> is not the correct version.   I hacked the configure file but it fails
> as it builds it later on.
> 
>     So, help!        Dave
> 

Here's a notebook I wrote up as I went through the stuff you're doing.
It's obviously directed at me (plus other people at my site who want
to do this), but it has the advantage of being pretty recent.

Haven't built newlib for ARM, so I can't help there.  I built it for
M32R a while ago, but don't remember what was involved.

miket


Building binutils
-----------------

-- Grab safe binutils source.  The current Debian version, 2.9.5.0.31,
   is claimed to be buggy on one of the ARM mailing lists.  2.9.5.0.14
   is reported to be safe on Chris Rutter's ARM cross-compiler page,
   so I'm going to give that a try.  According to Phil Blundell's page
   and FTP site, the 2.9.5.* series binutils don't require ARM patches
   (unlike 2.9.1.*).

   Here's the official site for binutils:
   ftp://ftp.varesearch.com/pub/support/hjl/binutils/

   Actually, scratch the above version number stuff.  The site contains
   2.9.5.0.37, and I'm going to try that, because going back to a much older
   version looks like it will involve a heinous amount of reverse patching.
   If .37 doesn't work, I guess I'll try .14.

-- Also grab current Debian binutils source, so that I can figure out how to
   package the cross-compiler one I'm building.  Looks like the debian stuff
   is really complicated here (this source package produces four different
   .debs).  I guess it's time I read the Debian packaging manual...

These steps will install the ARM binutils under /usr/local/.  The binaries
will be named arm-linux-*.  Binutils is the easy part of cross-gcc
compilation.

1) Unpack tarball.
2) Make build dir 'binutils-build' parallel to source dir.
3) cd to build dir.
3) Run ../configure --help to see options.
4) Run ../configure --target=arm-linux
5) Typical make + make install.

Building GCC
------------

Following instructions on:
http://inkvine.fluff.org/~chris/arm-tools.html

GCC requires the kernel header files.  I'm going to try against a patched
2.4.0-test1-ac19.  Steps to getting this kernel in the right state for
building gcc:

1) Get 2.4.0-test1-ac19 source (from kernel.org).  Have to download
   2.4.0-test1 and apply the ac19 patch to it.  Get the .sign files
   and check the signatures, too!  This kernel can be found at
   ftp.us.kernel.org in:
        /pub/linux/kernel/v2.4/linux-2.4.0-test1.tar.gz
        /pub/linux/kernel/v2.4/linux-2.4.0-test1.tar.gz.sign
   and the -ac19 patch is in:
        /pub/linux/kerner/people/alan/2.4.0test/patch-2.4.0test1-ac19.bz2
        (and corresponding .sign).
   To unpack and apply the patch (somewhere in your home directory):
        $ tar zxvf linux-2.4.0-test1.tar.gz
        $ mv linux linux-2.4.0-test1
        $ cd linux-2.4.0-test1
        $ bzcat ../patch-2.4.0test1-ac19.bz2 | patch -p1 -s -E

2) Get latest RMK (Russell M. King, linux-arm maintainer) patch from 
   ftp://ftp.arm.linux.org.uk/pub/armlinux/source/kernel-patches/v2.4/
   (it's against -ac19, that's why I chose that kernel version) and once
   again patch the kernel:
        $ zcat ../patch-2.4.0-test1-ac19-rmk1.gz | patch -p1 -s -E

3) In the top-level kernel Makefile, replace the line:
        ARCH := $(shell uname ... bunch of stuff ...)
   with
        ARCH := arm

4) Configure the kernel with 'make menuconfig'.  Save the default
   configuration.  I'm hoping this works OK, as we don't need to really
   build the kernel, we just need to get its headers into a state
   acceptable for building GCC.  The closest thing in the Makefiles to
   the 7211 is probably the 7500 (although ARM710A, not 710TDMI), but
   that port is not fully merged and the option is commented out.

5) Run 'make dep' to build the dependency tree.

6) Create links in the arm-linux target include directory:
        $ cd /usr/local/arm-linux
        $ mkdir include; cd include
        $ ln -s your-linux-kernel-directory/include/asm-arm asm
        $ ln -s your-linux-kernel-directory/include/linux linux

7) Download gcc 2.95.2, plus Phil Blundell's add-on patch at:
        ftp://ftp.netwinder.org/users/p/philb/gcc-2.95.2-diff-991022.gz
   and the fold-const.c patch from Chris Rutter's page
        http://inkvine.fluff.org/~chris/arm-tools.html
   Read Chris's page top to bottom, as it has a bunch of information on
   what should be done next.

8) Commentary on Chris Rutter's page
   -- Phil Blundell's 2.95.2 gcc patch doesn't apply cleanly, but I looked
      at the patch, and the changes look reasonable (right direction,
      likely bug fixes, etc).  The top-level stuff (ChangeLog, configure,
      configure.in) will get rejected; the other stuff patches cleanly,
      although I had to supply a path to each file.
   -- The fold-const.c patch looks like it's still needed (it hasn't been
      applied in 2.95.2).
   -- The instructions about changing #if 0 to #if 1 in
      gcc/config/arm/linux-elf.h look to be obsolete; there is no #if 0
      in that file.
   -- I used the -Dinhibit_libc hack described in the page.

9) Configure and build, after the necessary patching.
   Command lines (from directory _above_ gcc-2.95.2):
        $ mkdir gcc-build
        $ cd gcc-build
        $ ../gcc-2.95.2/configure --target=arm-linux --disable-threads
        $ make LANGUAGES="c" cross
   My build failed with an error message in libio, but I looked at the
   binaries and found quite a lot of gcc stuff, so I did an impatient
   'make install' without debugging the problem (looks to be lack of a
   target libc) and was able to compile a standalone boot loader with
   no libc dependencies.

Glibc
-----

1) Download glibc-2.1.3 and the crypt and linuxthreads add-ons.

        $ mkdir glibc-build
        $ cd glibc-build
        $ export CC=arm-linux-gcc
        $ ../glibc-2.1.3/configure arm-linux --build=i586-linux \
                --prefix=/usr/local/arm-linux/ --enable-add-ons
        $ make
        $ make install

Gcc Revisited
-------------

You can now go back and compile the full-on gcc.  First, remove the
-Dinhibit_libc hack from the sources.  Delete your previous build
directory, and:

        $ mkdir gcc-build
        $ cd gcc-build
        $ ../gcc-2.95.2/configure --target=arm-linux
        $ make
        $ make install

Don't forget to unset CC if you set it above.

Stripping Binaries
------------------

You now have an unholy amount of stuff in /usr/local.  I went through
and stripped some shared libraries.  Make sure you use 'strip' for Intel
tools and 'arm-linux-strip' for ARM binaries.  Hopefully, I'll automate
this process soon; if you don't know what you're doing, I recommend
against this step.


unsubscribe: body of `unsubscribe linux-arm' to [EMAIL PROTECTED]
++        Please use [EMAIL PROTECTED] for           ++
++                        kernel-related discussions.                      ++

Reply via email to