Building Binutils & GCC3 in the MinGW VM
Now it's time to replace second bootstrapping compiler with full-featured compiler tied to eglibc and capable of building hosted code, not only freestanding code. Also new compiler will be independent from cygwin1.dll, unlike the old one.
Update C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.sh :
#!/bin/bash export TARGET=arm-linux-gnueabihf export PREFIX=/opt/crosstool/gcc-4.6.3-eglibc-2.13/$TARGET cd /opt/crosstool/src/build-binutils find . -delete ../binutils-2.22/configure --target=$TARGET \ --prefix=$PREFIX --with-sysroot=$TARGET \ --disable-nls --with-arch=armv6 if [ "$?" -ne "0" ]; then echo "=== build script: failed to configure binutils ===" exit 1 fi make all if [ "$?" -ne "0" ]; then echo "=== build script: failed to make binutils ===" exit 1 fi make install if [ "$?" -ne "0" ]; then echo "=== build script: failed to install binutils ===" exit 1 fi export PATH=$PATH:$PREFIX/bin cd /opt/crosstool/src/build-gcc find . -delete ../gcc-4.6.3/configure --target=$TARGET --prefix=$PREFIX \ --with-arch=armv6 --with-fpu=vfp --with-float=hard \ --with-sysroot=$PREFIX \ --disable-sjlj-exceptions --enable-checking=release \ --enable-linker-build-id --enable-gnu-unique-object \ --disable-nls --enable-languages=c,c++ \ --with-headers --enable-shared --enable-threads=posix \ --disable-multilib -enable-__cxa_atexit \ --disable-libmudflap --disable-libssp \ --disable-libgomp --without-ppl --without-cloog \ --with-gmp=/usr/local --with-mpfr=/usr/local \ --with-mpc=/usr/local if [ "$?" -ne "0" ]; then echo "=== build script: failed to configure gcc ===" exit 1 fi make if [ "$?" -ne "0" ]; then echo "=== build script: failed to make gcc ===" exit 1 fi make install if [ "$?" -ne "0" ]; then echo "=== build script: failed to install gcc ===" exit 1 fi echo "=== build script: OK ==="
- You may need to reapply dos2unix to build_gcc_cross.sh if your text editor does not preserve DOS/Unix line endings.
- Put C-style comments /* */ around "#define caddr_t char *" line in C:\MinGW\msys\1.0\opt\crosstool\src\gcc-4.6.3\gcc\configure to prevent caddr_t-related error in sys/types.h during GCC build.
- Run C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.cmd and wait until it completes.
- If there are no errors, shutdown the MinGW VM and make snapshot "SNAP-D".
Notes:
- There may be an error in $TARGET/usr/include/sys/types.h when building GCC (in the line "typedef __caddr_t caddr_t;"). Reason: you forgot to patch GCC configure script as described above.
- Multilib is a special feature of GCC to allow building 32-bit targets on x86_64 platform. It's useless on ARM.
- If you didn't specify --with-sysroot=$PREFIX configure argument,
you will get the following error during build:
In file included from ../../../gcc-4.6.3/libgcc/../gcc/libgcc2.c:29:0:
../../../gcc-4.6.3/libgcc/../gcc/tsystem.h:87:19: fatal error: stdio.h: No such file or directory
compilation terminated.
make[2]: *** [_muldi3.o] Error 1
make[2]: Leaving directory `/opt/crosstool/src/build-gcc/arm-linux-gnueabihf/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/opt/crosstool/src/build-gcc'
make: *** [all] Error 2
Additional steps to support SoftFP ABI:
- Replace TARGET=arm-linux-gnueabihf with TARGET=arm-linux-gnueabi and ../gcc-4.6.3/configure with ../gcc-4.6.3.noarmhf/configure in build_gcc_cross.sh
- binutils configure flags: --with-arch=armv4t
- gcc configure flags: --with-arch=armv4t --with-float=soft. Also remove --with-fpu=vfp.
- You may need to reapply dos2unix to build_gcc_cross.sh if your text editor does not preserve DOS/Unix line endings.
- Run C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.cmd and wait until it completes.
- If there are no errors, shutdown the MinGW VM and make snapshot "SNAP-E".
>> Read next section or
buy already prepared
cross-compiler (€10) to save your time.