This is the mail archive of the gcc-help@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: Getting started with building a GCC cross-compiler


On Mon, Nov 24, 2008 at 05:54:58PM -0500, Dave Nadler wrote:
> I hoped (OK, wished) that "make" would create a ready-
> to-package cross-compiler including:
> - executables (OK so far)
> - set of libraries for the target (built by running the
>   newly-built cross-compiler)
> - the set of include files required for the selected
>   language targets
> I hoped that the includes/libraries would implement
> C and C++ as possible bare-metal. That is, minus file
> IO etc. or with harmless stubs to be replaced later
> as needed. The vendor has the bare metal adaption for
> malloc-level utilities in libgcc.
> 
> While I did get a complete set of executables from
> the make, I didn't get libgcc, libstdc++, nor did I get
> the include files. What am I missing here ?
> 
> I need to get the C++ libraries built (and then I'll
> see what work I must do to adapt to the bare-metal
> environment).
> 
> I'd be grateful for any pointers, directions to
> documentation I should study, etc...

Most likely your port vendor has modified the toplevel configure.ac and
configure files so that 'noconfigdirs' disables building libgcc and libstdc++.
I don't have any 3.x trees lying around, so this is from memory.

However, libstdc++ and libgcc won't build without the basic host files.

If you don't have a basic library, newlib is fairly easy to port (at least it
was years ago).  You need to add a few 'system calls' like basic I/O (or stub
them out).  Then you build newlib.  After you install newlib, you go back and
rebuild the compiler, enabling libgcc and libstdc++.

There are various recipies for building a cross compiler.  One that I've used
recently is:

1) Build binutils for your target, install it.
2) Build the compiler, using the binutils, install it (without libgcc,
libstdc++).
3) Using #1/#2, build newlib, install it.
4) Rebuild binutils with --with-sysroot=<xxx>.  Install it.
5) Enable libgcc builds.
6) Rebuild gcc using --with-sysroot=<xxx> --with-newlib.  Install it.
7) Assuming this all works at the C level, enable libstdc++.
8) Rebuild compiler, hopefully with libstc++.

Note, if the people that wrote the port never targeted C++, you will probably
have to go in an make sure that static constructors and destructors work with
your object format, etc.  Ditto for exceptions.  If your tools use the ELF
object format, you can use some of the solutions used by other ports (building
sections with pointers to the constructor/destructor functions).

I'm wondering if there are any C++ -> C compilers still around (such as the
original CFRONT)?  It might be simpler to use those rather than trying to slog
through the GCC support if you are just doing this for one project.

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com


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