This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mips-elf target


Niklaus kirjoitti:
Hi,
Until now i have only build cross toolchains for linux systems.
I guess "for totally self-built Linux-from-scratch" systems, not cross toolchains for usual Linuces like
RedHats, SuSEs, Fedoras, Ubuntus etc.
Usually i build crossgcc in 2 parts, one is before glibc is built ,
the other is after glibc is built.
For usual Linuces the glibc is already built and included with the Linux distro. Just as are all those
X11, Gnome, KDE etc. libraries. So these are normally NOT built, only copied from the target
system or from its install stuff (RPM-packages for glibc etc.). And the GCC build happens in
only one stage after building the target binutils.
 Is there any way where i can skip the step glibc and build the whole
gcc compiler.

As told, this is the expected way to build a crosscompiler for Linux - to build it in only one stage!

If yes how do i build the whole gcc without glibc. I have binutils for
the target already installed.
I only need c and c++ languages. I doing it for vr4131 (mips-elf) target.
The mips-elf target uses (usually) newlib as its target C library. And there is that '--with-newlib'
option which should enable anyone to build a GCC (no 'native' choice! so it is vain to add the
'cross-' for telling it is not a native-GCC) without the (complete) target C library being available
during the GCC build. The 'libiberty' and 'libstdc++-v3' configure scripts SHOULD NOT use
any link tests for solving the target C library properties, the '--with-newlib' tells what the C
library is and what it has. In this issue the new gcc-4.x releases seem to have restored the old
bug : doing link tests with the target C library during the libstdc++-v3 configure !


So with gcc-3.4.x and older sources using '--with-newlib' should enable you to build the complete
GCC with libiberty and libstdc++-v3 when having only the generic newlib headers preinstalled
before the GCC build. The place, for instance 'newlib-1.13.0/newlib/libc/include', is well-known
and copying this into the final '$prefix/$target/include' (the newlib install puts the final headers with
possible additions/fixes for the target there) should be enough. But this "should" is optimism, there
has been that "sys-include-bug" mess over 10 years without no-one of the GCC developers ever
caring to fix it ! And the libiberty configure stuff has claimed that the functions 'asprintf()', 'strdup()'
and 'vasprintf()' are missing from newlib although these appeared into it years ago!


So one must take care that the target headers can be seen also in the '$prefix/$target/sys-include'
during the GCC build! And take care that they cannot be seen there AFTER the build, IF copying
them there, using symlink is not dangerous, when using the compiler, the stuff in the 'sys-include'
will be searched before the 'include'. The 'sys-include' is the equivalent to the SYSTEM_INCLUDE_DIR
in a native GCC and the 'include' is the equivalent to the STANDARD_INCLUDE_DIR, or usually
the '/usr/include' in a native GCC. Somehow the GCC developers have mixed apples and oranges
and still think the '$prefix/$target/sys-include' being the equivalent to the '/usr/include'....


If you don't require the target C library at all, and not use C++, then just don't build newlib at all!
And it can be fully possible that you don't need even the newlib headers for producing the 'libgcc.a' !
But producing it shouldn't hurt... So your steps would be :


1. copy the generic newlib headers into the '$prefix/mips-elf/include'. Then symlink this to be seen
also as the '$prefix/mips-elf/sys-include'.


2. configure the GCC sources using '--target=mips-elf --with-newlib --enable-languages=c,c++'

3. build the GCC, also the libiberty and libstdc++-v3 subdirs should succeed. The protos in the
newlib headers can clash with the reimplementations in libiberty. If so, your homework is to
search for the 'newlib' in the 'libiberty/configure*' and fix them by editing the mentioned three
functions from the lists where they are claimed to be missing from newlib.... Install GCC.


4. configure and build newlib using the same '--prefix=$prefix' and '--target=mips-elf' as you used
already with binutils and GCC. Then install newlib.


5. try compiling and linking your "Hello World"... This is the hardest step because only the true
Legolas, Tinuviel etc. fans believe all elves being real creatures. The 'mips-elf' is not a real
target like 'mips-linux-gnu' and therefore requires some special linker script being used to
describe the 'real target' (a MIPS based board with monitor firmware or something). Newlib
comes with linker scripts for IDT, PMON-based (a free monitor) etc. MIPS boards. Some
homework expected before the "Hello World" succeeds...



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]