Deploying Source Code to Cygwin VM

1. Unpacking source code

Open Cygwin console, create directory /opt/crosstool/src (mkdir -p), and unpack binutils, gcc-core, gcc-g++, mpc, mpfr, gmp and glibc into it. Use "tar zxvf" to unpack .tar.gz files and "tar jxvf" to unpack .tar.bz2 files.

You should get the following folders:

C:\Cygwin\opt\crosstool\src\binutils-2.20.1
C:\Cygwin\opt\crosstool\src\gcc-4.4.1
C:\Cygwin\opt\crosstool\src\mpc-0.9
C:\Cygwin\opt\crosstool\src\mpfr-3.0.1
C:\Cygwin\opt\crosstool\src\gmp-5.0.1
C:\Cygwin\opt\crosstool\src\glibc-2.10.1

Also you need to create the following folders:

/opt/crosstool/gcc-4.4.1-glibc-2.10.1
/opt/crosstool/gcc-4.4.1-glibc-2.10.1/i486-linux-gnu
/opt/crosstool/gcc-4.4.1-glibc-2.10.1/i486-linux-gnu/usr
/opt/crosstool/gcc-4.4.1-glibc-2.10.1/x86_64-linux-gnu
/opt/crosstool/gcc-4.4.1-glibc-2.10.1/x86_64-linux-gnu/usr

and extract your Linux API headers into .../usr/include (for both i486 and x86_64 roots).

2. 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.10.1/elf/rtld.c:2718: undefined reference to `__open'
../glibc-2.10.1/elf/rtld.c:2690: undefined reference to `__access'
../build-glibc/elf/librtld.os: In function `dl_main':
../glibc-2.10.1/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.10.1:

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

3. Creating temporary folders for build

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

4. 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%
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 ==="

and apply Cygwin dos2unix tool to it in order to convert 0x0D,0x0A line endings (DOS/Windows format) to 0x0A line endings (UNIX format).

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.