Deploying Source Code to Cygwin VM

1. Unpacking source code

Open Cygwin console, create directory /opt/crosstool/src (mkdir -p), and unpack binutils, gcc and glibc 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

Also you need to unpack previously prepared Linux API headers into /opt/crosstool.

In the end, you should get the following folders:


Also please copy downloaded patch files to /opt/crosstool/src (C:\Cygwin\opt\crosstool\src).

2. Creating symlinks

Please run the following commands in the cygwin console:

# cd /opt/crosstool/gcc-8.3.0-glibc-2.28/i586-linux-gnu
# mv usr i586-linux-gnu
# ln -s i586-linux-gnu usr
# ls -l
# cd /opt/crosstool/gcc-8.3.0-glibc-2.28/x86_64-linux-gnu
# mv usr x86_64-linux-gnu
# ln -s x86_64-linux-gnu usr
# ls -l


3. Applying patch for glibc

Start Cygwin console and run the following commands:

$ cd /opt/crosstool/src
$ gunzip glibc-2.28.cygwin.diff.gz
$ cd /opt/crosstool/src/glibc-2.28
$ patch -p1 < ../glibc-2.28.cygwin.diff


4. Preventing glibc build error on case-insensitive filesystem

In order to prevent glibc build errors on the case-insensitive filesystem (Windows), please find (in glibc source tree) all makefiles containing ".oS" string (in that exact case) and replace it with ".oZ". Do not touch ".os" strings.

Here is a list of files to be updated for glibc-2.28:


5. Creating temporary folders for build

gcc and glibc, and probably other software will not build in their source folders. So, please create build-binutils, build-gcc and build-glibc subfolders in C:\Cygwin\opt\crosstool\src. These subfolders will contain intermediary build results when corresponding software will be built.

6. Creating script files

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

@echo off
set PATH=C:\Cygwin\bin;%PATH%
dos2unix.exe /opt/crosstool/src/
bash.exe -l -c /opt/crosstool/src/

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


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

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

It's recommended to shutdown the virtual machine and make snapshot "SNAP-2" when initial deployment is done. Otherwise in case of any errors in future you'll have to start all this Rube Goldbergy again.

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