linux-mips
[Top] [All Lists]

Solving the cross-compiler issue (Was: Trouble compiling MIPS cross-comp

To: Kumba <kumba@gentoo.org>
Subject: Solving the cross-compiler issue (Was: Trouble compiling MIPS cross-compiler)
From: Nathan Field <ndf@ghs.com>
Date: Wed, 21 Jan 2004 18:32:23 -0800 (PST)
Cc: linux-mips@linux-mips.org
In-reply-to: <400A1B5F.6010307@gentoo.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
This email is a bit long so here's the short version:
        Building cross tools is basically impossible without knowledge 
which isn't available on the www.linux-mips.org web site
        glibc seems to have obvious syntax errors and won't even compile
        The prebuilt tools referenced in the FAQ are so out of date 
they're useless
        Even tools provided by various commercial Linux vendors are out of 
date (at least what MontaVista lets us see in their preview kits)
        This could all be solved if someone wrote a script to do all the 
work which contains all the logic necessary to get a known set of tools to 
build

I've written a script which will do all the work, but because there are 
failures in building glibc it doesn't work. If someone could help me get 
my script to work it could be used to update the cross compile section of 
the FAQ. The script as it stands is attached. It needs some configuration 
(which is why it exits by default), but if you're trying to build a cross 
compiler you'd better have at least some knowledge of what you're doing.

Here's what it does:
        it wgets specific versions of binutils, gcc and glibc
        it sets some environment variables
        it uncompresses and builds the tools in the "correct" sequence 
with the correct options

There are 2 problems with this script:
        1. It references a specific binutils snapshot which will probably 
go away in a few days
        2. It doesn't f'ing work

That said, here's where things are breaking:

I'm also trying to build a newer cross toolchain since MontaVista doesn't
seem to provide one recent enough to even build the linux_2_4 branch from
the linux-mips cvs repository (it builds, but when I run it on my Malta
board it crashes immediately). I'm coming up against problems that just
seem stupidly obvious... Enough ranting though, here are the details.

Kumba suggested using:
> I'd recommend the following:
> binutils-2.14.90.0.7 (or you can try the latest .8 release, it has some 
> more mips fixes in it)
> glibc-2.3.2 (or 2.3.1)
> gcc-3.3.2
        I couldn't find a version of binutils like that, so I grabbed 
yesterdays snapshot, which builds and runs fine. Then I built the gcc 
bootstrap fine. Then I tried building glibc-2.3.2. That failed when it got 
to stdio-common/sscanf. The declaration of sscanf:

sscanf (s, format)
     const char *s;
     const char *format;

Doesn't match the function, and it should be:

sscanf (const char *s, const char *format, ...)

Does no one even bother to test to see if these things compile before they 
are released? I've had similar syntax error type problems when building 
several older (2.2.x) versions of glibc for PPC.

Anyway, after I fixed that I now get a link failure:

/space1/ndf/linux/mips/tools/glibc-build/elf/ld.so.1: undefined reference 
to `elf_machine_rela.7'

The command which generates this is:

mips-linux-gcc -nostdlib -nostartfiles -o 
/space1/ndf/linux/mips/tools/glibc-build/iconv/iconvconfig  
-Wl,-dynamic-linker=/space1/ndf/demos/malta_linux_reference/embedded/tools/lib/ld.so.1
    
/space1/ndf/linux/mips/tools/glibc-build/csu/crt1.o 
/space1/ndf/linux/mips/tools/glibc-build/csu/crti.o `mips-linux-gcc 
--print-file-name=crtbegin.o` 
/space1/ndf/linux/mips/tools/glibc-build/iconv/iconvconfig.o 
/space1/ndf/linux/mips/tools/glibc-build/iconv/strtab.o 
/space1/ndf/linux/mips/tools/glibc-build/iconv/xmalloc.o  
-Wl,-rpath-link=/space1/ndf/linux/mips/tools/glibc-build:/space1/ndf/linux/mips/tools/glibc-build/math:/space1/ndf/linux/mips/tools/glibc-build/elf:/space1/ndf/linux/mips/tools/glibc-build/dlfcn:/space1/ndf/linux/mips/tools/glibc-build/nss:/space1/ndf/linux/mips/tools/glibc-build/nis:/space1/ndf/linux/mips/tools/glibc-build/rt:/space1/ndf/linux/mips/tools/glibc-build/resolv:/space1/ndf/linux/mips/tools/glibc-build/crypt:/space1/ndf/linux/mips/tools/glibc-build/linuxthreads
 
/space1/ndf/linux/mips/tools/glibc-build/libc.so.6 
/space1/ndf/linux/mips/tools/glibc-build/libc_nonshared.a -lgcc 
`mips-linux-gcc --print-file-name=crtend.o` 
/space1/ndf/linux/mips/tools/glibc-build/csu/crtn.o
/space1/ndf/linux/mips/tools/glibc-build/elf/ld.so.1: undefined reference 
to `elf_machine_rela.7'

Interestingly when I try glibc 2.3.1 I get the same syntax error in sscanf 
but the linker complains about elf_machine_rela, without the .7.

It would be wonderful if I could get some help on this. It seems like a
chicken and egg problem which will only get worse as more and more people
try to build the 2.6 kernels.

        nathan

PS. This script is totally ripped off of Kumba's script which he submitted 
earlier. I've just added stuff to try to automate *everything*.

-- 
Nathan Field (ndf@ghs.com)                                All gone.

But the trouble with analogies is that analogies are like goldfish:
sometimes they have nothing to do with the topic at hand.
        -- Crispin (from a posting to the Bugtraq mailing list)

Attachment: build_tools.sh
Description: Bourne shell script

<Prev in Thread] Current Thread [Next in Thread>