This is the mail archive of the gcc-bugs@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]

Re: Cross compile is broken?


Jim Wilson <wilson@cygnus.com> writes:

> 	for libgcc2.c when your C library and header files are in
> 	$(build_tooldir). I have to do
> 
> 	# mkdir $(libdir)/gcc-lib/$(target_alias)/$(version)
> 
> There is code in the Makefile stmp-fixinc rule that creates this directory
> before it is first needed.
> 
> 	Is gcc cross compile broken for glibc? From what I can see in gcc
> 	source, cross compile only works for newlib. These are in
> 	gcc/Makefile.in:
> 
> I wouldn't say that cross compiles using newlib work right.  They do manage
> to work, but only because we cripple libgcc by defining inhibit_libc.  Since
> most of these crippled gcc features are hard to use for embedded targets
> anyways, few people care.
> 
> There is a little support for cygwin builds that gets it right, but it
> requires that newlib be part of the source tree, e.g. a one-tree build,
> and it isn't very pretty.  There is no one-tree support for GNU libc, and
> I am not convinced that there should be.

In most cases, you don't want to rebuild glibc anyway, you want to use
the glibc binaries that come with the distribution you are targetting;
otherwise you get nasty surprises caused by distribution-specific
changes to glibc.

> With GNU libc provided as source, there is the matter of bootstrapping the
> process.  You need to build and install a library before you can use
> --with-headers and --with-libs.  This would require doing something by hand,
> but you should only need to do it once, so it doesn't seem like it would be
> too hard.

It's a bit tricky.  One of the problems is that parts of libgcc
require stdio; not just the 'simple' stdio, like printf(), but
`complicated' things like stderr and fopen.

This has several nasty effects, among which is that you may need to
rebuild libgcc.a when you upgrade from glibc 2.0 to 2.1.  It also
makes finding the right header files for cross-compilation very
difficult.  

I think the best way to build a cross-gcc is to simply use
inhibit_libc the first time, then build&install glibc, then rebuild
gcc.  This is the same process you should use to build gcc natively
from an old glibc anyway, so it should be no trouble.


-- 
Geoffrey Keating <geoffk@cygnus.com>


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