Building Binutils & GCC in the Cygwin VM

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

    #!/bin/bash
    export TARGET=i586-linux-gnu
    export PREFIX=/opt/crosstool/gcc-8.3.0-glibc-2.28/$TARGET
    
    cd /opt/crosstool/src/build-binutils
    find . -delete
    ../binutils-2.31.1/configure --target=$TARGET \
        --prefix=$PREFIX --with-sysroot=$TARGET \
        --disable-nls --with-arch=i586
    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-8.3.0/configure --target=$TARGET --prefix=$PREFIX \
        --with-arch=i586 \
        --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_gcc_cross.cmd and wait until it completes.
  3. If there are no errors, shutdown the Cygwin VM and make snapshot "SNAP-4".

Additional steps to support 64-bit Linux target platform:

  1. Replace TARGET=i586-linux-gnu with TARGET=x86_64-linux-gnu and remove "--with-arch=i586" in build_gcc_cross.sh
  2. Run C:\Cygwin\opt\crosstool\src\build_gcc_cross.cmd and wait until it completes.
  3. 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.