Deploying Inputs into the MinGW VM

1. Moving intermediary build results

  • Boot into your Cygwin VM, open Cygwin console, and run the following commands:
    $ cd /opt/crosstool/
    $ tar --owner=0 --group=0 -h -zcf \
        cygwin-build-results.tar.gz gcc-8.3.0-glibc-2.28
    
    Because target MinGW VM does not support symlinks, it's important to create tar archive with symlink dereferencing (-h option).
     
  • Copy cygwin-build-results.tar.gz to a shared folder with a host and shutdown the Cygwin VM.
     
  • Boot into your MinGW VM, create new folder C:\MinGW\msys\1.0\opt\crosstool and copy cygwin-build-results.tar.gz from shared folder with a host into recently created folder C:\MinGW\msys\1.0\opt\crosstool.
     
  • Open MinGW shell, and run the following commands:
    $ cd /opt/crosstool
    $ tar -zxf cygwin-build-results.tar.gz
    $ cd gcc-8.3.0-glibc-2.28
    $ ls -l
    $ find . -name '*.exe' -delete
    $ find . -name '*.dll' -delete
    Last commands will remove all .exe/.dll files in the intermediary build results, because these binary files depend on cygwin1.dll and won't run in MinGW anyway. Also they won't run because our Cygwin environment is 64-bit and our MinGW environment is 32-bit.
 

2. Unpacking source code

Open MinGW shell, create directory /opt/crosstool/src (mkdir -p), and unpack binutils, gcc, mpc, mpfr and gmp into it. Use "tar zxf" to unpack .tar.gz files, "tar jxf" to unpack .tar.bz2 files, and "tar Jxf" to unpack .tar.xz files (grab these files from host system via shared folder).

You should get the following folders:

C:\MinGW\msys\1.0\opt\crosstool\src\binutils-2.31.1
C:\MinGW\msys\1.0\opt\crosstool\src\gcc-8.3.0
C:\MinGW\msys\1.0\opt\crosstool\src\gdb-8.2.1
C:\MinGW\msys\1.0\opt\crosstool\src\gmp-6.1.2
C:\MinGW\msys\1.0\opt\crosstool\src\mpfr-4.0.2
C:\MinGW\msys\1.0\opt\crosstool\src\mpc-1.1.0
C:\MinGW\msys\1.0\opt\crosstool\src\expat-2.2.9

Source code for glibc is not required, because we have already built it.

 

3. Patching source code

Please copy downloaded patch files to /opt/crosstool/src (C:\MinGW\msys\1.0\opt\crosstool\src) and run the following commands in the MSYS terminal:

# cd /opt/crosstool/src/
# gunzip binutils-2.31.1.mingw.diff.gz
# gunzip gdb-8.2.1.mingw.diff.gz
# cd /opt/crosstool/src/binutils-2.31.1
# patch -p1 < ../binutils-2.31.1.mingw.diff
# cd ../gdb-8.2.1
# patch -p1 < ../gdb-8.2.1.mingw.diff

 

4. Creating temporary folders for build

gcc and probably other software and libraries will not build in their source folders. So, please create build-gmp, build-mpfr, build-mpc, build-expat, build-binutils, build-gcc and build-gdb subfolders in C:\MinGW\msys\1.0\opt\crosstool\src. These subfolders will contain intermediary build results when corresponding software will be built.

 

5. Patching MinGW build environment

Please make sure that C:\MinGW\include\wincon.h contains the following lines:

#define COMMON_LVB_REVERSE_VIDEO  0x4000
#define COMMON_LVB_UNDERSCORE     0x8000

 

6. Creating script files

Also please prepare stub batch file C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.cmd with the following contents:

@echo off
C:\MinGW\msys\1.0\bin\dos2unix.exe ^
    -l -c C:/MinGW/msys/1.0/opt/crosstool/src/build_gcc_cross.sh

C:\MinGW\msys\1.0\bin\bash.exe ^ -l -c /opt/crosstool/src/build_gcc_cross.sh

Also please prepare main build script file C:\Cygwin\opt\crosstool\src\build_gcc_cross.sh with the following contents:

#!/bin/bash

echo "=== build script: OK ==="

Then run build_gcc_cross.cmd to make sure scripts work as expected.


It's recommended to shutdown MinGW virtual machine and make snapshot "SNAP-B" when initial deployment is done.


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