Building Glibc in the Cygwin VM
- Before building glibc, you must remove the following folders:
/opt/crosstool/gcc-8.3.0-glibc-2.28/arm-linux-gnueabihf/include /opt/crosstool/gcc-8.3.0-glibc-2.28/arm-linux-gnueabi/include
- Update C:\Cygwin\opt\crosstool\src\build_cross_toolchain.sh :
#!/bin/bash export TARGET=arm-linux-gnueabihf export PREFIX=/opt/crosstool/gcc-8.3.0-glibc-2.28/$TARGET export PATH=$PATH:$PREFIX/bin cd /opt/crosstool/src/build-glibc find . -delete ../glibc-2.28/configure --prefix=/usr \ --with-headers=$PREFIX/usr/include \ --enable-add-ons=nptl --enable-kernel=5.0.0 \ --with-binutils=$PREFIX --build=x86_64-pc-cygwin \ --host=$TARGET --enable-shared --disable-profile \ --with-tls --with-__thread --without-gd --without-cvs \ --enable-add-ons \ libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_ssp=no if [ "$?" -ne "0" ]; then echo "=== build script: failed to configure glibc ===" exit 1 fi make if [ "$?" -ne "0" ]; then echo "=== build script: failed to make glibc ===" exit 1 fi make install_root=$PREFIX install if [ "$?" -ne "0" ]; then echo "=== build script: failed to install glibc ===" exit 1 fi echo "=== build script: OK ==="
- Run C:\Cygwin\opt\crosstool\src\build_cross_toolchain.cmd and wait until it completes.
- If there are no errors, shutdown Cygwin VM and make snapshot "SNAP-9".
- Replace TARGET=arm-linux-gnueabihf with TARGET=arm-linux-gnueabi in C:\Cygwin\opt\crosstool\src\build_cross_toolchain.sh, then run C:\Cygwin\opt\crosstool\src\build_cross_toolchain.cmd and wait until it completes.
- If there are no errors, shutdown Cygwin VM and make snapshot "SNAP-10".
Notes:
- Glibc build will take a lot of time, 4-5 times more than binutils + gcc.
- "--enable-kernel" sets minimum version of Linux kernel for this glibc to run on. 5.0.0 should be good for Raspberry Pi OS 10 "Buster" running on Raspberry Pi 4.
- "--prefix=/usr" is not dangerous and will not hurt your /usr in host system, unless you call "make install" in plain and wrong way. This is an old glibc joke.
- If you get the following error messages during build:In file included from ../sysdeps/unix/sysv/linux/i386/sysdep.h:27,
from <stdin>:1:
../sysdeps/i386/nptl/tls.h:24:11: fatal error: stdbool.h: No such file or directory
# include <stdbool.h>
^~~~~~~~~~~
compilation terminated.
make[2]: *** [../Makerules:287: /opt/crosstool/src/build-glibc/tcb-offsets.h] Error 1
make[2]: Leaving directory '/opt/crosstool/src/glibc-2.28/csu'
make[1]: *** [Makefile:258: csu/subdir_lib] Error 2
make[1]: Leaving directory '/opt/crosstool/src/glibc-2.28'
make: *** [Makefile:9: all] Error 2
then you forgot to delete the following folders before running the script:/opt/crosstool/gcc-8.3.0-glibc-2.28/arm-linux-gnueabihf/include /opt/crosstool/gcc-8.3.0-glibc-2.28/arm-linux-gnueabi/include
- Also you may get error message about various missing syscalls (__-prefixed) if you forgot to replace .oS with .oZ in makefiles (Cygwin case-insensitive filesystem).
>> Read next section or
buy already prepared
cross-compiler (€10) to save your time.