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" command to unpack .tar.gz files, "tar jxf" to unpack .tar.bz2 files and "tar Jxf" to unpack .tar.xz files.
You should get the following folders:
C:\Cygwin\opt\crosstool\src\gcc-8.3.0
C:\Cygwin\opt\crosstool\src\glibc-2.28
After unpacking linux-api-headers, you should get the following folders:
C:\Cygwin\opt\crosstool\gcc-8.3.0-glibc-2.28\arm-linux-gnueabi
C:\Cygwin\opt\crosstool\gcc-8.3.0-glibc-2.28\arm-linux-gnueabihf
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 arm-linux-gnueabi
# ln -s arm-linux-gnueabi usr
# ls -l
# cd /opt/crosstool/gcc-8.3.0-glibc-2.28/arm-linux-gnueabihf
# mv usr arm-linux-gnueabihf
# ln -s arm-linux-gnueabihf 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_cross_toolchain.cmd with the following contents:
set PATH=C:\Cygwin\bin;%PATH%
dos2unix.exe /opt/crosstool/src/build_cross_toolchain.sh
bash.exe -l -c /opt/crosstool/src/build_cross_toolchain.sh
Also please prepare main build script file C:\Cygwin\opt\crosstool\src\build_cross_toolchain.sh with the following contents:
echo "=== build script: OK ==="
Then run build_cross_toolchain.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.