This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: CrosGCC: [cross]compiling egcs/gcc with glibc headers


Brendan John Simon wrote:
> 
> I'm trying to cross-compile gcc-2.95.2 and egcs-1.1.2 for a
> powerpc-linux system.  Kai Ruotto suggested preinstalling headers and
> libs from an exisiting powerpc-linux system (yellowdog) into the
> $prefix/$target/include and $prefix/$target/lib directory.  This does
> work but I'm not too keen on this method.  I'd prefer to compile
> everything from the sources.
>
> I would prefer to use gcc-2.95.2 but it has problems compiling
> glibc-2.1.1 and glibc-2.1.2.  It complains about
> __libc_global_constructors not being defined.  I do not have this
> problem when I use egcs-1.1.2.  This problem shows up for both native
> ix86-linux compiles and also powerpc-linux cross-compiles.  Any ideas ?

 I think you must first update your native Linux 'host' suitable for
glibc-2.1.x before the build will succeed. The same thing will be needed
for the 'virtual' powerpc-linux 'host'. The minimum can be the Linux
kernel-2.2.10 or something...

 Perhaps the docs for the other Linux targets may help.  The 'arm-linux'
webpage from Phil Blundell, says about producing the glibc in a cross-
development environment:

-------------------- clip ----------------------------------------------
3. libc 

For ARM systems you need glibc 2.1.  You will need the linuxthreads and
crypt add-ons as well as the library itself.  The primary distribution
site for glibc is here but this server is located in the USA and people
from other countries must not download the crypt add-on from there.
Instead you can find it on ftp.funet.fi.

Compiling the libc natively is simple and you can just follow the instructions.
If you are building on a system that is already based on glibc then be careful
if you install your new library -- a mistake may mean you are hosed. 

In a cross-compile environment things are a little more difficult.  You need to
use a configure line of the following form: 

$ CC=arm-linux-gcc .../configure arm-linux --build=i586-linux --prefix=/usr/arm-linux
--enable-add-ons=... 

Specifying the compiler is compulsory, otherwise you will end up building the library
with your native compiler which will leave you with a horrendous mix of architectures
and a broken library.  Specifying the build system is also necessary to ensure the make
process goes smoothly.  The name you give here doesn't need to be 100% accurate, it
basically just has to be different from the name of the host system.  It makes no sense
to use --target when configuring glibc.  Do NOT just give the same --prefix argument
that you used for compiling gcc and binutils, make sure you add the extra component so
that the library installs into the correct target directory.  Installing a cross library
in /usr by mistake will bring you to grief quite quickly. 

For standalone environments you might like to investigate the newlib package instead. 
-------------------- clip ----------------------------------------------

 I'm going to try the 'arm-linux' and these Phil's instructions quite soon (that's why
I looked at the docs...)

 The arm-linux docs suggested egcs-1.1.1 as the preferred compiler... What does the
glibc-2.1.x docs say about the 'preferred compiler' to compile the library sources?
The glibc-2.1.2/FAQ should have something about this, the glibc-2.1.1-2.1.2 diffs
have :

-------------------- clip ----------------------------------------------
 1.5.	Which compiler should I use for powerpc?

-{GK} You want to use egcs 1.1 or later (together with the right versions
-of all the other tools, of course).
-
-In fact, egcs 1.1 has a bug that causes linuxthreads to be
-miscompiled, resulting in segmentation faults when using condition
-variables.  There is a temporary patch at:
-
-<http://discus.anu.edu.au/~geoffk/egcs-3.diff>
-
-Later versions of egcs may fix this problem.
+{GK} You want to use at least gcc 2.95 (together with the right versions
+of all the other tools, of course).  See also question question 2.8.
-------------------- clip ----------------------------------------------

 So the gcc-2.95.x seems to be now the 'preferred'...

 Ok, some 'stupid' or self-evident questions and things...

 Where it gives that "__libc_global_constructors not being defined" ?  Which
compiler it uses then? (The native one because of some error, or the cross-
compiler and not finding this from the headers...). Or it is a link-error
when trying to build some executable/shared library? (Is the 'shared' used
when trying to produce the shared lib?)

 When the glibc will be built with some compiler, native or cross, there
SHOULDN'T be any need for other C-headers than those provided with the glibc
sources, and the build should find the headers from the sources.  Just as
the newlib build will not need any headers for the 'host' (= 'target' with
other builds). So copying them somewhere is unnecessary. (The Linux kernel
headers and the target 'asm' headers must be got somewhere however...)

 The GCC-build needs the headers for the target, but building the C-library
should not need them anywhere but in the C-library sources. Old glibc-versions
(1.09) took some headers from the target's proprietary (from the manufacturer)
ones and searched some info from them ('sys/errno.h', 'sys/param.h',...).

 Building GCC using the new glibc-2.1.x may perhaps work only when the glibc-2.1.x
has been installed. So you probably need to build gcc-2.95.2 first using your
current headers & libs, build glibc-2.1.x using it, install glibc-2.1.x and rebuild
gcc-2.95.2 with glibc-2.1.x. Or the things may be more complicated, I cannot say
how well (or if at all) old glibc-2.0.7-based binaries will run with glibc-2.1.x
shared libraries.

 About building glibc...

 I cannot imagine what 'secret' or 'proprietary' info the current headers
(the Yellowdog ones) for the target could have, and why the same info couldn't
be included into the glibc sources...

 The only ones could be the Linux kernel headers (.../include/linux), there
can be a need to use some up-to-date kernel sources and the headers from it.
So you must link the 'linux/include/linux' (or what it then was...) from them
to your 'powerpc-linux' headers (for the cross-compiler) while building glibc.
So it would see the 'host' environment for glibc to be just as it should be...
Perhaps the things like where to symlink the Linux-kernel headers -- they don't
belong to the glibc-headers, but are the necessary part of the installed Linux
C-library -- are already told in the glibc build instructions, but now this has
been repeated.
 
Cheers, Kai


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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