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:
C:\Cygwin\opt\crosstool\src\gcc-8.3.0
C:\Cygwin\opt\crosstool\src\glibc-2.28
C:\Cygwin\opt\crosstool\gcc-8.3.0-glibc-2.28
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:
# 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:
$ 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:
Makeconfig
Makerules
csu/Makefile
htl/Makefile
sysdeps/i386/i686/Makefile
sysdeps/ieee754/ldbl-opt/Makefile
sysdeps/sparc/sparc32/sparcv9/Makefile
sysdeps/sparc/sparc64/Makefile
sysdeps/x86/Makefile
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:
set PATH=C:\Cygwin\bin;%PATH%
dos2unix.exe /opt/crosstool/src/build_gcc_cross.sh 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:
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.