tc12_armv7l (on piCore RPi4)

tce-load -i compiletc perl5 ncurses-dev bash mpc-dev libudev-dev texinfo coreutils glibc_apps rsync gettext python3.8 git

export TC=/mnt/tc [***]

sudo mkdir $TC
sudo mount /dev/sda7 $TC [***]

sudo mkdir -pv $TC/{usr,lib,var,etc,bin,sbin}
sudo chown -v tc:staff $TC/{usr,lib,var,etc,bin,sbin}

sudo mkdir $TC/tools [***] 
sudo chown tc:staff $TC/tools [***]

sudo ln -s $TC/tools / [***]

sudo mkdir $TC/sources
sudo chown tc:staff $TC/sources

cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF

cat > ~/.bashrc << "EOF"
set +h
umask 022
TC=/mnt/tc
LC_ALL=POSIX
TC_TGT=arm-tc-linux-gnueabihf
PATH=$TC/tools/bin:/usr/local/bin:/bin:/usr/bin
export TC LC_ALL TC_TGT PATH
EOF

source ~/.bash_profile

----------

cd binutils-2.34

mkdir build
cd build

../configure --prefix=$TC/tools --with-sysroot=$TC --target=$TC_TGT --disable-nls --disable-werror --with-float=hard --with-fpu=vfp

make [8m42.773s]
make install


cd gcc-10.1.0

tar -xf ../mpfr-4.0.2.tar.xz
mv mpfr-4.0.2 mpfr
tar -xf ../gmp-6.2.0.tar.xz
mv gmp-6.2.0 gmp
tar -xf ../mpc-1.1.0.tar.gz
mv mpc-1.1.0 mpc

mkdir build
cd build

../configure --target=$TC_TGT --prefix=$TC/tools --with-glibc-version=2.11 --with-sysroot=$TC --with-newlib --without-headers --enable-initfini-array --disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads --disable-libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libstdcxx --enable-languages=c,c++ --with-float=hard --with-fpu=vfp [--with-arch=armv6]

make [95m21.500s]
make install

cd ..
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $($TC_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h


git clone --depth=1 --branch rpi-5.4.y https://github.com/raspberrypi/linux

cd linux

make mrproper

make headers
find usr/include -name '.*' -delete
rm usr/include/Makefile
cp -rv usr/include $TC/usr [need to save]


cd glibc-2.31

patch -Np1 -i ../glibc-2.31-fhs-1.patch
patch -Np1 -i ../glibc-2.31_long-double.patch

mkdir build
cd build

../configure --prefix=/usr --host=$TC_TGT --build=$(../scripts/config.guess) --enable-kernel=4.9.22 --with-headers=$TC/usr/include libc_cv_slibdir=/lib

config.h
/* The ARM hard-float ABI is being used.  */
#define HAVE_ARM_PCS_VFP 1


make [29m31.040s]
make DESTDIR=$TC install

echo 'int main(){}' > dummy.c
$TC_TGT-gcc dummy.c
readelf -l a.out | grep '/ld-linux'

[Requesting program interpreter: /lib/ld-linux-armhf.so.3] mustn't be ld-linux.so.3

rm dummy.c a.out

$TC/tools/libexec/gcc/$TC_TGT/10.1.0/install-tools/mkheaders


cd gcc-10.1.0 (libstdc++)

sudo ln -s /usr/local/bin/cpp /lib/cpp

mkdir build
cd build

../libstdc++-v3/configure --host=$TC_TGT --build=$(../config.guess) --prefix=/usr --disable-multilib --disable-nls --disable-libstdcxx-pch --with-gxx-include-dir=/tools/$TC_TGT/include/c++/10.1.0

make [2m58.934s]
make DESTDIR=$TC install

----

cd m4-1.4.18

sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

./configure --prefix=/usr --host=$TC_TGT --build=$(build-aux/config.guess)

make [0m35.557s]
make DESTDIR=$TC install


cd ncurses-6.2

sed -i s/mawk// configure

mkdir build
cd build
  ../configure
  make -C include
  make -C progs tic
cd ..

./configure --prefix=/usr --host=$TC_TGT --build=$(./config.guess) --mandir=/usr/share/man --with-manpage-format=normal --with-shared --without-debug --without-ada --without-normal --enable-widec

make [2m32.203s]

make DESTDIR=$TC TIC_PATH=$(pwd)/build/progs/tic install
echo "INPUT(-lncursesw)" > $TC/usr/lib/libncurses.so

mv -v $TC/usr/lib/libncursesw.so.6* $TC/lib
ln -sfv ../../lib/$(readlink $TC/usr/lib/libncursesw.so) $TC/usr/lib/libncursesw.so


cd bash-5.0

make [2m2.996s]
make DESTDIR=$TC install

mv $TC/usr/bin/bash $TC/bin/bash
ln -sv bash $TC/bin/sh


cd coreutils-8.32

./configure --prefix=/usr --host=$TC_TGT --build=$(build-aux/config.guess) --enable-install-program=hostname --enable-no-install-program=kill,uptime

make [3m38.457s]
make DESTDIR=$TC install

mv -v $TC/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} $TC/bin
mv -v $TC/usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} $TC/bin
mv -v $TC/usr/bin/{rmdir,stty,sync,true,uname} $TC/bin
mv -v $TC/usr/bin/{head,nice,sleep,touch} $TC/bin
mv -v $TC/usr/bin/chroot $TC/usr/sbin
mkdir -pv $TC/usr/share/man/man8
mv -v $TC/usr/share/man/man1/chroot.1 $TC/usr/share/man/man8/chroot.8
sed -i 's/"1"/"8"/' $TC/usr/share/man/man8/chroot.8


cd diffutils-3.7

./configure --prefix=/usr --host=$TC_TGT

make [0m41.573s]
make DESTDIR=$TC install


cd file-5.39

./configure --prefix=/usr --host=$TC_TGT

make [0m25.771s]
make DESTDIR=$TC install

Cannot use the installed version of file (5.37) to
cross-compile file 5.39
Please install file 5.39 locally first
make[2]: *** [Makefile:833: magic.mgc] Error 1


cd findutils-4.7.0

./configure --prefix=/usr --host=$TC_TGT --build=$(build-aux/config.guess)

make [0m58.303s]
make DESTDIR=$TC install

mv -v $TC/usr/bin/find $TC/bin
sed -i 's|find:=${BINDIR}|find:=/bin|' $TC/usr/bin/updatedb


cd gawk-5.1.0

sed -i 's/extras//' Makefile.in

./configure --prefix=/usr --host=$TC_TGT --build=$(./config.guess)

make [1m19.940s]
make DESTDIR=$TC install


cd grep-3.4

./configure --prefix=/usr --host=$TC_TGT --bindir=/bin --disable-perl-regexp

make [0m41.919s]
make DESTDIR=$TC install


cd gzip-1.10

./configure --prefix=/usr --host=$TC_TGT

make [0m17.236s]
make DESTDIR=$TC install

mv -v $TC/usr/bin/gzip $TC/bin


cd make-4.3

./configure --prefix=/usr --without-guile --host=$TC_TGT --build=$(build-aux/config.guess)

make [0m23.451s]
make DESTDIR=$TC install


cd patch-2.7.6

./configure --prefix=/usr --host=$TC_TGT --build=$(build-aux/config.guess)

make [0m29.975s]
make DESTDIR=$TC install


cd sed-4.8

./configure --prefix=/usr --host=$TC_TGT --bindir=/bin

make [0m29.910s]
make DESTDIR=$TC install


cd tar-1.32

./configure --prefix=/usr --host=$TC_TGT --build=$(build-aux/config.guess) --bindir=/bin

make [1m14.109s]
make DESTDIR=$TC install


cd xz-5.2.5

./configure --prefix=/usr --host=$TC_TGT --build=$(build-aux/config.guess) --disable-static --docdir=/usr/share/doc/xz-5.2.5

make [0m50.253s]
make DESTDIR=$TC install

mv -v $TC/usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} $TC/bin
mv -v $TC/usr/lib/liblzma.so.* $TC/lib
ln -svf ../../lib/$(readlink $TC/usr/lib/liblzma.so) $TC/usr/lib/liblzma.so


cd binutils-2.34

mkdir build
cd build

../configure --prefix=/usr --build=$(../config.guess) --host=$TC_TGT --disable-nls --enable-shared --disable-werror --enable-64-bit-bfd --with-float=hard --with-fpu=vfp

make [10m40.224s]
make DESTDIR=$TC install


cd gcc-10.1.0

tar -xf ../mpfr-4.0.2.tar.xz
mv -v mpfr-4.0.2 mpfr
tar -xf ../gmp-6.2.0.tar.xz
mv -v gmp-6.2.0 gmp
tar -xf ../mpc-1.1.0.tar.gz
mv -v mpc-1.1.0 mpc

patch -Np1 -i ../gcc-10.1.0-cet_fix-1.patch

mkdir build
cd build

mkdir -pv $TC_TGT/libgcc
ln -s ../../../libgcc/gthr-posix.h $TC_TGT/libgcc/gthr-default.h

../configure --build=$(../config.guess) --host=$TC_TGT --prefix=/usr CC_FOR_TARGET=$TC_TGT-gcc --with-build-sysroot=$TC --enable-initfini-array --disable-nls --disable-multilib --disable-decimal-float --disable-libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libstdcxx --enable-languages=c,c++ --with-float=hard --with-fpu=vfp

make [103m41.511s]
make DESTDIR=$TC install

ln -sv gcc $TC/usr/bin/cc

----

sudo chown -R root:root $TC/{usr,lib,var,etc,bin,sbin,tools}

sudo mkdir -pv $TC/{dev,proc,sys,run}

sudo mknod -m 600 $TC/dev/console c 5 1
sudo mknod -m 666 $TC/dev/null c 1 3

sudo mount -v --bind /dev $TC/dev

sudo mount -v --bind /dev/pts $TC/dev/pts
sudo mount -vt proc proc $TC/proc
sudo mount -vt sysfs sysfs $TC/sys
sudo mount -vt tmpfs tmpfs $TC/run

sudo chroot "$TC" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='(tc chroot) \u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login +h

mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
mkdir -pv /{media/{floppy,cdrom},srv,var}
mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv /usr/{,local/}share/man/man{1..8}
install -dv -m 1777 /tmp /var/tmp
install -dv -m 0750 /root

mkdir -v /var/{log,mail,spool}
ln -sv /run /var/run
ln -sv /run/lock /var/lock
mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local}

ln -sv /proc/self/mounts /etc/mtab
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts

[copy tc /etc/passwd and /etc/group files to $TC/etc]

exec /bin/bash --login +h

touch /var/log/{btmp,lastlog,faillog,wtmp}

chmod -v 664  /var/log/lastlog
chmod -v 600  /var/log/btmp

----

cd gcc-10.1.0 (libstdc++)

ln -s gthr-posix.h libgcc/gthr-default.h

mkdir build
cd build

../libstdc++-v3/configure CXXFLAGS="-g -O2 -D_GNU_SOURCE" --prefix=/usr --disable-multilib --disable-nls --host=arm-tc-linux-gnueabihf --disable-libstdcxx-pch

make [6m0.928s]
make install


cd bison-3.6.4

./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.6.4

make [0m57.869s]
make install


cd gettext-0.20.2

./configure --disable-shared

make [11m37.430s]

cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin


cd perl-5.32.0

sh Configure -des -Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/share/perl5/core_perl -Darchlib=/usr/lib/perl5/5.32/core_perl -Dsitelib=/usr/share/perl5/site_perl -Dsitearch=/usr/lib/perl5/5.32/site_perl -Dvendorlib=/usr/share/perl5/vendor_perl -Dvendorarch=/usr/lib/perl5/5.32/vendor_perl

make [11m49.330s]
make install


cd Python-3.8.3

./configure --prefix=/usr --enable-shared --without-ensurepip

make [8m24.446s]
make install


cd texinfo-6.7

./configure --prefix=/usr

make [1m36.586s]
make install


cd util-linux-2.35.2

add tty:x:4: to /etc/group

mkdir -pv /var/lib/hwclock

./configure ADJTIME_PATH=/var/lib/hwclock/adjtime --docdir=/usr/share/doc/util-linux-2.35.2 --disable-chfn-chsh --disable-login --disable-nologin --disable-su --disable-setpriv --disable-runuser --disable-pylibmount --disable-static --without-python

make [6m26.378s]
make install

find /usr/{lib,libexec} -name \*.la -delete

exit
sudo umount $TC/dev{/pts,}
sudo umount $TC/{sys,proc,run}

sudo rm -rf $TC/usr/share/{info,man,doc}

[backup]
cd $TC 
sudo /usr/local/bin/tar -cJpf tc-temp-tools-SVN-20200707.tar.xz .

cd $TC
sudo rm -rf ./* 
sudo tar -xpf tc-temp-tools-SVN-20200707.tar.xz

----

sudo mount -v --bind /dev $TC/dev

sudo mount -v --bind /dev/pts $TC/dev/pts
sudo mount -vt proc proc $TC/proc
sudo mount -vt sysfs sysfs $TC/sys
sudo mount -vt tmpfs tmpfs $TC/run

sudo chroot "$TC" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='(tc chroot) \u:\w\$ ' PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin /bin/bash --login +h

----------

cd glibc-2.31

patch -Np1 -i ../glibc-2.31-fhs-1.patch
patch -Np1 -i ../glibc-2.31_long-double.patch

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ../configure --prefix=/usr --disable-werror --enable-kernel=4.9.22 --enable-stack-protector=strong --with-headers=/usr/include libc_cv_slibdir=/lib --enable-obsolete-rpc --libexecdir=/usr/lib/glibc [still get libexec...]

config.h
/* The ARM hard-float ABI is being used.  */                                
#define HAVE_ARM_PCS_VFP 1   

find . -name config.make -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;
find ../ -name Makeconfig -type f -exec sed -i 's/-g -O2//g' {} \;

make [25m0.004s]

touch /etc/ld.so.conf

sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile

make install [install install_root=/tmp/pkg]

cp -v ../nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd

make localedata/install-locales [36m37.532s]

[copy tc /etc/nsswitch.conf and /etc/ld.so.conf files to $TC/etc]


cd zlib-1.2.11

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr

find . -name Makefile -type f -exec sed -i 's/-O3//g' {} \;

make [0m14.989s]
make install


cd bzip2-1.0.8

patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch

sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile

Edit Makefile-libbz2_so
CC=gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe
CFLAGS=-fpic -fPIC -Wall -Winline $(BIGFILES)

make -f Makefile-libbz2_so [0m7.928s]
make clean

Edit Makefile
CC=gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe
CFLAGS=-Wall -Winline $(BIGFILES)

make [0m8.136s]
make PREFIX=/usr/local install

cp bzip2-shared /usr/local/bin/bzip2
cp -a libbz2.so* /usr/local/lib
cd /usr/local/lib
ln -s libbz2.so.1.0 libbz2.so
cd ../bin
rm {bunzip2,bzcat}
ln -s bzip2 bunzip2
ln -s bzip2 bzcat

ldconfig


cd xz-5.2.5

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --disable-static --docdir=/usr/share/doc/xz-5.2.5

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m40.643s]
make install

ldconfig


cd zstd-1.4.5

find . -name Makefile -type f -exec sed -i 's/-O3//g' {} \;

make CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" [0m50.813s]
make CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" prefix=/usr/local install

ldconfig


cd file-5.39

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m20.063s]
make install

ldconfig


cd readline-8.0

sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --disable-static --with-curses --docdir=/usr/share/doc/readline-8.0

find . -name Makefile -type f -exec sed -i 's/CFLAGS = -g -O/CFLAGS = /g' {} \;

make SHLIB_LIBS="-lncursesw" [0m17.755s]
make SHLIB_LIBS="-lncursesw" install


cd m4-1.4.18

sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m20.805s]
make install


cd bc-3.0.3

PREFIX=/usr/local CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CFLAGS="-std=c99" ./configure.sh -G

make [0m9.212s]
make install


cd flex-2.6.4

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --docdir=/usr/share/doc/flex-2.6.4

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m29.829s]
make install

ln -sv flex /usr/local/bin/lex

ldconfig


cd binutils-2.34

sed -i '/@\tincremental_copy/d' gold/testsuite/Makefile.in
patch -Np1 -i ../binutils-2.34-gcc10_gold_test_fix-1.patch

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ../configure --prefix=/usr --enable-gold --enable-ld=default --enable-plugins --enable-shared --disable-werror --enable-64-bit-bfd --with-system-zlib --with-float=hard --with-fpu=vfp

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-O2 -g//g' {} \;

make tooldir=/usr [20m6.301s]
make tooldir=/usr install


cd gmp-6.2.0

mv config{fsf,}.guess
mv config{fsf,}.sub

ABI=32 CFLAGS="-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXXFLAGS="-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ./configure --prefix=/usr/local --enable-cxx --disable-static --docdir=/usr/share/doc/gmp-6.2.0 --enable-assembly=no

make [2m54.155s]
make install

ldconfig


cd mpfr-4.0.2

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ./configure --prefix=/usr/local --disable-static --enable-thread-safe --docdir=/usr/share/doc/mpfr-4.0.2

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [1m57.248s]
make install

ldconfig


cd mpc-1.1.0

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ./configure --prefix=/usr/local --disable-static --docdir=/usr/share/doc/mpc-1.1.0

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m23.785s]
make install

ldconfig

cd gcc-10.1.0

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ../configure --prefix=/usr LD=ld --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib --libexecdir=/usr/lib  --with-float=hard --with-fpu=vfp

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-O2 -g//g' {} \;
find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;
[-O2 still appears building libs]

make [78m37.675s]
make install

rm -rf /usr/lib/gcc/$(gcc -dumpmachine)/10.1.0/include-fixed/bits/
ln -sv ../usr/bin/cpp /lib
install -v -dm755 /usr/lib/bfd-plugins
ln -sfv /usr/lib/gcc/$(gcc -dumpmachine)/10.1.0/liblto_plugin.so /usr/lib/bfd-plugins/

mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'

      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log

/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/10.1.0/../../../crt1.o succeeded
/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/10.1.0/../../../crti.o succeeded
/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/10.1.0/../../../crtn.o succeeded

grep -B4 '^ /usr/include' dummy.log

#include <...> search starts here:
 /usr/lib/gcc/armv7l-unknown-linux-gnueabihf/10.1.0/include
 /usr/local/include
 /usr/lib/gcc/armv7l-unknown-linux-gnueabihf/10.1.0/include-fixed
 /usr/include

grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'

SEARCH_DIR("/usr/armv7l-unknown-linux-gnueabihf/lib")
SEARCH_DIR("/usr/local/lib")
SEARCH_DIR("/lib")
SEARCH_DIR("/usr/lib");

grep "/lib.*/libc.so.6 " dummy.log

attempt to open /lib/libc.so.6 succeeded

grep found dummy.log

found ld-linux.so.3 at /lib/ld-linux-armhf.so.3

rm -v dummy.c a.out dummy.log

----

cd binutils-2.34

sed -i '/@\tincremental_copy/d' gold/testsuite/Makefile.in
patch -Np1 -i ../binutils-2.34-gcc10_gold_test_fix-1.patch

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ../configure --prefix=/usr/local --enable-gold --enable-ld=default --enable-plugins --enable-shared --disable-werror --enable-64-bit-bfd --with-system-zlib --with-float=hard --with-fpu=vfp

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-O2 -g//g' {} \;

make tooldir=/usr/local [22m56.344s]
make tooldir=/usr/local install

[remove binutils from /usr]
ldconfig


cd gcc-10.1.0

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ../configure --prefix=/usr/local --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib --libexecdir=/usr/local/lib --with-float=hard --with-fpu=vfp

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-O2 -g//g' {} \;
find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;

make [87m34.309s]
make install

rm -rf /usr/local/lib/gcc/$(gcc -dumpmachine)/10.1.0/include-fixed/bits/
ln -sv ../usr/local/bin/cpp /usr/local/lib
install -v -dm755 /usr/local/lib/bfd-plugins
ln -sfv /usr/local/lib/gcc/$(gcc -dumpmachine)/10.1.0/liblto_plugin.so /usr/local/lib/bfd-plugins/

mkdir -pv /usr/local/share/gdb/auto-load/usr/local/lib
mv -v /usr/local/lib/*gdb.py /usr/local/share/gdb/auto-load/usr/local/lib

[remove gcc from /usr except libstdc++ and libgcc_s]

----

cd pkg-config-0.29.2

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --with-internal-glib --disable-host-tool --docdir=/usr/share/doc/pkg-config-0.29.2 --with-pc-path="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/share/pkgconfig"

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-g -Wall -O2/-Wall/g' {} \;

make [1m28.517s]
make install


cd ncurses-6.2

sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --mandir=/usr/local/share/man --with-shared --without-debug --without-normal --enable-pc-files --enable-widec --with-cxx-shared

find . -name Makefile -type f -exec sed -i 's/-O2//g' {} \;

make [2m35.387s]
make install

[remove ncurses from /usr]
ldconfig

cd sed-4.8

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m25.068s]
make install

[rm /bin/sed]


cd bison-3.6.4

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --docdir=/usr/share/doc/bison-3.6.4

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m47.891s]
make install

[remove bison files from /usr]


cd grep-3.4

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m33.120s]
make install

[remove grep from /bin]


cd bash-5.0

patch -Np1 -i ../bash-5.0-upstream_fixes-1.patch

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --docdir=/usr/share/doc/bash-5.0 --without-bash-malloc --with-installed-readline

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [1m30.497s]
make install

cd /bin
rm bash
ln -sv /usr/local/bin/bash ./

exec /bin/bash --login +h


cd gperf-3.1

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --docdir=/usr/share/doc/gperf-3.1

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m6.901s]
make install


cd expat-2.2.9

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --disable-static --docdir=/usr/share/doc/expat-2.2.9

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m16.950s]
make install


cd perl-5.32.0

export BUILD_ZLIB=False
export BUILD_BZIP2=0

sh Configure -des -Dcc="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" -Dprefix=/usr/local -Dvendorprefix=/usr/local -Dprivlib=/usr/local/share/perl5/core_perl -Darchlib=/usr/local/lib/perl5/5.32/core_perl -Dsitelib=/usr/local/share/perl5/site_perl -Dsitearch=/usr/local/lib/perl5/5.32/site_perl -Dvendorlib=/usr/local/share/perl5/vendor_perl -Dvendorarch=/usr/local/lib/perl5/5.32/vendor_perl -Dman1dir=/usr/local/share/man/man1 -Dman3dir=/usr/local/share/man/man3 -Dpager="/usr/bin/less -isR" -Duseshrplib -Dusethreads

find . -name Makefile -type f -exec sed -i 's/-O2//g' {} \;

make [13m53.534s]
make install

unset BUILD_ZLIB BUILD_BZIP2

rm /usr/bin/perl


cd XML-Parser-2.46

perl Makefile.PL

make [0m9.288s]
make install


cd intltool-0.51.0

sed -i 's:\\\${:\\\$\\{:' intltool-update.in

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

make [0m0.166s]
make install
install -v -Dm644 doc/I18N-HOWTO /usr/local/share/doc/intltool-0.51.0/I18N-HOWTO


cd libtool-2.4.6

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --disable-static

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m5.905s]
make install


cd autoconf-2.69

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

make [0m3.608s]
make install


cd automake-1.16.2

sed -i "s/''/etags/" t/tags-lisp-space.sh

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

make [0m3.532s]
make install


cd gettext-0.20.2

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --disable-static --docdir=/usr/share/doc/gettext-0.20.2 --disable-curses

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;

make [11m21.377s]
make install

chmod -v 0755 /usr/local/lib/preloadable_libintl.so

rm /usr/bin/{msgfmt,msgmerge,xgettext}

ldconfig


cd coreutils-8.32

patch -Np1 -i ../coreutils-8.32-i18n-1.patch

sed -i '/test.lock/s/^/#/' gnulib-tests/gnulib.mk

autoreconf -fiv

#define MBFILE_INLINE _GL_EXTERN_INLINE in src/{un,}expand.c before
#include <mbfile.h>

FORCE_UNSAFE_CONFIGURE=1 CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --enable-no-install-program=kill,uptime --libexecdir=/usr/local/lib

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;

make [3m22.057s]
make install

rm /bin/{cat,echo,pwd,stty}
cd /bin
ln -s /usr/local/bin/cat cat
ln -s /usr/local/bin/echo echo
ln -s /usr/local/bin/pwd pwd
ln -s /usr/local/bin/stty stty


cd diffutils-3.7

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m34.249s]
make install


cd gawk-5.1.0

sed -i 's/extras//' Makefile.in

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --libexecdir=/usr/local/lib/gawk

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [1m6.324s]
make install


cd findutils-4.7.0

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var/lib/locate --libexecdir=/usr/local/lib/findutils

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m46.988s]
make install


cd groff-1.22.4

PAGE=A4 CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make -j1 [3m2.883s]
make install


cd gzip-1.10

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m15.294s]
make install


cd make-4.3

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m21.128s]
make install


cd patch-2.7.6

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [0m24.111s]
make install


cd tar-1.32

FORCE_UNSAFE_CONFIGURE=1 CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --libexecdir=/usr/local/lib/tar

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [1m1.435s]
make install


cd texinfo-6.7

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [1m30.346s]
make install
make TEXMF=/usr/local/share/texmf install-tex


cd util-linux-2.35.2

mkdir -pv /var/lib/hwclock

ADJTIME_PATH=/var/lib/hwclock/adjtime CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --docdir=/usr/share/doc/util-linux-2.35.2 --disable-chfn-chsh --disable-login --disable-nologin --disable-su --disable-setpriv --disable-runuser --disable-pylibmount --disable-static --without-python --without-systemd --without-systemdsystemunitdir --libexecdir=/lib

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [6m18.467s]
make install

ldconfig


cd e2fsprogs-1.45.6

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ../configure --prefix=/usr --bindir=/bin --with-root-prefix="" --enable-elf-shlibs --disable-libblkid --disable-libuuid --disable-uuidd --disable-fsck

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-O2//g' {} \;

make [2m36.381s]
make install
make install-libs
chmod u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a

----------

cd util-linux-2.35.2

ADJTIME_PATH=/var/lib/hwclock/adjtime CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --docdir=/usr/share/doc/util-linux-2.35.2 --disable-chfn-chsh --disable-login --disable-nologin --disable-su --disable-setpriv --disable-runuser --disable-pylibmount --disable-static --without-python --without-systemd --without-systemdsystemunitdir --libexecdir=/usr/local/lib --localstatedir=/var

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [6m18.467s]
make install


cd e2fsprogs-1.45.6

mkdir build
cd build

CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ../configure --prefix=/usr/local --enable-elf-shlibs --disable-libblkid --disable-libuuid --disable-uuidd --disable-fsck

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-O2//g' {} \;

make [2m35.826s]
make install
make install-libs
chmod u+w /usr/local/lib/{libcom_err,libe2p,libext2fs,libss}.a

[remove files to match base/extension setup]
