NMT:cross
export CTARGET=mipsel-linux-uclibc
export ARCH=mips
rm -rf build
mkdir build
cd build
../binutils-2.17/configure \
--target=$CTARGET \
--prefix=/usr/local/$ARCH/ \
--with-sysroot=/usr/local/$ARCH/$CTARGET \
--disable-werror
make
make install
# It installs things we don't want (and will fail later)
rm -rf /usr/local/$ARCH/{info,lib,man,share}
export PATH=/usr/local/$ARCH/bin:$PATH
cd ../linux-2.6.15.7
yes "" | make ARCH=$ARCH oldconfig prepare
#With 2.6.x, this will probably end in an error because you don't have a gcc
#cross-compiler yet, but you can ignore that. Just copy over the headers:
mkdir -p /usr/local/$ARCH/$CTARGET/usr/include/
rsync -arv include/linux include/asm-generic /usr/local/$ARCH/$CTARGET/usr/include/
rsync -arv include/asm-$ARCH/ /usr/local/$ARCH/$CTARGET/usr/include/asm
cd ../uClibc-0.9.28.3/
make menuconfig
#Target Architecture: mips
#Target Architecture Features and Options:
# Target Process Architecture: MIPS I
# Target Process Endianness: Little Endian
# Target CPU has a memory management unit (MMU): YES
# Enable floating point number support: YES
# Target CPU has a floating point unit: NO
# (/usr/local/mips/mipsel-linux-uclibc/usr) Linux kernel header location
#
#Library Installation Options
# (/usr/local/mips/mipsel-linux-uclibc) uClibc runtime library directory
# (/usr/local/mips/mipsel-linux-uclibc/usr) uClibc development environment
#
#uClibc development/debugging options
# (mipsel-linux-uclibc-) Cross-compiling toolchain prefix
# This command should fail.
make CROSS=mipsel-linux-uclibc-
# Copy the new include files
rsync -arvL include/ /usr/local/$ARCH/$CTARGET/sys-include
cd ../build/
rm -rf *
../gcc-4.0.4/configure \
--target=$CTARGET \
--prefix=/usr/local/mips \
--with-sysroot=/usr/local/mips/$CTARGET \
--enable-languages=c \
--disable-shared \
--disable-checking \
--disable-werror \
--disable-__cxa_atexit \
--enable-target-optspace \
--disable-nls \
--enable-multilib \
--with-float=soft \
--enable-sjlj-exceptions \
--disable-threads
make
make install
# Remove the temporary headers, and compile it properly.
rm -rf /usr/local/$ARCH/$CTARGET/sys-include
cd ../uClibc-0.9.28.3/
make CROSS=mipsel-linux-uclibc-
make install
# This bit fixes the C++ issue. But should not be required. TODO: Figure out why
cd /usr/local/mips/$CTARGET/lib
ln -s ../usr/lib//crti.o .
ln -s ../usr/lib//crtn.o .
ln -s ../usr/lib//crt1.o .
# Now recompile gcc fully.
cd ../build/
rm -rf *
../gcc-4.0.4/configure \
--target=$CTARGET \
--prefix=/usr/local/mips \
--with-sysroot=/usr/local/mips/$CTARGET \
--enable-languages=c,c++ \
--enable-shared \
--disable-checking \
--disable-werror \
--disable-__cxa_atexit \
--enable-target-optspace \
--disable-nls \
--enable-multilib \
--with-float=soft \
--enable-sjlj-exceptions \
--enable-threads=posix
# It is likely it will fail on __ctype_touplow_t*, this is quite easy to fix.
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14939
# I went with the #ifdef changes of ../gcc-4.0.4/libstdc++-v3/config/locale/generic/c_locale.h
# and ../gcc-4.0.4/libstdc++-v3/config/os/gnu-linux/ctype_base.h
make
make install
Unfortunately this will use libc dynamic linker, which is incorrect. So at the moment, use the following line to compile your executables.
# gcc -Wl,--dynamic-linker,/lib/ld-uClibc.so.0 -o hello hello.c
I will attempt to find out how to make it use the correct dynamic linker by default.
Thanks to emveepee we now know to do this:
1. To get around the need to specify the dynamic-linker I found you could be able to modify the default dynamic-linker in gcc4.0.4/gcc/config/mips/linux.h I just modified line 118 to the proper setting rather than applying the patch discussed in the following url and the problem goes away. http://www.busybox.net/lists/uclibc/2004-January/007943.html 2. The soft floating-point functions will not be linked in by default without a patch http://bugs.busybox.net/view.php?id=1069 which I haven't tried yet but linking in -lgcc_s also solves the problem.