Deploying Source Code to Cygwin VM

1. Unpacking source code

Open Cygwin console, create directory /opt/crosstool/src (mkdir -p), and unpack binutils, gcc, glibc and linux 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\binutils-2.25
C:\Cygwin\opt\crosstool\src\gcc-4.9.2
C:\Cygwin\opt\crosstool\src\glibc-2.19
C:\Cygwin\opt\crosstool\src\linux-4.1.19

Also please unpack patches-for-raspberry-pi-jessie-toolchain.tar.gz into /opt/crosstool/src (C:\Cygwin\opt\crosstool).

Also you need to create the following folders:

/opt/crosstool/gcc-4.9.2-glibc-2.19
/opt/crosstool/gcc-4.9.2-glibc-2.19/arm-linux-gnueabi
/opt/crosstool/gcc-4.9.2-glibc-2.19/arm-linux-gnueabihf
 

2. Applying patches

Start Cygwin console and run the following commands:

$ cd /opt/crosstool/src/glibc-2.19
$ cat ../glibc--cygwin-dirname-lookup.diff | patch -p1
$ cat ../glibc--cygwin-sunrpc-hdrs-libs.diff | patch -p1
 

3. Preventing glibc build error on case-insensitive filesystem

glibc has a problem when built under Cygwin: it needs case-sensitive filesystem, otherwise .os and oS files collide and "make" phase of glibc build fails with the following error message:

.../build-glibc/elf/librtld.os: In function `process_envvars':
../glibc-2.19/elf/rtld.c:2718: undefined reference to `__open'
../glibc-2.19/elf/rtld.c:2690: undefined reference to `__access'
../build-glibc/elf/librtld.os: In function `dl_main':
../glibc-2.19/elf/rtld.c:1657: undefined reference to `__access'
 
 

In order to prevent this problem, in glibc source tree: find 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.19:

extra-lib.mk
Makeconfig
Makerules
nptl/Makefile
sysdeps/i386/i686/Makefile
sysdeps/ieee754/ldbl-opt/Makefile
sysdeps/sparc/sparc32/sparcv9/Makefile
sysdeps/sparc/sparc64/Makefile
 
 

4. 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, build-glibc and build-linux subfolders in C:\Cygwin\opt\crosstool\src. These subfolders will contain intermediary build results when corresponding software will be built.
 

5. Creating script files

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

@echo off
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:

#!/bin/bash
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.