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: problems cross-compilng gcc


Andy wrote:

> I'm trying to  build  a cross compiler for powerpc OpenBSD on a i386
> OpenBSD machine (2.5)
> 
> I configured binutils with the following:
> configure ---host=$MACHTYPE --target=powerpc--openbsd
> --prefix=/usr/cross-tools -v
> This worked fine and built binutils.
> I then ran configure script  for gcc with the same parameters and then ran
> make all install.
> There I get error:
> /usr/buildtools/gcc-2.95.2/gcc/xgcc -B/usr/buildtools/gcc-2.95.2/gcc/
> -B/usr/cross-tools/powerpc--openbsd/bin/ -c -DHAVE_CONFIG_H -g -O2 -I.
> -I./../../include  vsprintf.c
> vsprintf.c: In function `vsprintf':
> vsprintf.c:47: structure has no member named `_flag'
> vsprintf.c:47: `_IOWRT' undeclared (first use in this function)
> vsprintf.c:47: (Each undeclared identifier is reported only once
> vsprintf.c:47: for each function it appears in.)
> vsprintf.c:47: `_IOSTRG' undeclared (first use in this function)
> vsprintf.c:48: structure has no member named `_ptr'
> vsprintf.c:49: structure has no member named `_cnt'
> 
> Looks like it's running a test of libgc1.a and fails to find the correct
> definitions for things like FILE among others.

 You have clipped quite a lot away from your output sample, but the last rows
will tell where the problem is. Not in building 'libgcc.a' but in building
'libiberty.a' for the target.

> Stop in /usr/buildtools/gcc-2.95.2/powerpc--openbsd/libiberty.
> *** Error code 1

 Before trying libiberty there is a search of the 'missing' functions in the
C-library (libc.a) and this results to the decision to include the 'vsprintf()'
into 'libiberty.a'. If you haven't the 'libc.a' for the target yet, it also
cannot find the vsprintf() from it.

> I don't quite understand why this is happening.
> Also: gcc was complaining a lot  about not being able to find files
> stdio.h and stdedef.h  and such until I created a symllink to usr/include
> in cross-tools/powerpc--openbsd ( my prefix directory)

 If you already have GCC or are going to build it, you should have the GCC
manual, "Using and Porting the GNU Compiler" :

---------------- clip ------------------------
Introduction

This manual documents how to run, install and port the GNU compiler, as well
as its new features and incompatibilities, and how to report bugs.  It
corresponds to GCC version 2.95.  
---------------- clip ------------------------

The chapter/section "Installation/Cross-Compiler" says:

---------------- clip ------------------------
Cross-Compilers and Header Files

If you are cross-compiling a standalone program or a program for an embedded
system, then you may not need any header files except the few that are part
of GNU CC (and those of your program).  However, if you intend to link your
program with a standard C library such as libc.a, then you probably need to
compile with the header files that go with the library you use.

The GNU C compiler does not come with these files, because (1) they are
system-specific, and (2) they belong in a C library, not in a compiler.

If the GNU C library supports your target machine, then you can get the header
files from there (assuming you actually use the GNU library when you link your
program).

If your target machine comes with a C compiler, it probably comes with suitable
header files also.  If you make these files accessible from the host machine,
the cross-compiler can use them also.

Otherwise, you're on your own in finding header files to use when cross-compiling.

When you have found suitable header files, put them in the directory
/usr/local/target/include, before building the cross compiler.  Then installation
will run fixincludes properly and install the corrected versions of the header files
where the compiler will use them.

Provide the header files before you build the cross-compiler, because the build stage
actually runs the cross-compiler to produce parts of libgcc.a.  (These are the parts
that can be compiled with GNU CC.)  Some of them need suitable header files.
---------------- clip ------------------------

 (The 'target' is in italics in the original text... and the '/usr/local' is the
default, '--prefix=/usr/local')

 The OpenBSD/PowerPC may have common headers with OpenBSD/x86, but the Linux-case tells
that expecting an operating system on different architectures to use the same headers
may be a wrong idea. So the sure case would be to take the target headers from the target
OpenBSD/PowerPC machine. Then you can make a diff between them and your native OpenBSD
headers and decide if a symlink is enough (= the headers are just the same).

> The thing that confuses me most is how do I determine from the error
> messages it spits out which particular module it was compiling.

 For me the 'libiberty/vsprintf.c' seems to be quite obvious...

> Also, what else do I need to build a functional cross compile environment
> besides gcc and binutils?

 Let me quote the GCC-manual again:

---------------- clip ------------------------
 · Link those files to make an executable.  You can do this either with a linker on
   the target machine, or with a cross-linker on the host machine.  Whichever machine
   you use, you need libraries and certain startup files (typically crt....o) for the
   target machine.
---------------- clip ------------------------

 You'll need the prebuilt target C-library with headers (for OpenBSD/PowerPC) or the
sources from where to compile it. For embedded systems the C-library is newlib, for
Linux it is the glibc, but for OpenBSD it is some BSD C-library. The startup-files
will also come with the C-library.

 I found prebuilt libs for OpenBSD/x86 via 'www.openbsd.org' or something when I tried
a cross-compiler for it a year or so ago. I would suggest you to start from there for
searching the OpenBSD/PowerPC stuff... Unless you have the target machine available.

 If you cannot find suitable pre-built libs for OpenBSD/PowerPC, probably you will
find at least the sources for them... Otherwise you can just forget the whole project...

 If your problems are now in building 'libiberty.a', this means that you have already
a working compiler, which you can use to build the C-library. But getting a prebuilt
C-library for the target, even a little old, would be much easier...

 After the C-library has been built and installed into the proper place (under 
$(prefix)/$(target)/lib and $(prefix)/$(target)/include), you can continue with libiberty.
Then it will have a 'libc.a' where to search the 'vsprintf()' and probably it finds it
there and doesn't try to build the one in the libiberty sources, which caused the error.

 Of course you may have troubles although you already had the target C-library with headers.
But when it went as far as really building 'libiberty.a', you passed the 'Cannot make
executables' somehow...

 It may be that your OpenBSD/PowerPC C-library doesn't have the 'vsprintf()'... And you
cannot compile the code in libiberty with your OpenBSD-headers. Then the quick way is to
decide that you don't need it and edit the

  /usr/buildtools/gcc-2.95.2/powerpc--openbsd/libiberty/Makefile

and remove the 'vsprintf.o' from the 'needed objects'-list there. I had this same problem
latest with the 'm68k-coff' or 'm68k-elf' target -- mystically it didn't find the function
in the 'libc.a' (perhaps it is really missing from newlib-1.8.0 or what I then have as the
C-library for m68k...)

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]