This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib 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: newlib mips cross compiler help


That's helped, thanks Jeff

Richard

-----Original Message-----
From: newlib-owner@sources.redhat.com
[mailto:newlib-owner@sources.redhat.com] On Behalf Of J. Johnston
Sent: 19 September 2003 20:21
To: Richard Neville
Cc: newlib@sources.redhat.com
Subject: Re: newlib mips cross compiler help

Richard Neville wrote:
> Hi,
> 
> For the last week I've been trying to build a newer gcc cross compiler
> for a mips32 architecture using newlib with gcc3.3 on redhat 8.0.
> 
> All is fine until I try to build a simple program against this new
> compiler it complains about a lack of crt0.o.
> 
> This looks on the face of it to be a newlib problem which although
> contains a crt0.S never seems to get compiled in libgloss. I've
attached
> the method I used to build the compiler below this mail.
> 
> My question is have I done anything that looks wrong in the above,
> should I really be using glibc instead, any extra patches, its all
> wrong/fine?
> 
> Any recommendations appreciated.
> 

Your target should be mips-elf, not mips-mips-elf.
I get a crt0.o built with mips-elf 1.10.0.  You should probably step up
to newlib-1.11.0 which
has a number of fixes not in 1.10.0.

-- Jeff J.

> Cheers
> 
> Richard
> ---------
> what you need:
> binutils-2.13<ftp://ftp.gnu.org/gnu/binutils/>
> newlib-1.10.0<ftp://sources.redhat.com/pub/newlib/index.html>
> gcc3.3 <ftp://ftp.mirror.ac.uk/sites/sources.redhat.com/pub/gcc/>
> 
> get the tars from 
> 
> // Setup a GNU directory
> mkdir GNU
> cd GNU
> 
> // setup some environment vars
> export host=i686-pc-linux
> export target=mips-mips-elf
> export prefix=<where ever you want to install the compiler>
> 
> // untar the files
> tar -zxvf <whatever>.tar
> 
> // make some target directories
> mkdir build-binutils build-gcc build-newlib
> 
> //configure, make and install binutils
> cd build-binutils
> ../binutils-2.13/configure 
> 		--host=$host
> 		--target=$target
> 		--prefix=$prefix
> 		--with-gnu-as
> 		--with-gnu-ld
> 
> make CFLAGS=-O2 LANGUAGES="c c++"
> make install LANGUAGES="c c++"
> 
> // configure and make the static c lib
> cd ../build-gcc
> ../gcc3.3/configure --enable-languages=c
> 	            --enable-multilib=no
> 		    --with-cpu=mips32
> 		    --with-newlib
> 		    --target=mips-mips-elf
> 		    --prefix=$prefix 
> 		    --with-gnu-as
> 		    --with-gnu-ar
> 
> make 
> make install
> 
> // now build newlib
> cd ../build-newlib
> ../newlib-1.10.0/configure --host=$target --prefix=$prefix
--with-gnu-as
> --with-gnu-ld --with-newlib make CC_FOR_TARGET=$prefix/$target/bin/gcc
>      AS_FOR_TARGET=$prefix/$target/bin/as
>      LD_FOR_TARGET=$prefix/$target/bin/ld
>      AR_FOR_TARGET=$prefix/$target/bin/ar
>      RANLIB_FOR_TARGET=$prefix/$target/bin/ranlib
> 
> make install
> 
> // now the tricky bit building the c++ compiler
> // if you try
> cd ../build-gcc
> ../gcc3.3/configure --enable-languages=c++
> 	            --enable-multilib=no
> 		    --with-cpu=mips32
> 		    --with-newlib
> 		    --target=mips-mips-elf
> 		    --prefix=$prefix 
> 		    --with-gnu-as
> 		    --with-gnu-ar
> 
> make 
> 
> // you will get errors like
> ~/xgcc/gcc-3.3/libiberty/hashtab.c: In function `higher_prime_number':
> 
>>~/xgcc/gcc-3.3/libiberty/hashtab.c:133: warning: implicit declaration
> 
> of function `abort'
> 
>>~/xgcc/gcc-3.3/libiberty/hashtab.c: In function `htab_create':
>>~/xgcc/gcc-3.3/libiberty/hashtab.c:204: error: `free' undeclared
> 
> (first use in this function)
> 
>>~/xgcc/gcc-3.3/libiberty/hashtab.c:204: error: (Each undeclared
> 
> identifier is reported only once
> 
>>~/xgcc/gcc-3.3/libiberty/hashtab.c:204: error: for each function it
> 
> appears in.)
> 
>>~/xgcc/gcc-3.3/libiberty/hashtab.c: In function `htab_try_create':
>>~/xgcc/gcc-3.3/libiberty/hashtab.c:214: error: `calloc' undeclared
> 
> (first use in this function)
> 
>>~/xgcc/gcc-3.3/libiberty/hashtab.c:214: error: `free' undeclared
> 
> (first use in this function)
> 
>>make[2]: *** [hashtab.o] Error 1
>>make[2]: Leaving directory
> 
> `~/xgcc/obj/m68k-elf/m68k-elf-gcc/m68k-elf/libiberty'
> 
>>make[1]: *** [install-target-libiberty] Error 2
>>make[1]: Leaving directory `~/xgcc/obj/m68k-elf/m68k-elf-gcc'
>>make: *** [install-gcc] Error 2
> 
> // According to Peter Barada you should add the hashtab.c portion of
> http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00726.html
> // this is basically adds #include <malloc.h> into hashtab.c
> // add the malloc header in your code into the /libiberty/hashtab.c
file
> // if you try to configure again you'll get more errors like In file
> included from 
> ../../../../gcc-3.3/libstdc++-v3/libsupc++/eh_alloc.cc:33:
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:86: `div_t' not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:87: `ldiv_t'
not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:97: `div' not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:102: `ldiv' not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:104: `mblen'
not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:105: `mbstowcs'
> not declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:106: `mbtowc'
not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:115: `wcstombs'
> not declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:116: `wctomb'
not
> declared
> ~/build-gcc/mipsisa32-elf/libstdc++-v3/include/cstdlib:122: syntax
error
> before `(' token
> make[3]: *** [eh_alloc.lo] Error 1
> make[3]: Leaving directory 
> `~/build-gcc/mipsisa32-elf/libstdc++-v3/libsupc++'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory 
> `~/build-gcc/mipsisa32-elf/libstdc++-v3'
> make[1]: *** [all-recursive-am] Error 2
> make[1]: Leaving directory 
> `~/build-gcc/mipsisa32-elf/libstdc++-v3'
> make: *** [all-target-libstdc++-v3] Error 2
> 
> // this is a header file problem according to Henri Girard
> // the configure should be modified to
> ../gcc3.3/configure --enable-languages=c++
> 	            --enable-multilib=no
> 		    --with-cpu=mips32
> 		    --with-newlib
> 		    --target=mips-mips-elf
> 		    --prefix=$prefix 
> 		    --with-gnu-as
> 		    --with-gnu-ar
> 		    --with-headers=$prefix/$target/include
> 	
> 
> // also delete the copy of stdlib.h in ~build-gcc
> make 
> make install
> 
> 
> 



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