Skip to contentSkip to conversation

native gcc for mipsel / uClibc (building or binaries)?

DISCUSSION Tomasz Chmielewski 4 participants 8 messages Feb 12, 2006 – Feb 13, 2006 MIPS

lore
Share & tools
lore
#0 lore raw

I'm trying to cross-compile gcc to work on mipsel / uClibc, to run there natively (that is, I want to compile on this mipsel / uClibc machine).

So far I have a cross compiler that builds binaries for mipsel/uClibc on a x86 machine.

According to crosstool HOWTO, "to do a Canadian Cross build with crosstool, you have to run it three times:

1. once to build a toolchain that runs on the build system and
generates code for the host system
2. once to build a toolchain that runs on the build system and
generates code for the target system
3. once to build a toolchain that runs on the host system and
generates code for the target system".

So I guess the first step is behind me, but I'm not sure how to do steps 2 and 3.

Anyone knows how to do it?
Or perhaps, there are already gcc binaries available for mipsel / uClibc?

Signature · 3 lines
Tomasz Chmielewski
Software deployment with Samba
http://wpkg.org
#1 lore raw

Canadian cross is when you build toolchain on system X to run on system Y, and generate code for system Z.
Are you sure it is what you want? I somehow suspect that you want to generate toolchain to build things
natively on your mipsel box to run on said box. If that is true, buildroot (http://buildroot.uclibc.org) will do everything for you. Also, I think crosstool does it by default as well (not 100% sure though). Look under your destination dir
for <target>/bin/gcc.

Quoted 24 lines · Tomasz Chmielewski

I'm trying to cross-compile gcc to work on mipsel / uClibc, to run there natively (that is, I want to compile on this mipsel / uClibc machine).

So far I have a cross compiler that builds binaries for mipsel/uClibc on a x86 machine.

According to crosstool HOWTO, "to do a Canadian Cross build with crosstool, you have to run it three times:

1. once to build a toolchain that runs on the build system and
generates code for the host system
2. once to build a toolchain that runs on the build system and
generates code for the target system
3. once to build a toolchain that runs on the host system and
generates code for the target system".

So I guess the first step is behind me, but I'm not sure how to do steps 2 and 3.

Anyone knows how to do it?
Or perhaps, there are already gcc binaries available for mipsel / uClibc?

Signature · 3 lines
Ilya A. Volynets-Evenbakh
Total Knowledge. CTO
http://www.total-knowledge.com
#2 lore raw
Quoted 2 lines · Ilya A. Volynets-Evenbakh

Canadian cross is when you build toolchain on system X to run on system Y, and generate code for system Z.

all right, so I misunderstood, I need to build gcc on system X to run on system Y.

Quoted 4 lines

Are you sure it is what you want? I somehow suspect that you want to generate toolchain to build things
natively on your mipsel box to run on said box. If that is true, buildroot (http://buildroot.uclibc.org) will do everything

Buildroot also builds gcc which works on let's say x86 and makes binaries for mipsel/uclibc).

I need the gcc binaries which will work on mipsel, and which will build for mipsel.

Quoted 3 lines

for you. Also, I think crosstool does it by default as well (not 100% sure though). Look under your destination dir
for <target>/bin/gcc.

Crosstool by default builds the binaries on system X that will run on system X and build for Y.

So now I have binaries that build for mipsel/uclibc on x86, but I can't build gcc that will work on mipsel/uclibc with it.

Signature · 3 lines
Tomasz Chmielewski
Software deployment with Samba
http://wpkg.org
#3 lore raw
Quoted 8 lines · Tomasz Chmielewski
Quoted 4 lines · Ilya A. Volynets-Evenbakh

Are you sure it is what you want? I somehow suspect that you want to generate toolchain to build things
natively on your mipsel box to run on said box. If that is true, buildroot (http://buildroot.uclibc.org) will do everything

Quoted 5 lines

Buildroot also builds gcc which works on let's say x86 and makes binaries for mipsel/uclibc).

I need the gcc binaries which will work on mipsel, and which will build for mipsel.

Buildroot builds _both_. At least it has support for building both.

Quoted 7 lines
Quoted 5 lines

for you. Also, I think crosstool does it by default as well (not 100% sure though). Look under your destination dir
for <target>/bin/gcc.

Quoted 5 lines

Crosstool by default builds the binaries on system X that will run on system X and build for Y.

So now I have binaries that build for mipsel/uclibc on x86, but I can't build gcc that will work on mipsel/uclibc with it.

Let's say you build with instdir /crosstool
Then look for mipsel toolchain binaries in /crosstool/gcc-x.y.z-glibc-K.L.M/mipsel-linux-gnu/mipsel-linux-gnu/bin

Signature · 3 lines
Ilya A. Volynets-Evenbakh
Total Knowledge. CTO
http://www.total-knowledge.com
#4 lore raw
Quoted 9 lines · Ilya A. Volynets-Evenbakh
Quoted 7 lines · Tomasz Chmielewski
Quoted 4 lines · Ilya A. Volynets-Evenbakh

Are you sure it is what you want? I somehow suspect that you want to generate toolchain to build things
natively on your mipsel box to run on said box. If that is true, buildroot (http://buildroot.uclibc.org) will do everything

Quoted 7 lines
Quoted 5 lines

Buildroot also builds gcc which works on let's say x86 and makes binaries for mipsel/uclibc).

I need the gcc binaries which will work on mipsel, and which will build for mipsel.

Buildroot builds _both_. At least it has support for building both.

OK, than I didn't look close enough.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

for you. Also, I think crosstool does it by default as well (not 100% sure though). Look under your destination dir
for <target>/bin/gcc.

Crosstool by default builds the binaries on system X that will run on system X and build for Y.

Quoted 6 lines
Quoted 2 lines

So now I have binaries that build for mipsel/uclibc on x86, but I can't build gcc that will work on mipsel/uclibc with it.

Let's say you build with instdir /crosstool
Then look for mipsel toolchain binaries in /crosstool/gcc-x.y.z-glibc-K.L.M/mipsel-linux-gnu/mipsel-linux-gnu/bin

It's all x86 cross compilers (they will build for mipsel, on x86):

# pwd
/opt/crosstool/mipsel-unknown-linux-uclibc/gcc-3.3.3-uClibc-0.9.23/mipsel-unknown-linux-uclibc/bin
# file gcc
gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
# pwd
/opt/crosstool/mipsel-unknown-linux-uclibc/gcc-3.3.3-uClibc-0.9.23/bin
# file mipsel-unknown-linux-uclibc-gcc
mipsel-unknown-linux-uclibc-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped

So I guess I need to spend some more time on it, if I don't figure out, I'll keep on asking :)

Signature · 3 lines
Tomasz Chmielewski
Software deployment with Samba
http://wpkg.org
#5 lore raw
In reply to Tomasz Chmielewski
Quoted 14 lines · Tomasz Chmielewski

I'm trying to cross-compile gcc to work on mipsel / uClibc, to run there natively (that is, I want to compile on this mipsel / uClibc machine).

So far I have a cross compiler that builds binaries for mipsel/uClibc on a x86 machine.

According to crosstool HOWTO, "to do a Canadian Cross build with crosstool, you have to run it three times:

1. once to build a toolchain that runs on the build system and
generates code for the host system
2. once to build a toolchain that runs on the build system and
generates code for the target system
3. once to build a toolchain that runs on the host system and
generates code for the target system".

Quoted 5 lines

So I guess the first step is behind me, but I'm not sure how to do steps 2 and 3.

Anyone knows how to do it?
Or perhaps, there are already gcc binaries available for mipsel / uClibc?

I have done it for mipsel-linux-glibc, however until last week gcc had no support for uClibc, so it will probably not work with uClibc without some patching to gcc.

The basic idea is that once you have a working cross toolchain just configure gcc and binutils with: --build=i686-pc-linux-glibc --target=mipsel-linux --host=mipsel-linux. This will produce a native toolchain. You will have to copy the compile time portions of the C library (include files and link time libraries) to the target, then you should be all set.

David Daney.

#6 lore raw
Quoted 5 lines · David Daney

I have done it for mipsel-linux-glibc, however until last week gcc had no support for uClibc, so it will probably not work with uClibc without some patching to gcc.

The basic idea is that once you have a working cross toolchain just configure gcc and binutils with: --build=i686-pc-linux-glibc --target=mipsel-linux --host=mipsel-linux. This will produce a native
toolchain. You will have to copy the compile time portions of the C library (include files and link time libraries) to the target, then you should be all set.

Exactly that's my problem.

I have a compiler that generates binaries for mipsel/uclibc.

I compiled lots of software with it, so we can say it's functional.

Now, when I try to compile gcc (--build=i686-pc-linux-glibc

Quoted 1 line

--target=mipsel-linux --host=mipsel-linux), it breaks, as during the build process gcc's ./configure has a schizophrenia: it tries to compile some parts for mipsel (as I'd expect), but it also tries to compile and execute the binaries during the build process.

This means, it creates some binaries/libs needed for the build process (like libiberty), then tries to run/use them, but as they are mipsel binaries, the build process breaks.

I tried that with gcc-4.0.2, and some earlier 3.3.6 and 3.4.5, without a success.

Signature · 3 lines
Tomasz Chmielewski
Software deployment with Samba
http://wpkg.org
#7 lore raw
Quoted 5 lines · Tomasz Chmielewski

Now, when I try to compile gcc (--build=i686-pc-linux-glibc

Quoted 1 line

--target=mipsel-linux --host=mipsel-linux), it breaks, as during the

build process gcc's ./configure has a schizophrenia: it tries to compile some parts for mipsel (as I'd expect), but it also tries to compile and execute the binaries during the build process.

Just to rule out one possibility, were the x86-hosted tools in your path when you ran configure and make? They need to be.

Quoted 3 lines

This means, it creates some binaries/libs needed for the build process (like libiberty), then tries to run/use them, but as they are mipsel binaries, the build process breaks.

Recent versions compile two versions of libiberty, one for the build machine and one for the host. The build version is used for things like genattrtab (a build-time tool used only to build gcc itself) while the host version is linked into the final compilers.

Richard