Building Binutils & GCC in the Cygwin VM

  1. Update C:\Cygwin\opt\crosstool\src\build_cross_toolchain.sh :

    #!/bin/bash
    
    export TARGET=arm-linux-gnueabihf
    export PREFIX=/opt/crosstool/gcc-4.9.2-glibc-2.19/$TARGET
    
    cd /opt/crosstool/src/build-binutils
    find . -delete
    ../binutils-2.25/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.9.2/configure --target=$TARGET --prefix=$PREFIX \
        --with-arch=armv6 --with-fpu=vfp --with-float=hard \
        --disable-sjlj-exceptions --enable-checking=release \
        --enable-linker-build-id --enable-gnu-unique-object \
        --disable-nls --enable-languages=c \
        --without-headers --disable-shared --disable-threads \
        --disable-multilib --disable-decimal-float \
        --disable-libmudflap --disable-libssp \
        --disable-libgomp --without-ppl --without-cloog \
        --with-gmp --with-mpfr --with-mpc
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to configure gcc ==="
        exit 1
    fi
    make all-gcc
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to make gcc ==="
        exit 1
    fi
    make install-gcc
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to install gcc ==="
        exit 1
    fi
    make all-target-libgcc
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to make libgcc ==="
        exit 1
    fi
    make install-target-libgcc
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to install libgcc ==="
        exit 1
    fi
    
    echo "=== build script: OK ==="
    

  2. Run C:\Cygwin\opt\crosstool\src\build_cross_toolchain.cmd and wait until it completes.
  3. If there are no errors, shudown the Cygwin VM and make snapshot "SNAP-4".

Notes:

  • If there's complaint about missing file fenv.h, then you forgot to specify "--disable-decimal-float" when configuring gcc.
  • "--without-headers" means freestanding-mode only compiler without libc dependency.
  • Multilib is a special feature of GCC to allow building 32-bit targets on x86_64 platform. It's useless on ARM.

Additional steps to support SoftFP ABI:

  1. Replace TARGET=arm-linux-gnueabihf with TARGET=arm-linux-gnueabi in build_cross_toolchain.sh
  2. binutils configure flags: --with-arch=armv4t
  3. gcc configure flags: --with-arch=armv4t --with-float=soft. Also remove --with-fpu=vfp.
  4. Run C:\Cygwin\opt\crosstool\src\build_cross_toolchain.cmd and wait until it completes.
  5. If there are no errors, shutdown the Cygwin VM and make snapshot "SNAP-5".


>> Read next section or buy already prepared cross-compiler ($10) to save your time.