Cross Compiler Problems

Cross Compiler Problems

Post by Michael Ericks » Sun, 11 Feb 2001 01:02:39



Hello all.
I am haveing some real problems with setting up gcc as a cross
compiler. The host platform is an i686-pc-linux-gnu. The target will
be sh-linux-gnu (linux running on an embedded board based on the
hitachi sh4 processor).  My host platform is also running kernel 2.4
which supports sh4. Here is what I have done.

Installed  010116 snapshot of binutils. No problem here, I configured
with the options: --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
--target=sh-linux-gnu. This left me with cross binutilities in
/usr/local/sh-linux-gnu

Then, I placed "appropriate" headers in the directory
/usr/local/sh-linux-gnu/include. These headers included:

asm -- a symbolic link to /usr/src/linux/include/asm-sh
linux - a symbolic link to /usr/src/linux/include/linux
(Note, the above links point to kernel 2.4 source files.)

The remaining headers and directories I got out of glibc-2.2.1 and
copied to /usr/local/sh-linux-gnu/include:

/usr/include/bits
/usr/include/gnu
/usr/include/sys
/usr/include/endian.h, alloca.h, time.h, features.h, unistd.h, and
stlib.h

I decided on the above files and directories by attempting to build
gcc and noteing where it failed. I then added the header files it
needed until I got no more errors concerning missing files.

I configure gcc with options: --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=sh-linux-gnu --enable-shared
--enable-languages=c

I then build with the command: make gcc-all LANGUAGES=c

The problem is, I get errors from the assembler about bad assembly
code while xgcc is trying to compile libgcc2.c. I compiled a little
test program with the xgcc program that the build process made. It
doesn't seem to make any valid assembly. That is, neither my native
x86 assembler, nor the sh cross-assembler sitting in
/usr/local/sh-linux-gnu/bin seem to be able to do anything with the
code generated by xgcc. Does anyone have any thoughts on this?

As I understand it, while installing gcc, xgcc is made first. This is
then used to compile the rest of the gcc source. So, shouldn't xgxx be
generating x86 assembly code?

Kai has been helping me through this whole process, yet he doesn't
seem to be having any of these troubles.

Thanks for any help,
--Mike


 
 
 

Cross Compiler Problems

Post by Nix » Tue, 13 Feb 2001 17:35:27


On Fri, 09 Feb 2001, Michael Erickson spake:

[Assuming gcc-2.95.2.]

Quote:> Then, I placed "appropriate" headers in the directory
> /usr/local/sh-linux-gnu/include. These headers included:

> asm -- a symbolic link to /usr/src/linux/include/asm-sh
> linux - a symbolic link to /usr/src/linux/include/linux
> (Note, the above links point to kernel 2.4 source files.)

> The remaining headers and directories I got out of glibc-2.2.1 and
> copied to /usr/local/sh-linux-gnu/include:

> /usr/include/bits
> /usr/include/gnu
> /usr/include/sys
> /usr/include/endian.h, alloca.h, time.h, features.h, unistd.h, and
> stlib.h

> I decided on the above files and directories by attempting to build
> gcc and noteing where it failed. I then added the header files it
> needed until I got no more errors concerning missing files.

Argh!

That directory holds header files for the *target*. Unless your embedded
processor has glibc on it the glibc headers are decidedly the wrong ones
to use.

You might find it more useful to get newlib or some other small C
library and use that; or you can #define inhibit_libc in
gcc/config/sh/t-sh (IIRC) which might help by suppressing calls in the C
runtime library to things that would be present in a hosted ISO C
library but make no sense on a freestanding implementation.

No matter what, you'll need to *write* a <float.h> for your target; for
non-embedded targets the program `enquire -f' can be built for that
target and used to compute that header, but you can't really run that on
an embedded target. (Maybe you can modify it to arrange to have it do
I/O in whatever way your embedded target can do that.)

Quote:> I configure gcc with options: --build=i686-pc-linux-gnu
> --host=i686-pc-linux-gnu --target=sh-linux-gnu --enable-shared
> --enable-languages=c

That's fine.

Quote:> I then build with the command: make gcc-all LANGUAGES=c

No!

`make LANGUAGES=c'. No explicit target name (and as of GCC-3.0 the
LANGUAGES gunge won't be necessary anymore either). No target name.

(The install guide is fairly clear on this --- as clear as it is on
anything related to cross-compilation, which is not much --- and it
never mentions `gcc-all', since that doesn't exist. What version of GCC
are you trying to build?

Quote:> As I understand it, while installing gcc, xgcc is made first. This is
> then used to compile the rest of the gcc source. So, shouldn't xgxx be
> generating x86 assembly code?

I can't tell what on earth it is doing; you're running a makefile target
that doesn't exist :)

Cross builds are special; they must be bootstrapped with GCC, and the
bootstrap there is one-stage; xgcc is only used to build libgcc2, not
(as in normal bootstraps) the next stage of the bootstrap.

--
`Anyhow, that pipe dream doesn't say anything about the question you
 asked.  (I am planning for a career in politics.)' --- Mark Mitchell
                                                      on the GCC list

 
 
 

1. cross compiler problems

    Ok i tried compiling a cross compiler on linuxppc. And everything
compiled fine and seemed to install. ALl the stuff had differnt names
than my ppc compiler but the new cross compilers didnt work. And now to
top it off, i cant compile things regularly with my normal compiler. I
know i did something but i dont know how to fix it. I'm going to totally
re-install as soon as i get my copy of r5, but i dont know when itll be
and id like to be able to compile something in the meantime, can anyone
help me out. Ive tried checking out deja news and the linuxppc mailing
lists for help, but havent found much. The error tha ti get from a
configure script of any program is this.

configure:876: gcc -o conftest    conftest.c  1>&5
Assembler messages:
Error: invalid switch -mc68020
configure: failed program was:
#line 872 "configure"
#include "confdefs.h"
main(){return(0);}

so it seems like obviously it was beacause i was trying to install a
cross compiler i goofed things up, but im not sure how to fix it. Thanks
in advance

    Scott Knight

2. 10G partition, 6G ext2 file system!

3. cross-compiler problem

4. DITTO Max tape drive in 2.2.5?

5. Cross Compiler Problems

6. installing Star Office 5.2 on Linux Kernel 2.4.x

7. problem in setup cross-compiler in cygwin.

8. strange file: .nfsCE2B ???

9. HELP!! Cross compiler/linker problem

10. Problems building a cross-compiler

11. HELP!! Cross compiler/linker problem

12. problems building cross-compiler host/build in linux for target i686-pc-msdosdjgpp (long)

13. SCO cross-compiler, iBCS, curses -- problems!