Errors while crosscompiling a mips toolchain under OSX

Khem Raj raj.khem@gmail.com
Mon May 23 02:33:00 GMT 2011


On 5/22/2011 3:26 PM, Guylhem Aznar wrote:
> Hello
>
> I'm trying to generate a toolchain for mips under macosx, and I've run
> into various error, which were initially due to a bad choice of
> triplet. With "mips-linux" + a change to newlib configure script
> (commenting out mips*-*-linux* on line 3529) I can reach stage 2
> Now I'm stuck there on libiberty if I disable C++ :
> (...)
> checking for library containing strerror... configure: error: Link
> tests are not allowed after GCC_NO_EXECUTABLES.
> (...)
> but also later if I enable it:
> (...)
> /Developer/Fritzbox/mips-linux/bin/ld: cannot find crti.o: No such
> file or directory
> /Developer/Fritzbox/mips-linux/bin/ld:
> /Developer/Fritzbox/mips-linux/lib/libc.a(lib_a-abort.o): relocation
> R_MIPS_HI16 against `__gnu_local_gp' can not be used when making a
> shared object; recompile with -fPIC
> /Developer/Fritzbox/mips-linux/lib/libc.a: could not read symbols: Bad value
> collect2: ld returned 1 exit status
> make[2]: *** [libgcc_s.so] Error 1
> make[1]: *** [all-target-libgcc] Error 2
>
>
> Versions and commands used :
>
> cd gmp-5.0.2&&  ./configure --disable-nls
> --prefix=/Developer/Fritzbox/ --enable-cxx |tee config-gmp.log&&  make
> -j4 | tee make-gmp.log&&  make install&&  cd ..
> cd mpfr-3.0.1&&  ./configure --disable-nls
> --prefix=/Developer/Fritzbox/ --with-gmp=/Developer/Fritzbox/| tee
> config-mpfr.log&&  make -j4 | tee make-mpfr.log&&  make install&&  cd
> ..
> cd mpc-0.8.2&&  ./configure --disable-nls --prefix=/Developer/Fritzbox
>   --with-gmp=/Developer/Fritzbox --with-mpfr=/Developer/Fritzbox | tee
> config-mpc.log&&  make -j4 |tee make-binutils.log&&  make install&&
> cd ..
> cd binutils-2.21&&  ./configure --disable-nls
> --prefix=/Developer/Fritzbox  --with-gmp=/Developer/Fritzbox
> --with-mpfr=/Developer/Fritzbox  --target=mips-linux --with-gnu-as
> --with-gnu-ld --enable-interwork --enable-multilib --enable-ld |tee
> config-binutils.log&&  make -j4 |tee make-binutils.log&&  make install
> rm -fr gcc-build-freestanding ; mkdir gcc-build-freestanding&&  cd
> gcc-build-freestanding&&  ../gcc-4.5.3/configure --disable-nls
> --with-gmp=/Developer/Fritzbox --with-mpfr=/Developer/Fritzbox
> --with-mpc=/Developer/Fritzbox  --prefix=/Developer/Fritzbox
> --target=mips-linux --with-gnu-as --with-gnu-ld --enable-interwork
> --enable-multilib  --with-newlib --enable-languages=c
> --without-headers --disable-shared --disable-threads
> --disable-checking --disable-werror --disable-libssp
> --disable-libmudflap --disable-libgomp | tee
> config-gcc-freestanding.log&&  make -j4 |tee make-gcc.log&&  make
> install
> cd newlib-1.19.0&&  ../configure --with-mpfr=/Developer/Fritzbox
> --with-gmp=/Developer/Fritzbox --with-mpc=/Developer/Fritzbox
> --prefix=/Developer/Fritzbox  --target=mips-linux  --enable-interwork
> --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls | tee
> config-newlib.log&&  make -j4 | tee make-newlib.log&&  make install
> rm -fr gcc-build-full ; mkdir gcc-build-full&&  cd gcc-build-full&&
> ../gcc-4.5.3/configure --disable-nls --with-gmp=/Developer/Fritzbox
> --with-mpfr=/Developer/Fritzbox --with-mpc=/Developer/Fritzbox
> --prefix=/Developer/Fritzbox  --target=mips-linux --with-gnu-as
> --with-gnu-ld --enable-interwork --enable-multilib
> --enable-languages=c,c++ --without-headers --disable-threads
> --enable-shared | tee config-gcc-full&&  make -j4 |tee
> make-gcc-full.log&&  make install
>   --enable-threads=single
>

newlib is for baremetal. If you are compiling for mips-linux then you
have to use either glibc or uclibc. The build sequence becomes a bit
twisted since now it needs linux kernel headers and few bootstraps for 
gcc to get the final toolchain. Have a look here

http://uclibc.org/~kraj/toolchain-uclibc.sh

that might help you understanding the process of building cross 
toolchains using uclibc.

> I have been looking on google and on the list for the cause of these
> bugs - apparenty the R_MIPS_HI16 is due to a compilation without -fPIC
> (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524593) and the
> GCC_NO_EXECUTABLES is due to LIBTOOL checks
> (http://gcc.gnu.org/ml/gcc/2007-11/msg00790.html) but I'm not sure
> about this one, so my config.log is attached here.
>
> I would like to crosscompile a c/c++ toolchain then compile a native
> toolchain for the mips host (a fritzbox 7390, mips big endian, it uses
> uclibc and I only need some simple tools so I compile statically with
> :export CFLAGS="-O3 -march=24kec -mips16 -mdsp -static -static-libgcc
> -Wl,-static")

if you have a mips cross toolchain configured with uclibc as C library
it should suffice. You could use this toolchain then to compile gcc
for target i.e. mips and resulting gcc should be able to run on the
target.

>
> I'm interested in learning to do that by hand (I know crosstools,
> buildroot, etc.) and understanding what I'm not doing correctly. I
> hope my "mips-linux" choice is correct by the way :-)
>
> So my question: how can I work around these bugs? For the -fpic I
> assume I should pass a flag to gcc 2nd stage compilation but I haven't
> found which one after some googling. The documentations I found did
> not mention this problem, probably because they used old version of
> gcc.
>
> Any help is appreciated.
>
> Guylhem
>
>
>
>
> --
> For unsubscribe information see http://sourceware.org/lists.html#faq


--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list